/* Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] Website: http://purebeam.biz E-mail : purebeam@gmail.com */ #property copyright "Copyright @ Rita Lasker" #property link "http://www.ritalasker.com" extern bool ProfitTrailing = TRUE; extern double TrailingStop = 15.0; extern double TrailingStep = 2.0; extern int MagicNumber = -1; double gd_100; int init() { gd_100 = Point; if (Digits == 5 || Digits == 3) gd_100 = 10.0 * gd_100; return (0); } void start() { if (TrailingStop > 0.0 && OrdersTotal() > 0) RealTrailOrder(); } void RealTrailOrder() { double l_ord_open_price_20; double l_ord_stoploss_28; double l_price_36; double ld_0 = MarketInfo(Symbol(), MODE_STOPLEVEL) * Point / gd_100; double ld_8 = MathMax(TrailingStop, ld_0); for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES) == TRUE) { if (OrderMagicNumber() == MagicNumber || MagicNumber < 0 && OrderSymbol() == Symbol()) { l_ord_open_price_20 = OrderOpenPrice(); l_ord_stoploss_28 = OrderStopLoss(); while (IsTradeContextBusy()) Sleep(500); RefreshRates(); if (OrderType() == OP_BUY) { l_price_36 = ND(Bid - ld_8 * gd_100); if (Bid > l_ord_open_price_20 + ld_8 * gd_100 || !ProfitTrailing && l_price_36 >= l_ord_stoploss_28 + TrailingStep * gd_100 && ld_8 * gd_100 > ld_0 * gd_100) { if (!OrderModify(OrderTicket(), OrderOpenPrice(), l_price_36, OrderTakeProfit(), 0, Blue)) if (!IsOptimization()) Print("BUY OrderModify Error " + GetLastError()); } } if (OrderType() == OP_SELL) { l_price_36 = ND(Ask + ld_8 * gd_100); if (Ask < l_ord_open_price_20 - ld_8 * gd_100 || !ProfitTrailing && l_price_36 <= l_ord_stoploss_28 - TrailingStep * gd_100 || l_ord_stoploss_28 == 0.0 && ld_8 * gd_100 > ld_0 * gd_100) { if (!OrderModify(OrderTicket(), OrderOpenPrice(), l_price_36, OrderTakeProfit(), 0, Red)) if (!IsOptimization()) Print("Sell OrderModify Error " + GetLastError()); } } } } } } double ND(double ad_0) { return (NormalizeDouble(ad_0, Digits)); }