#property copyright "Forex Rising 1.2" #property link "http://www.ForexRising.com" extern string Expert_Name = "Forex Rising 1.2"; extern double Hour_Start_Trade = 22.0; extern double Hour_Stop_Trade = 5.0; 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 = 20.0; extern double TakeProfit = 10.0; extern double StopLoss = 45.0; extern double Trailing_TakeProfit = 6.0; extern double Recovery = 2.0; double g_slippage_172 = 1.0; extern double MaxSpread = 6.0; extern double MaxOpenTrades = 3.0; double g_pips_196 = 0.0; extern double Trade_Frequency = 3.0; extern int MagicNumber = 28723; int gi_216 = 55; int init() { return (0); } int deinit() { return (0); } int start() { double ld_108; double ld_116; int l_ticket_148; double l_price_156; double ld_unused_164; double ld_172; int l_ord_total_180; int l_cmd_188; int l_ord_close_192; double l_price_196; double l_ord_open_price_204; int l_cmd_220; int l_error_224; Comment("Copyright ForexRising.com"); int li_unused_0 = 123456; double l_iopen_4 = iOpen(15, 0, 2); double l_iclose_12 = iClose(15, 0, 2); double l_iopen_20 = iOpen(15, 0, 1); double l_iclose_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 l_lots_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, Trade_Frequency, 1)] + g_pips_196 * 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() < MaxOpenTrades && AccountFreeMargin() > 20.0 * Lot_type) { if (Ask <= ld_36) { if (Ask - Bid <= MaxSpread * Point * Broker_type) { if (IsTradeTime() && DayOfWeek() == 5) l_ticket_148 = OrderSend(Symbol(), OP_BUY, Lot_type / 100.0, Ask, g_slippage_172, Ask - Point * ld_116 * Broker_type, ld_36 + Point * ld_108 * Broker_type, "ForexRising", MagicNumber, 0, Red); else if (IsTradeTime()) l_ticket_148 = OrderSend(Symbol(), OP_BUY, l_lots_92, Ask, g_slippage_172, Ask - Point * ld_116 * Broker_type, ld_36 + Point * ld_108 * Broker_type, "ForexRising", MagicNumber, 0, Red); } } } if (Broker_type == 10.0) ld_172 = 5; else ld_172 = 4; int l_ord_total_152 = OrdersTotal(); if (l_ord_total_152 > 0) { l_ord_total_180 = OrdersTotal(); for (int l_pos_184 = 0; l_pos_184 < l_ord_total_180; l_pos_184++) { OrderSelect(l_pos_184, SELECT_BY_POS); if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { l_cmd_188 = OrderType(); if (l_cmd_188 == OP_BUY) { l_price_156 = NormalizeDouble(Ask + li_140 * Point * Broker_type, ld_172); if (l_price_156 < OrderTakeProfit() && l_price_156 >= OrderOpenPrice() + Trailing_TakeProfit * Point * Broker_type && l_price_156 >= Ask + li_140 * Point * Broker_type) ld_unused_164 = OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_price_156, 0, CLR_NONE); } } } } if (OrderSelect(0, SELECT_BY_POS, MODE_TRADES)) l_ord_open_price_204 = OrderOpenPrice(); double ld_212 = NormalizeDouble(l_ord_open_price_204 + Recovery * Point * Broker_type, ld_172); if (ld_212 < Bid && TakeProfit != Recovery || Recovery != Trailing_TakeProfit && OrderMagicNumber() == MagicNumber) { for (int li_228 = OrdersTotal() - 1; li_228 >= 0; li_228--) { if (OrderSelect(0, SELECT_BY_POS, MODE_TRADES)) { l_cmd_220 = OrderType(); if (!(l_cmd_220 == OP_BUY || l_cmd_220 == OP_SELL)) continue; while (true) { if (l_cmd_220 == OP_BUY && OrderMagicNumber() == MagicNumber) l_price_196 = MarketInfo(OrderSymbol(), MODE_BID); else l_price_196 = MarketInfo(OrderSymbol(), MODE_ASK); l_ord_close_192 = OrderClose(OrderTicket(), OrderLots(), l_price_196, g_slippage_172, CLR_NONE); if (l_ord_close_192 != 1) { l_error_224 = GetLastError(); Print("LastError = ", l_error_224); } else l_error_224 = 0; if (l_error_224 != 135/* PRICE_CHANGED */) break; RefreshRates(); } } Print("Error when order select ", GetLastError()); } } return (0); } bool IsTradeTime() { if (Hour_Start_Trade < Hour_Stop_Trade && TimeHour(TimeCurrent()) < Hour_Start_Trade || TimeHour(TimeCurrent()) >= Hour_Stop_Trade) return (FALSE); if (Hour_Start_Trade > Hour_Stop_Trade && (TimeHour(TimeCurrent()) < Hour_Start_Trade && TimeHour(TimeCurrent()) >= Hour_Stop_Trade)) return (FALSE); if (Hour_Stop_Trade == 0.0) Hour_Stop_Trade = 24; if (Hour() == Hour_Stop_Trade - 1.0 && Minute() >= gi_216) return (FALSE); return (TRUE); }