Help: stochastic readings - page 2

 
blogzr3:

Looking post #1 again, it is possible you are not using iStochastic as it is mean to be. You are supposed to be comparing the %K and %D for the same shift, and comparing which is higher or lower.

Basically, it still comes down to something is not identical, or some logic is not correct, or you misinterpreted something. Whatever it is, without the code, no one can tell.




Thanks for your reply.

I am using iStochastic correctly, exactly as you have written.

The code is not the issue, the reading are.

Here are the relevant lines:

STO_Value_current = iStochastic(Symbol(),PERIOD_M1,K,D, Slowing,MODE_SMA,1,MODE_MAIN,0);

STO_Signal_current = iStochastic(Symbol(),PERIOD_M1,K,D, Slowing,MODE_SMA,1,MODE_SIGNAL,0);

STO_Value_prev = iStochastic(Symbol(),PERIOD_M1,K,D, Slowing,MODE_SMA,1,MODE_MAIN,1);

STO_Signal_prev = iStochastic(Symbol(),PERIOD_M1,K,D, Slowing,MODE_SMA,1,MODE_SIGNAL,1);

(K,D,Slowing etc as parameters).


All parameters are similar, EA and chart.


Still, what I see on the chart is not what is reported by Strategy Tester Journal.

 
jirimac:

I think i works the way it should.

I guess you use the crosses of Signal and Main, so the first cross is at 10am since you use the 0 and 1 offset and because its calculated on closed, it will open the next Open candle which is at 11am.

You will find out that most of the signals generated based on the indicators are quite late..

You might want to try to generate the signal when direction of the Main line change, then you would get it one bar earlier. But I guess its all speculative..


I moved to M1 chart.

There, I see that readings are made every tick, not every minute. In fact, I get several different reading every minute.

When I try to execute a command, it shoots off on one of those readings, not on the exact close of that minute.

How can I control this?

 
zevbn:

I moved to M1 chart.

There, I see that readings are made every tick, not every minute. In fact, I get several different reading every minute.

When I try to execute a command, it shoots off on one of those readings, not on the exact close of that minute.

How can I control this?

Moreover: If I call the function when Seconds() == 0, I still get different readings between the chart and the Journal.

 

If you are doing the iStochastic every tick, then you are working your Expert very hard. (If you do not require it to)

Build a trigger to test the Stoch when every new candle starts.

Put something like this in your start section....


if ( Time[0] != CurrentBarTime )

{

// Reset all of the things required at the start of each new Bar here.

CurrentBarTime = Time[0];
STO_Value_current = iStochastic(Symbol(),PERIOD_M1,K,D, Slowing,MODE_SMA,1,MODE_MAIN,0);

etc....

}


Then you will have numbers that match the live screen.

(You will have to create the variable CurrentBarTime at the top of your expert as a static int.)

Gavin.

Reason: