How to select the BUY LIMIT Position or the SELL LIMIT from the date and time of placement

 
For example, I have a BUY LIMIT position,
But when the march has continued and the order is still not executed, I want to change the TP to the highest between the order placement date and the current date
 

Hi

You can simply find this trade and its open time and find the highest price:

for(int i=0;i<OrdersTotal();i++) 
   {
      if(OrderSelect(i,SELECT_BY_POS)) 
      {
         if(OrderMagicNumber()==oMagic  
         {
            if(OrderSymbol()==Symbol()) 
            {
               if(OrderType()==OP_BUYLIMIT){
                  datetime opentime = OrderOpenTime();
                  int openIndex=iBarShift(Symbol(), PERIOD_M1, opentime);
                  double highest= iHigh(Symbol(), PERIOD_M1, iHighest(Symbol(), PERIOD_M1, MODE_HIGH, openIndex+1,0));
                  if(NormalizeDouble(highest-OrderTakeProfit(), _Digits)!=0)
                     bool res = OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), highest, 0);
               }
            }
         }
      }
   }

it would be best to work on M1 period, but if you would not have data available the values might be missing and then you would have to add functions to remember the highest/lowest prices on every tick and use them to update values. But it’s much more complicated, especially if you have multiple trades.

Best Regards


 
Marzena Maria Szmit #: it would be best to work on M1 period, but if you would not have data available

On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
          Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)