mr.Potter

Читают

User-icon
12

Записи

51

Формула индикатора ADX в WLD4

Ребята, кто нибудь знает как в ADX рассчитывается?

Взял формула из мануала WLD4:

+DI = Round( ( +DM / TR ) * 100 )

where,

DI+ = DIPlus
TR = True Range of current bar

The +DI is then smoothed over the period specified, the same way as a simple moving average, and +DM is calculated as follows:

(i) For up trending days, +DM = today's high — yesterday's high
(ii) For down trending days, +DM = zero
(iii) For inside days, +DM = zero
(iv) For outside days, if today's high — yesterday's high, is greater than yesterday's low- today's low, then +MD = today's high — yesterday's high, otherwise +DM = zero
(v) For upwards gap days, +DM = today's high — yesterday's high
(vi) For downwards gap days, +DM = zero

Прописал на C#, Lua — не фига не подходит, даже на WLD4 сделал аналогичную функцию:

function MyDXPluse(Period: integer): integer;
begin

var BarSys,pDM,mDM,pDMA,mDMA,ATRA,R: integer;

var dHigh,dLow: float;

pDM := CreateSeries();
mDM := CreateSeries();

mDMA := CreateSeries();
pDMA := CreateSeries();

Result:= CreateSeries();
R:= CreateSeries();

for BarSys := Period to BarCount - 1 do
begin

   dHigh := @#High[BarSys] - @#High[BarSys-1];
   dLow := @#Low[BarSys-1] - @#Low[BarSys];


  if ((dHigh < 0) and (dLow < 0)) or (dHigh=dLow) then begin
      SetSeriesValue( BarSys,pDM,0);
      SetSeriesValue( BarSys,mDM,0);
   end;
   if (dHigh > dLow) then begin
      SetSeriesValue( BarSys, pDM,dHigh);
      SetSeriesValue( BarSys, mDM, 0);
   end;

   if (dHigh < dLow) then begin
      SetSeriesValue( BarSys, pDM,0);
      SetSeriesValue( BarSys, mDM,dLow);
   end;
  
end; //for

{
pDMA:= WilderMASeries(pDM,Period);
mDMA:= WilderMASeries(mDM,Period);

ATRA := ATRSeries(Period);
}

ATRA := TrueRangeSeries();

for BarSys := Period to BarCount() - 1 do begin
SetSeriesValue( BarSys, R,  Round( 100 * (@pDM[BarSys] / @ATRA[BarSys])));
end; //for

Result :=  WilderMASeries(R,Period);

end;  //function
//--------------------------------------------------------------------------------

var x : integer = MyDXPluse(7);


var xPane: integer =  CreatePane( 75, true, true );
PlotSeriesLabel( x, xPane, 009, #Thick, 'MyDXPluse Plot' );


( Читать дальше )

теги блога mr.Potter

....все тэги



UPDONW
Новый дизайн