//+------------------------------------------------------------------+ //| MyTral.mq4 | //| Copyright by Macleod © 2010 | //| | //+------------------------------------------------------------------+ #property copyright "Copyright by Macleod © 2010" #property link "" //---- input parameters extern string g1 = "Уровень TralingStop\'а"; extern int TrailingLevel = 400; extern int TrailingStep = 30; extern string g2 = "Уровень \"Безубытка\""; extern int ZeroLevel = 300; extern string g3 = "MagicNumber (0 - тралим все ордера)"; extern int MagicNumber = 0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- for (int i=0; i ND(Ask + TrailingLevel * Point + TrailingStep * Point)) || (OrderStopLoss() == 0)) { // 2 OrderModify(OrderTicket(),OrderOpenPrice(),ND(Ask + TrailingLevel * Point),OrderTakeProfit(),0,Red); } // 2 } // 1 } int Zero() { if (OrderType() == OP_BUY) { // 1 if (OrderOpenPrice() <= ND(Bid - ZeroLevel * Point) && OrderOpenPrice() > OrderStopLoss()) { // 2 OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green); } // 2 } // 1 BUY if (OrderType() == OP_SELL) { // 1 if (OrderOpenPrice() >= ND(Ask + ZeroLevel * Point) && OrderOpenPrice() < OrderStopLoss()) { // 2 OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red); } // 2 } // 1 SELL } double ND(double d, int n=-1) { if (n<0) return(NormalizeDouble(d, Digits)); return(NormalizeDouble(d, n)); }