SteveHopwood » Sun May 18, 2014 1:01 am wrote:kwchau » Fri May 16, 2014 11:49 am wrote:Here are my test results so far on H1 charts:
For the buy or sell twice trend EAs, there is no waiting time to execute an entry, everything seems fine.
For the single entry trend EAs, the entry still has problem but I think I have figured it out . I used the default waiting time of 2 minutes before taking a trade. If the waiting time finished on the same bar, the trade would be entered correctly. If the waiting time was beyond the current bar, i.e., a new bar formed before the 2 minutes waiting time was up, the EA reset everything at the new bar opening. For example, if price broke stoch 10 one minute before bar close, when the new bar started, everything will be reset. Since at that time, the price has already passed Stoch 10, the EA would wait until price broke the Stoch 30 threshold.
I do not trade counter trend trade, so I haven't tested them but I believe the logic would be the same.
The EA's decide there is a trade to be taken,
then go into a loop that examines the Sto7 for a retreat into an untradable area for however long you chose the waiting time to be. If Sto7 retreats at any point, the trade is cancelled. If not, the ea proceeds to attempt to take the trade on exit from the loop.
If the trade attempt fails, then the ea resumes normal activity. If conditions are still correct for a trade, it starts the cycle again. If not, there is no further attempt to trade.
The Sto7 can scream up and down like an elevator on acid. On the charts and if at the close of the candle, it is the same value as it was at the candle open, in retrospect it will look as though the thing has not moved for the entire 4 hours - yet it might have opened and closed several trades.
That is the downside of using 'confirmation' delays with an indi as sensitive as those being used here. We might not get what we assumed we would get from looking back in time. Bob says he trades when everything else is in place and Sto7 crosses appropriately. He does not await 'confirmation' stuff like 'remained above for x period of time' or 'wait for the candle to close' etc
You might be barking at the wrong moon with all this. Not saying you
are, just suggesting you
might be.

Hello Steve and everyone.
I looked into this and have to say, that though the moon was the wrong one, the problem still exists. It is not in the loop that examines the Sto7, but in the way stochastic itself behaves. When a new bar starts, the 7-bar range on which it is calculated shifts one bar to the right. This sometimes causes the line to jump over the threshold immediately. Then the ReadIndicatorValues() function detects a new M5 bar and decides to renew the "previous" value of Sto7. Both previous and current values appear to be the same, so no cross is detected.
I think that changing this line
Code: Select all
if (!EveryTickMode) dStochMain[1]=GetStochastic(Symbol(),0,KPeriod,DPeriod,Slowing,Method,Price,MODE_MAIN,shift + 1);
into this
Code: Select all
if (!EveryTickMode || iTime(NULL,TradingTimeFrame,0) == iTime(NULL,1,0)) dStochMain[1]=GetStochastic(Symbol(),0,KPeriod,DPeriod,Slowing,Method,Price,MODE_MAIN,shift + 1);
should do the trick. It takes the Sto7 value from the previous bar, if the current one has just opened.
Logically I'm not sure if the cross as a result of a change in parameters rather than price movement should really count. In extreme cases the line can jump from 10 straight to 90, which would cause a fast open/close and self-destruction. Some additional check may be required just in case.
But it is a cross nevertheless. 1 or 2 profitable trades were not taken yesterday on my demo because of this.
Cheers!