Can anyone help me change the code below to move a SL to zero + or - a set number of pips? The Set Zero SL script by elihayun works great to move stop loss to break even but I would like it to move my stoploss to break even plus 10, 20 or whatever pips. Can anyone help with this?
//+------------------------------------------------------------------+
//| Set Zero SL.mq4 |
//| Copyright © 2006, Eli Hayun |
//|
xing yu zhang yiming yuan at elihayun.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli Hayun"
#property link "http://www.elihayun.com"
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
string curr = Symbol();
int ot = OrdersTotal();
int ords[200], ordType[200], ordTicket[200]; double ordLots[200];
string ordComments[200];
int ix=0;
for (int i=0; i<ot; i++)
{
int o = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol())
if ((OrderType() == OP_BUY) || (OrderType() == OP_SELL))
{
double sl = 0;
if ((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice()))
sl = OrderOpenPrice() ;
if ((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))
sl = OrderOpenPrice() ;
if (sl != 0)
OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0);
}
}
//----
return(0);
}
Thanks for any help you can give, Tom.