# iStochastic grabbing the former value

25

Hi all,

I have another query.

I am using the following code to retrieve the stochastic value at the 0000hrs mark:

`iStochastic(NULL,PERIOD_H4,14,3,3,MODE_SMA,0,MODE_MAIN,0);`

The above code gives me a value of 12.136685

However, on my chart with the same plotted as above, it is different from the value. I get the value 25.320764 for 0000hrs using iStochastic(NULL,PERIOD_H4,fast,3,3,MODE_SMA,0,MODE_MAIN,1) at 0400hrs.

When I tried shifting +1 bar, it returned the correct previous closed bar value.

So what I want is when my EA runs at 0000hrs, I want to retrieve the stochastic for the time 0000hrs which has a value of 25.320764.

15924

ShivaDagger: So what I want is when my EA runs at 0000hrs, I want to retrieve the stochastic for the time 0000hrs which has a value of 25.320764.

You want to know the future. IStochastic( H4, 1 ) at 0400 is the stochastic for the completed H4 0000 bar, the final value at 0359.99, 25.32. You can't get that value until 0400. Prior to then the iStochastic( H4, 0 ) bar is still forming and the value started at 12.13 (0000) and converged to 25.32 at the end of the 4 hours.

25

Thanks once again WHRoeder.

I thought that was the case and it was possible to retrieve, because it kinda make more sense since 2000hrs will already have its own value, then at 0000hrs a new value would have generated and the graph on the chart is straight line running through those 2 values.

But now I know, You've helped me out a whole lot!

25

Actually just curious, wouldn't that mean that on my chart, when the clock hits 0400hrs, my chart only started to draw the stochastic line for 2000hrs to 0000hrs? That is 8 hours difference, 2 blocks of time behind, does it work this way?
15924

No, the line for the 0000-0359 bar is drawn, it just move up and down as price changes.
25

If that is the case, doesn't it mean that the starting point at 0000hrs would have been there when 0000 is drawn? Because it is required the time to be 0400 for the 0000 value to be determined, at 0000 the line from 2000 to 0000 should have been drawn correct? Sorry a little confused here.
15924

The line from 2000 to 0000 is drawn when the 0000 candle starts. The 0000 endpoint moves as price does (per specific indicator)

Open a M1 chart, enlarge the bars to max (+ key) and add a MA with period 2, watch the line.