Drag and drop SL and TP in the tester. - page 14

 
I still decided to add SL and TP dragging to the 3rd variant. I.e. after the algorithm 3 options set SL and TP, we can drag them where necessary. This is in my opinion the best (universal) option. In the void OnTick() there should be a line: if(PriceModify<Point()) {OnSL=0;OnTP=0;}
void ModifySlTp2(double priceModify=0)
 {
  double sl=0,tp=0;
  
  for(int i=0; i<OrdersTotal(); i++) 
     { 
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
        { 
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) 
           {
            if(MathAbs(OrderOpenPrice()-priceModify)<10*Point())  {OnOrd=true;}    
            if(MathAbs(OrderStopLoss()-priceModify)<10*Point())   {OnSL=true;}
            if(MathAbs(OrderTakeProfit()-priceModify)<10*Point()) {OnTP=true;}
            if(OnOrd || OnSL || OnTP) {TicketModifyOrder=OrderTicket();}
            if(OnOrd) {OnOrd=false; return;}
           }
        }  
     }  
   if(TicketModifyOrder>0)
     {
      if(OrderSelect(TicketModifyOrder, SELECT_BY_TICKET))
        {
         bool typOrdBuy = OrderType()==OP_BUY  || OrderType()==OP_BUYSTOP  || OrderType()==OP_BUYLIMIT;
         bool typOrdSell= OrderType()==OP_SELL || OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT;
         if(!OnOrd && !OnSL && !OnTP)
           {
            if(typOrdBuy)
              {
               sl = NormalizeDouble(priceModify,Digits);
               tp = NormalizeDouble(OrderOpenPrice()+Ktp*(OrderOpenPrice()-sl),Digits);
              }
            if(typOrdSell)
              {
               sl = NormalizeDouble(priceModify,Digits);
               tp = NormalizeDouble(OrderOpenPrice()-Ktp*(sl-OrderOpenPrice()),Digits);
              }
            }    
            if(OnSL) {sl=NormalizeDouble(priceModify,Digits);tp=OrderTakeProfit();}
            if(OnTP) {tp=NormalizeDouble(priceModify,Digits);sl=OrderStopLoss();}
                                                             
            ModifyOrder1(-1, sl, tp, 0); 
            if(OnSL || OnTP) {TicketModifyOrder=0;} 
        }           
     }  
 }
 

I tested one strategy in the tester today. Practice has shown that it is more convenient to drag sl and tp if you make an adjustment to the 2 constants.

Here it is:

...

if(MathAbs(OrderOpenPrice()-priceModify)<10*Point())  {OnOrd=true;}    
if(MathAbs(OrderStopLoss()-priceModify)<30*Point())   {OnSL=true;}
if(MathAbs(OrderTakeProfit()-priceModify)<30*Point()) {OnTP=true;}
if(OnOrd || OnSL || OnTP) {TicketModifyOrder=OrderTicket();}
if(OnOrd) {OnOrd=false; return;}

...



 
Thank you for your help. That's helpful. Was looking for how to open orders in the tester. It is done through global variables. But it is inconvenient that the indicator has to be placed on a chart.
Reason: