i want to make TP to break even

 

hello there i have this 2 moving average cross over Robot .
first cross is sl and 2 cross over will be trade.

how ever i want when the trade open and market move 100 pip the sl should be modify to break even 
but when i used orderselect outside the if statement it print the value of OrderOpenPrice() to zero which should be the value of open priced of order .


and 2nd after break even i want to trail the sl according the price of moving average 21.

any suggestion ???

double initialSl = 0; // global variables
double initialTp = 0; // global variables

void OnTick() {



   double FastMovingAverage = iMA(_Symbol,PERIOD_H4, 7,0,MODE_EMA,PRICE_CLOSE,0);
   double MidMovingAverage  = iMA(_Symbol,PERIOD_H4,10,0,MODE_EMA,PRICE_CLOSE,0);
   double SlowMovingAverage = iMA(_Symbol,PERIOD_H4,21,0,MODE_EMA,PRICE_CLOSE,0);
   
   double LastFastMovingAverage = iMA(_Symbol,PERIOD_H4, 7,0,MODE_EMA,PRICE_CLOSE,1);
   double LastMidMovingAverage  = iMA(_Symbol,PERIOD_H4,10,0,MODE_EMA,PRICE_CLOSE,1);
   double LastSlowMovingAverage = iMA(_Symbol,PERIOD_H4,21,0,MODE_EMA,PRICE_CLOSE,1);


if((MidMovingAverage>SlowMovingAverage && LastMidMovingAverage<LastSlowMovingAverage) // fast MA upcross
       && OrdersTotal()==0) {
        
      int buyorder = OrderSend(Symbol(),OP_BUY, 0.1 , Ask , 0 , initialSl ,initialTp,NULL,0,0,Green);
      OrderSelect(buyorder,SELECT_BY_TICKET);
      double Openprice_buy = OrderOpenPrice();
      Print("the buy order is " +buyorder);

      // find the mid MA upcross
      double midMA  = MidMovingAverage;
      double fastMA = FastMovingAverage;

      for(int shift=0; shift<10; shift++) {
         double fastMAprev  = iMA(_Symbol,_Period, 7,NULL,MODE_EMA,PRICE_CLOSE,shift+1);
         double midMAprev   = iMA(_Symbol,_Period,10,NULL,MODE_EMA,PRICE_CLOSE,shift+1);

         if(fastMA>midMA && fastMAprev<=midMAprev) {
            // mid MA upcross at shift-th candle
            double  stoploss = iLow(_Symbol,PERIOD_H4,shift+1);
            initialTp = Ask+20;
            OrderModify(buyorder, Openprice_buy, stoploss , initialTp,0);
            break;
         }
       
      }
      
   }
      
      double Break_even_1 = OrderSelect(buyorder, SELECT_BY_TICKET);
      double open_price = OrderOpenPrice();
      double New_sl = MarketInfo(_Symbol,MODE_ASK);
      if(open_price== New_sl){
      initialTp = Ask+20;
      OrderModify(buyorder,OrderOpenPrice(),OrderOpenPrice(), initialTp, 0 );
      
     }
 }