In my trading system I would like to operate in FOREX market just once in a single day. For example if certain conditions are met the system enters. Imagine that after a certain number of hours the system exit from the market either because of exit conditions or because of stop loss or trailing stop. I would like the system avoids entering again in the market within the same day and instead waits for the next day to enter again.
A possible way to implement this test is setting a variable at 0 at beginning of the day. If the system enters (long/short conditions met) the variable is set to 1. This prevents the system to enter again in the same day since I add the condition variable=0 in the long/short conditions. But I do not know how to reset the variable at the beginning of each day-trading operating hours.
You can reset easily your variable each day by testing the intraday bar index with the instruction : intradaybarindex
Reset your variable by doing this:
1
2
3
ifintradaybarindex=0then
tradedtoday=0
endif
And set your variable “tradedtoday” to 1 when you launch a trade. Test it before initiate a new trade. That’s all 🙂
You could have tested also if the daily open candle was the same as the one saved before in a variable, that’s what I do in other platform programming.