samyjo222: Please could someone assist with the code required to ensure that only one buy/sell order is executed per candle?
That has been requested in the forum so many times, that us old-timers are getting a bit tired of it.
Search the Forum. There are many such requests. See the answers.
Search the CodeBase. There are many types of EAs both simple ones and complex ones. Study them. Use them. Adapt them. Learn to code from them.
And lastly, here is some code on how to detect the opening of a new bar/candle:
Detecting the start of a new bar or candle
Fernando Carreiro, 2022.04.24 00:38
Detecting the start of a new bar or candle, in the OnTick() event handler of an expert advisor.
int timeframe = PERIOD_CURRENT; int bars_since_open = iBarShift(_Symbol,timeframe,OrderOpenTime());
OrderOpenTime() // is an inbuilt function in MT4, so for MT5 this can be a custom function to retrieve this information.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi all
Please could someone assist with the code required to ensure that only one buy/sell order is executed per candle?
Many thanks
Sam