One Price SL TP

 

hi, i want EA to calculate first a zero point (a point where sell order's and buy order's      SL value and TP value will be zero) from which it will calculate number of positive pips named as "ZEN".

Below is my program where it takes ZEN as price, and places on all orders in either SL or TP form. "ZEN" //Price you put.
THIS is working program, i just need a little help in making ZEN in pips for all orders close at one price but in pips.

#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
 #property strict
 #property show_inputs

input double ZEN = 0;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
      int total = OrdersTotal();
  for(int b=total-1;b>=0;b--)
  {
     if(OrderSelect(b, SELECT_BY_POS)==false) break;
     if(OrderCloseTime()!=0 || OrderSymbol()!=Symbol()) continue;
     
     if(OrderType()==OP_BUY)
       if(ZEN>0 && ZEN>Ask)
         if(OrderTakeProfit()>=0)
                 {
                 if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),ZEN,0,clrNONE))
                        Print("Take Profit Updated TO New Level ",OrderTicket());
                     
                    }
                  
         if(ZEN>0 && ZEN<Bid)
         if(OrderStopLoss()>=0)
                 {
                 if(!OrderModify(OrderTicket(),OrderOpenPrice(),ZEN,OrderTakeProfit(),0,clrNONE))
                        Print("Stop Loss Updated TO New Level ",OrderTicket());
                     
                    }
                    
      if(OrderType()==OP_SELL)
       if(ZEN>0 && ZEN<Bid)
         if(OrderTakeProfit()>=0)
                 {
                 if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),ZEN,0,clrNONE))
                        Print("Take Profit Updated TO New Level ",OrderTicket());
                     
                    }
                  
         if(ZEN>0 && ZEN>Ask)
         if(OrderStopLoss()>=0)
                 {
                 if(!OrderModify(OrderTicket(),OrderOpenPrice(),ZEN,OrderTakeProfit(),0,clrNONE))
                        Print("Stop Loss Updated TO New Level ",OrderTicket());
                     
                    }
//---
   
  }
//+------------------------------------------------------------------+
 
  }
//+------------------------------------------------------------------+
 
SpaceX: i just need a little help in making ZEN in pips for all orders close at one price but in pips.
  1. TP/SL is a price not a distance. Your sentence makes no sense. If you want Zen to be a distance in PIPs. Compute what a PIP is and add/subtract Zen * PIP from the OrderClosePrice.

  2. PIP, Point, or Tick are all different in general.
              What is a TICK? - MQL4 programming forum 2014.08.03

    Unless you manually adjust your SL/TP for each separate symbol, using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points), and metals. Compute what a PIP is and use it, not points.
              How to manage JPY pairs with parameters? - MQL4 programming forum 2017.02.09
              Slippage defined in index points - Expert Advisors and Automated Trading - MQL5 programming forum 2018.01.15

 
thank you my friend
Reason: