Download MetaTrader 5
To add comments, please log in or register
Move from theory to practice. Code Base will help you!
MisterFantastic
9
MisterFantastic 2014.07.09 07:03 

Hello all!

From what I learned, the following two Indicators (which only differ in the shift attribute) should return exactly the same values, just shifted by one period:

PlusDI = iADX(NULL,0,14,PRICE_OPEN,MODE_PLUSDI,0);
PlusDI = iADX(NULL,0,14,PRICE_OPEN,MODE_PLUSDI,1);

 Mysteriously, it sometimes works, but most of the time they do not return the same values (shifted).

 In my code, these lines above are executed at the beginning of each new candle.

 

I hope, someone can shed some light on this. Thank you!

whroeder1
13609
whroeder1 2014.07.09 11:53  
stevie: From what I learned, the following two Indicators (which only differ in the shift attribute) should return exactly the same values, just shifted by one period:
Adx, like a moving average, changes each bar. The Adx[0] has a new price added (the open.)
Why would you think you'd get "exactly the same value?"
xavilin
48
xavilin 2014.07.09 14:50  
WHRoeder:
stevie: From what I learned, the following two Indicators (which only differ in the shift attribute) should return exactly the same values, just shifted by one period:
Adx, like a moving average, changes each bar. The Adx[0] has a new price added (the open.)
Why would you think you'd get "exactly the same value?"

isn't he saying that adx[0] now should be equal to adx[1] in the next period, but that it doesn't in his ea? if that's the case, i guess it is because at the begining of the bar, adx[0] is calculated with the first tick, while adx[1] is calculated with the whole bar. indeed, adx[1] now should be equal to adx[2] next period, but what he's asking is not possible neither logical.
Ian Venner
2583
Ian Venner 2014.07.10 02:29  
PlusDI = iADX(NULL,0,14,PRICE_OPEN,MODE_PLUSDI,0); //- the value of a 14 period adx calculated using bars 0 through 13
PlusDI = iADX(NULL,0,14,PRICE_OPEN,MODE_PLUSDI,1); //- the value of a 14 period adx calculated using bars 1 through 14
/
To add comments, please log in or register