-
Don't post pictures of code, they are too hard to read.
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor -
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time post in the correct place. The moderators will likely move this thread there soon.
Don't use local time. OrderOpenTime is broker time zone. You don't need TimeToStruct. Just compare TimeCurrent() - OrderOpenTime() >= certain number of hours * 3600
Thanks I'll try It right away
When I've experimented with a similar concept it proved to be useful to have a boolean variable indicating if it is OK or not to open a new position. Because on an H1 timescale the "hours passed" condition will still be true even after your EA opened like 5-10 positions...
I understand, and every time the condition is fulfilled the Boolean variable resets. Did you use as a Global or local ?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm trying to code a function on my expert advisor that opens or closes a trade after a certain number of hours, my idea is to work similarly to sure-fire hedging but my problem is when I test my code it opens like 9 or more trades at a time and I don't understand why.