there's many ways to do that, sample is below, check the documentation please
int start () { while (!IsStopped()) { datetime local = TimeLocal(); if ( (TimeDayOfWeek (local) == 5 && TimeHour (local) == 23 && TimeMinute (local) == 59 && TimeSeconds (local) >= 00 ) || TimeDayOfWeek (local) > 5 ) { // code in action } Sleep (100); //must have sleep if we use tight while loop } return (0); }
That sleep thing, we must have them if we use tight loop, just don't take too long or we may miss a tick while we're sleep :(
I said many ways. You have to code them carefully, since if that code miss minute 59, then the code in action will never get executed. That's why there is TimeDayOfWeek (local) > 5 - just in case.
:)
lostbridge:
You shouldn't be trading if there are no ticks coming in, or coming in very slowly. In the last few minutes of the market being open the spread can get quite bad and you will not see this on the strategy tester. I would close out any positions well before the market closes, say 20 minutes minimum. Then you can just run your EA standardly and when the time is greater than your cutoff time close out the positions.
I am thinking of close all open orders at 23:59:00 on Friday but it may not happen when there is no new tick coming in. I have searched the documetation but did not find anything close.
Please help me. Thanks
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 thinking of close all open orders at 23:59:00 on Friday but it may not happen when there is no new tick coming in. I have searched the documetation but did not find anything close.
Please help me. Thanks