Hi gurus,
I seem to be having a problem with my OrderClose() function. I want to close all orders at a specific time. I used the code from RaptorUK's thread: https://forum.mql4.com/48352
When it reaches the specific time it doesn't run the function and does not close orders; any ideas? Below is the code:
There are no values printed in tester.
Thanks in advance.
What function?
Where is this placed in your code?
- If you placed a print statement before the if, you would know whether the code is even being called.
- If the EA opens multiple orders, you need a RefreshRates before using OrderClosePrice.
When can minute ever be negative? if(Hour()==23 && Minute()>=0)
- If you placed a print statement before the if, you would know whether the code is even being called.
- If the EA opens multiple orders, you need a RefreshRates before using OrderClosePrice.
When can minute ever be negative?
I used this because I want it to check from the first second of the first minute of the hour for a tick.
if(Hour()==23 && Minute()>=0)
Added RefreshRates(); thanks!
There seems to be a problem with the above time if() statement. It is not calling it at all. If I remove the time code it closes all orders. Is there another way to represent this time as something else?
There seems to be a problem with the above time if() statement. It is not calling it at all. If I remove the time code it closes all orders. Is there another way to represent this time as something else?
Yes, use if(TimeHour(TimeCurrent())==23) instead.
Yes, use if(TimeHour(TimeCurrent())==23) instead.
Still not working? :(
Probably because you have a return(0) before the code can be executed or whatever symbol you are using stops trading before 23:00 hours
Thank you good sir!
I had a return(1) in my OrderDelete() function that was called before OrderClose(). I now have just added expiration time to all pending orders which would have been deleted by the OrderDelete().
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi gurus,
I seem to be having a problem with my OrderClose() function. I want to close all orders at a specific time. I used the code from RaptorUK's thread: https://forum.mql4.com/48352
When it reaches the specific time it doesn't run the function and does not close orders; any ideas? Below is the code:
There are no values printed in tester.
Thanks in advance.