Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Closing at 23:59 hours is not reliable because your broker usually will not allow opening/closing because of swap/rollover period. You can also check the times when your broker actually allows you to trade the symbol with ctrl M.
For min you can see that I get quotes for EURUSD from 00:00 to 23:57 but I can't actually trade until 4 mins after open and I can't trade three mins before close. Also why would you want to close at exactly these times? The spread is incredibly crazy

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
I am having trouble creating a snippet of code to sit within in a EA to close all trades at the end of the day.
MT5 build number 5.00 build 5260
Account type Netting
Tester settings Model: 1-minute OHLC
My expectation To close the trade as close to EOD as possible, and on Fridays must close before end of day
What actually happens Closes next day, between 1 and 7 minutes into the day
My question:
What am I missing in netting + 1-minute OHLC mode that prevents PositionClose(_Symbol) (and even the fallback opposite order) from closing the trade at 23:59 daily?
Any insight into known tester limitations, or what extra step is needed to force the tester to flatten the net position at the desired time?
My code: