//+------------------------------------------------------------------+ //| Lock P.mq4 | //| Snnaper | //| | //+------------------------------------------------------------------+ #property copyright "Snnaper" #property link "" // comment away the below line if you want instant execution with default inputs #property show_inputs #include #include // This is where you set the default values for those input variables. extern bool Fivedigitbroker = TRUE; extern int EA_MAGIC_NUM = 12345; extern double LockInPips = 1.1; extern double TrailingPips = 0.6; int PipFactor = 1; int init() { // Cater for fractional pips if (Digits == 3 || Digits == 5) { PipFactor = 10; } } void CheckStopLossLevels() { double point=0; if(Fivedigitbroker==false)point=Point; if(Fivedigitbroker==true)point=Point*10; double StartTrailLevel = (LockInPips+TrailingPips) * (PipFactor*Point); StartTrailLevel = NormalizeDouble(StartTrailLevel,Digits); double TrailLevel = TrailingPips * (PipFactor*Point); TrailLevel = NormalizeDouble(TrailLevel,Digits); int total = OrdersTotal(); if (total > 0) { for(int cnt=0;cnt TrailLevel && ((Bid-OrderOpenPrice()) >= StartTrailLevel || OrderStopLoss() >= OrderOpenPrice())) { if(OrderStopLoss() < Bid-TrailLevel) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailLevel,OrderTakeProfit(),0,Green); } } } } if (OrderType() == OP_SELL) { if (TrailingPips != 0 && LockInPips != 0) { if((OrderOpenPrice()-Ask) > TrailLevel && ((OrderOpenPrice()-Ask) >= StartTrailLevel || OrderStopLoss() <= OrderOpenPrice())) { if(OrderStopLoss() > Ask+TrailLevel) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailLevel,OrderTakeProfit(),0,Red); } } } } } } } } } int start() { CheckStopLossLevels(); }