Delay Buy Trade Till Next Candle Or Seconds Before Current Candle Ends

 
Incase anyone wants to suggest I go to the freelance section, please note that I already have and I don't think it advisable to pay an extra 30 for a feature I am not yet quite sure if it outcome

I want to initiate trade at the open of the next bar candle after my conditions have been met. Been googling alot and the different solutions are driving me mad.

I need the extra code that I can add to my If condition, meaning once I've gotten my confirmation I want the buy trade to be executed at the next candle open price

Would really really appreciate any help I can get. Thanks

OR

The buy/sell order to be executed at a certain time interval to the end of the candle.

Thanks in advance, there are several code doing this but the ones I saw were in MQL4
 
aodunusi:
Incase anyone wants to suggest I go to the freelance section, please note that I already have and I don't think it advisable to pay an extra 30 for a feature I am not yet quite sure if it outcome

I want to initiate trade at the open of the next bar candle after my conditions have been met. Been googling alot and the different solutions are driving me mad.

I need the extra code that I can add to my If condition, meaning once I've gotten my confirmation I want the buy trade to be executed at the next candle open price

Would really really appreciate any help I can get. Thanks

OR

The buy/sell order to be executed at a certain time interval to the end of the candle.

Thanks in advance, there are several code doing this but the ones I saw were in MQL4

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.

 
Seng Joo Thio:

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.

Should I use Time or CopyRates for it?
 
aodunusi:
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.

Should I use Time or CopyRates for it?

You can use CopyRates. Time does not exist in MQL5.

 
Seng Joo Thio:

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.


if (ask <= Highoo && ask >= low_value && ask<= 10500 )
   {
    if(IsNewCandle()){tradenow=1;}
      if(Allowed_position() < allowedposition && tradenow==1)
       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] )
      
          { if(trade.Buy(NormalizeDouble(lot_size, 2),NULL,ask,0,0,NULL))
             {
              ulong ticket = trade.ResultOrder();
              tradenow=0;
              set_tp(ticket);
             }
          
         }
 
aodunusi:
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);
      }
   }
 
Seng Joo Thio:

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]

Would try it out. Thanks alot
 
Seng Joo Thio:

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)
 
aodunusi:
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.

Reason: