Download MetaTrader 5
To add comments, please log in or register
Articles can help you to solidify your knowledge. Come and read them!
Nurudeen Amedu
36428
Nurudeen Amedu 2016.06.24 22:56 

How do I check the first trade opened during the current bar (or after close of previous bar) and save the open price of that trade

I tried this to catch buy trade price but its not working

 

double OpenBuyTrade(){
//      if(OpenOrdersThisPair(Symbol())>=1){
//      int slip = slippage*pips;
      int lastOpenTime = 0, needleTicket = 0;
      last_buynowprice;
   
      for(int i = (OrdersTotal()-1); i >= 0; i --)
         {
         OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      
         int curOpenTime = OrderOpenTime();
         int lastNeedle = OrderTicket();
      
         if((lastNeedle > needleTicket) && (OrderType()==OP_BUY) && (curOpenTime > iTime(Symbol(),0,1)))
         {
            lastOpenTime = curOpenTime;
            needleTicket = lastNeedle;
            last_buynowprice = OrderOpenPrice();
            //order_buylots = OrderLots();
         }else{
            last_buynowprice=0;
         }
      }
      

//   }
   return (last_buynowprice);
}
/
To add comments, please log in or register