Important question - shifted indicators

 

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!

 
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?"
 
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.
 
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
Reason: