#property copyright "PiptronicX" #property link "http://www.piptronic.com" extern string Expert_Name = "PiptronicX"; extern double Broker_type = 1.0; extern double Lot_type = 10.0; extern double GMT = 1.0; extern double MaxLots = 5.0; extern double Risk_Percentage = 15.0; extern double TakeProfit = 10.0; extern double StopLoss = 40.0; extern double TrailingTP = 3.0; extern double AdvancedClose = 5.0; double gd_156 = 1.0; extern double MaxSpread = 4.0; extern double MaxOpenOrders = 3.0; double gd_180 = 0.0; extern double Candles = 3.0; extern int MagicNumber = 200423; int init() { return (0); } int deinit() { return (0); } int start() { double ld_108; double ld_116; int li_148; double ld_156; double ld_164; double ld_172; int li_180; int li_188; int li_192; double ld_196; double ld_204; int li_220; int li_224; Comment("Copyright PiptronicX from Piptronic.com"); int li_0 = 123456; double ld_4 = iOpen(15, 0, 2); double ld_12 = iClose(15, 0, 2); double ld_20 = iOpen(15, 0, 1); double ld_28 = iClose(15, 0, 1); double ld_124 = 10.0 * Lot_type; double ld_132 = 100 / Lot_type; double ld_76 = MathFloor(0.007 * (AccountFreeMargin() / ld_124 * Ask) * Risk_Percentage) / ld_132; double ld_84 = MathMax(ld_76, Lot_type / 100.0); double ld_92 = MathMin(ld_84, MaxLots); int li_140 = MarketInfo(Symbol(), MODE_STOPLEVEL) / Broker_type; int li_144 = MarketInfo(Symbol(), MODE_SPREAD) / Broker_type; double ld_36 = Low[iLowest(NULL, PERIOD_M15, MODE_LOW, Candles, 1)] + gd_180 * Point * Broker_type; if (TakeProfit <= li_140) ld_108 = li_140; else ld_108 = TakeProfit; if (StopLoss <= li_140) ld_116 = li_140 + li_144; else ld_116 = StopLoss; if (OrdersTotal() < MaxOpenOrders && AccountFreeMargin() > 20.0 * Lot_type) { if (Ask <= ld_36) { if (Ask - Bid <= MaxSpread * Point * Broker_type) { if (DayOfWeek() == 5 && Hour() == GMT + 20.0 || Hour() == GMT + 21.0 || Hour() == GMT + 19.0) li_148 = OrderSend(Symbol(), OP_BUY, Lot_type / 100.0, Ask, gd_156, Ask - Point * ld_116 * Broker_type, ld_36 + Point * ld_108 * Broker_type, "PiptronicX", MagicNumber, 0, Red); else { if (Hour() == GMT + 19.0 || Hour() == GMT + 20.0 || Hour() == GMT + 21.0 || Hour() == GMT + 22.0 || Hour() == GMT + 23.0 || Hour() == GMT + 0.0 || Hour() == GMT + 1.0 || Hour() == GMT + 2.0 || Hour() == GMT + 3.0 || Hour() == GMT + 4.0 || Hour() == GMT + 5.0) li_148 = OrderSend(Symbol(), OP_BUY, ld_92, Ask, gd_156, Ask - Point * ld_116 * Broker_type, ld_36 + Point * ld_108 * Broker_type, "PiptronicX", MagicNumber, 0, Red); } } } } if (Broker_type == 10.0) ld_172 = 5; else ld_172 = 4; int li_152 = OrdersTotal(); if (li_152 > 0) { li_180 = OrdersTotal(); for (int li_184 = 0; li_184 < li_180; li_184++) { OrderSelect(li_184, SELECT_BY_POS); if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { li_188 = OrderType(); if (li_188 == OP_BUY) { ld_156 = NormalizeDouble(Ask + li_140 * Point * Broker_type, ld_172); if (ld_156 < OrderTakeProfit() && ld_156 >= OrderOpenPrice() + TrailingTP * Point * Broker_type && ld_156 >= Ask + li_140 * Point * Broker_type) ld_164 = OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), ld_156, 0, CLR_NONE); } } } } if (OrderSelect(0, SELECT_BY_POS, MODE_TRADES)) ld_204 = OrderOpenPrice(); double ld_212 = NormalizeDouble(ld_204 + AdvancedClose * Point * Broker_type, ld_172); if (ld_212 < Bid && TakeProfit != AdvancedClose || AdvancedClose != TrailingTP && OrderMagicNumber() == MagicNumber) { for (int li_228 = OrdersTotal() - 1; li_228 >= 0; li_228--) { if (OrderSelect(0, SELECT_BY_POS, MODE_TRADES)) { li_220 = OrderType(); if (!(li_220 == OP_BUY || li_220 == OP_SELL)) continue; while (true) { if (li_220 == OP_BUY && OrderMagicNumber() == MagicNumber) ld_196 = MarketInfo(OrderSymbol(), MODE_BID); else ld_196 = MarketInfo(OrderSymbol(), MODE_ASK); li_192 = OrderClose(OrderTicket(), OrderLots(), ld_196, gd_156, CLR_NONE); if (li_192 != 1) { li_224 = GetLastError(); Print("LastError = ", li_224); } else li_224 = 0; if (li_224 != 135/* PRICE_CHANGED */) break; RefreshRates(); } } Print("Error when order select ", GetLastError()); } } return (0); }