I'm trying to write an EA that limits trades to once a day. However, I cannot find a function for time that will work when backtesting ( the system checks the current time, not the timeframe thats being backtested). Has anyone developed a function for this, or am I missing something obvious?
- Limiting EA to one trade per bar
- Taking a trade at 01:05 AM
- Questions from Beginners MQL5 MT5 MetaTrader 5
cwn6161:
I'm trying to write an EA that limits trades to once a day. However, I cannot find a function for time that will work when backtesting ( the system checks the current time, not the timeframe thats being backtested). Has anyone developed a function for this, or am I missing something obvious?
I'm trying to write an EA that limits trades to once a day. However, I cannot find a function for time that will work when backtesting ( the system checks the current time, not the timeframe thats being backtested). Has anyone developed a function for this, or am I missing something obvious?
During Backtesting, Time is modelled !
Note: At the testing, local time is modelled and is the same as the modelled last known server time. |
Use DayOfWeek: Example:
if (TimeStamp != DayOfWeek()) { OrderSend......; TimeStamp = DayOfWeek(); }
That way when it comes around the second time, TimeStamp Will be equal to Monday or Tuesday or Whatever. So then it will Not move on to OrderSend.
Thanks for the help! I had tried using DayOfWeek before, but for some reason the trades weren't being limited correctly. Probably just an error in another part of the logic. Things look good now.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register