Hi fellow traders.
I am trying to write an Expert and saying under specific circumstances, place an order and take profit or stop loss.
But sometimes it opens and closes under the same candle.
And because in this candle the situations are still valid, it opens a new trade.
How can I say if it already opened an order in this candle, don't open a new one again after closing the previous one?
- only one order in one candle.
- Buy only at a close price
- How to prevent my expert to open new order if other order was already closed on the same candle
- Remember and check the candle open time.
- Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
if (PositionsTotal()-1==0) // we have no open positions.
1、only one order in one candle.: set a global variable to record the time of every candle, open orders only when the value of the vairable changes.
2、Buy only at a close price:buying at a close price would be the same with buying at the next open price, the method mentioned above could solve this as well.
3、How to prevent my expert to open new order if other order was already closed on the same candle:
you need to build a function that returns the close time of the last closed order. then check if TimeCurrent() > last_close_time + periodseconds();

Buy only at a close price
- 2010.01.30
- www.mql5.com
Hi, I want to write an EA which only opens an new order at the close price of the candle. How can I do it...

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