salexes:
Right now if all conditions are met it openens a trade at that moment, but on every candle after this (where conditions are still met) too, how can I limit it to only take a trade once?
Right now if all conditions are met it openens a trade at that moment, but on every candle after this (where conditions are still met) too, how can I limit it to only take a trade once?
Can I somehow set a flag so it will be checked if an order was already executed once, and once the conditions change and are not met anymore it gets reset, till the next time all conditions are met?
Right now your condition is testing a level | bool isBuy = Bid > X; |
Don't test a level, test a change in signal. | static bool isBuy = false; no flag needed.bool wasBuy = isBuy; isBuy = Bid > X; if(isBuy && !wasBuy) // new signal |
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
Hello,
I just started learning MQL language and I have a question, right now I have build a EA which is checking if all my different conditions to take a trade are met. When this happens then the order should be executed once.
Right now if all conditions are met it openens a trade at that moment, but on every candle after this (where conditions are still met) too, how can I limit it to only take a trade once?
Can I somehow set a flag so it will be checked if an order was already executed once, and once the conditions change and are not met anymore it gets reset, till the next time all conditions are met?
Best regards,
salexes