I have a system that I actually use since months in real automated trading but very rarely it enter a trade before the time indicated in the time conditions.
My strategy works over a 3 minutes charts and is must enter a trade ONLY between 9:03 and 11:00 of the morning.
So basically I've done a simple code like this :
Code: Select all
//Time frame of the day where entries are allowed
isTheRightTime = ( time >= Time_MorningStart_at and time <= Time_MorningStop_at) or ( time >= Time_AfternoonStart_at and time <= Time_AfternoonStop_at);
My trading system has to start checking bars from 9:00 and the early trade possible is exactly at the close of the first 3 minutes candle after the opening european bell that is at 9:00 gmt. As i said I need that the first candle is closed so I set the Time_MorningStart_at = 903.
Ok so doing that 99% of times work correctly but I have experienced some STOPLOSS due some early enters made between the 9:00 and 9:03... this mean that the system checked the 3 minutes bar between the 8:57 and 9:00 and then found the conditions to enter a trade, so at the opening of the following bar ( 9:00 - 9:03) it entered the trade ( WRONGLY BECAUSE it has only to start trading AFTER the first 3 minute bar starting from 9:00 indeed it should only allow trading some milliseconds after 9:03).
So How can I solve this? If you think that It would be enough to set the start at 9:06 that's not working and it miss a LOT of trades).
Any help is appreciated.
Thanks
David