Delay Buy Trade Till Next Candle Or Seconds Before Current Candle Ends
- Execute Trade only at the open on next New Candle- Need help
- How to start with MQL5
- [ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5.
Instead of (1) checking for opening conditions and (2) wait till the next bar to (3) take action, what about (1) wait till next bar then (2) check conditions and (3) take action if necessary?
And the checks for a new bar is essentially the same between MQL4 and MQL5. Whereas MQL4 may be using Time[], they can both use iTime(), or time[] in some indicators.
Instead of (1) checking for opening conditions and (2) wait till the next bar to (3) take action, what about (1) wait till next bar then (2) check conditions and (3) take action if necessary?
And the checks for a new bar is essentially the same between MQL4 and MQL5. Whereas MQL4 may be using Time[], they can both use iTime(), or time[] in some indicators.
I trade binary so whenever the signal comes it's still usually in the wrong trend hence the unnecessary drawdown and since it's in a way triggered early (80% of the time) I miss a lot of pips, but is usually in the direction I predicted by the next candle.
You can use CopyRates. Time does not exist in MQL5.
Been trying different codes for the past 5 days can't seem to get it done... I want the buy to be triggered on the next bar after the one we got the signal from.
Try this (B equals the number of bars you want your Buy to be delayed from the signal): [rough idea based on your code... not compiled/tested]
input int B = 1; // Global datetime SignaledTime = 0; // Global, or static : if (ask <= Highoo && ask >= low_value && ask<= 10500 ) { if(rat_value[0] >= current_stoch_low_value && rat_value[0] <= current_stoch_high_value && rat_value[1] >= prev_stoch_low_value && rat_value[1] <= prev_stoch_high_value && rsi_value[0] >= rsi_low_value && rsi_value[0] <= rsi_high_value && rsi_value[1] > rsi_value [0] ) SignaledTime = TimeCurrent(); } : if(IsNewCandle() && SignaledTime!=0 && iBarShift(_Symbol,_Period,SignalTime)<B && Allowed_position() < allowedposition) { if(trade.Buy(NormalizeDouble(lot_size, 2),NULL,ask,0,0,NULL)) { ulong ticket = trade.ResultOrder(); tradenow=0; set_tp(ticket); } }
Try this (B equals the number of bars you want your Buy to be delayed from the signal): [rough idea based on your code... not compiled/tested]
Try this (B equals the number of bars you want your Buy to be delayed from the signal): [rough idea based on your code... not compiled/tested]
Couldn't get it to work... The code didn't run, that is the file for the EA, please help me look at it for the full picture. I want it to check the current bar till the the parameters or conditions are met and once it is it it normally opens a buy but instead I want it to hold that request then trigger the buy on the new candle open or when the current candle ends (still the same thing)
Post the changes based on my earlier suggestion, and tell us what didn't work.
Otherwise, you're just wasting our time.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use