please help me abount ordercloseprice

 

I want to get the value of the candle closed at fixed time(ex:0h0'0'),from there I will calculate the value to order.

ex:candle close at 0h0'0' :1.2222.bar1=1.2222;

so openpriceb=bar1+0.005;openprices=bar1-0.005;if(Ask=openpriceb){ordersend(...)};if( Bid=openprices) ordersend(..);

I can do it with "buystop" and "sellstop",but I want to do it with "buy" and "sell", how to write it correctly?please help me!


 

OrderClosePrice, says the price at which an order was closed at. I don't think it's what you want.

I think you need iBarShift .. it tells which bar OPENS at a specific time.. so iBarShift( NULL, 0, time, true) + 1 might get the bar number.

Or if you really mean, the time is the start of the candle, then use iBarShift( NULL , 0 , time, true)

Once you have the bar number just use Close[] with the correct bar number (... if you are on the same chart).

So maybe play with this

Close[iBarShift( NULL , 0 , time,  true)];
 
wmlfs11: at fixed time(ex:0h0'0') if(Ask=openpriceb){ordersend(...)};if( Bid=openprices) ordersend(..);
  1. iBarShift
    #define HR2400 86400       // 24 * 3600
    int      TimeOfDay(datetime when){  return( when % HR2400          );         }
    datetime DateOfDay(datetime when){  return( when - TimeOfDay(when) );         }
    datetime Today(){                   return(DateOfDay( TimeCurrent() ));       }
    //datetime Tomorrow(){                return(Today() + HR2400);                 }
    //datetime Yesterday(){               return( iTime(NULL, PERIOD_D1, 1) );      }
    :
    datetime when      = Today(); // 0000 server time.
    int      iWhen     = iBarShift(NULL,0, when);
    double   closeWhen = Close[iWhen];
  2. The == operand. - MQL4 forum

 

@alladir

thank you very much. it was okay.

 

@Whroeder

thank you!I just wrote it simple

datetime some_time=StrToTime("0:00");
double bar1=Close[iBarShift(NULL,PERIOD_M1,some_time)];

 
wmlfs11: thank you!I just wrote it simple
And wrong for any chart time frame except except a M1 chart. You specify to get the M1 shift and then use it on the current chart.