Problem with %D value in stochastic

JGF
186
JGF  

Dear Guru's;

I have a simple EA that calls up iStochastic for the previous bar. The %K line is exactly right when checked via the subsequent print statement. However the %D line is way off and does not correspond to any nearby bars. I have tried using both "MODE_SIGNAL" as well as "1" in the mode value but get the same incorrect results. Its baffling because

               //Stochastic
               double   KLine_HTF_Last   = iStochastic(NULL,PERIOD_H1,Stochastic_K_HTF,Stochastic_D_HTF,Stochastic_S_HTF,MODE_SMA,PRICE_CLOSE,0,1);         
               double   DLine_HTF_Last   = iStochastic(NULL,PERIOD_H1,Stochastic_K_HTF,Stochastic_D_HTF,Stochastic_S_HTF,MODE_SMA,PRICE_CLOSE,1,1);         
               Print("KLine_HTF_Last =",KLine_HTF_Last," DLine_HTF_Last =",DLine_HTF_Last);        

the %K value is exactly right and the code is the same, except for the Mode value.

has anyone had this problem before? Any ideas?


ps: the "HTF" refers to "Higher Time Frame. I use this to determine the Stochastic value of the previous H1 bar, just after the opening of the zero minute bar


many thanks

JGF