#property copyright " Indrafxs_King`s USDJPY" #property link "http://mediacakrawala.com" extern double Lots = 0.1; int gi_84 = 28; int gi_88 = 0; bool gi_92 = FALSE; int gi_96 = 28; int gi_100 = 31; int gi_104 = 28; int gi_108 = 31; int gi_112 = 28; int gi_116 = 31; int gi_120 = 28; int gi_124 = 31; int gi_128 = 28; int gi_132 = 31; int gi_136 = 28; int gi_140 = 31; int gi_144 = 28; int gi_148 = 31; int gi_152 = 28; int gi_156 = 31; int gi_160 = 28; int gi_164 = 31; int gi_168 = 28; int gi_172 = 31; int g_slippage_176 = 3; int gi_180 = 2; int gi_184 = 0; int gi_188 = 24; int g_magic_192 = 258; bool gi_196 = FALSE; bool gi_200 = FALSE; int gi_204 = 1; bool gi_208 = FALSE; int gi_212 = 1; int gi_216 = 946692000; int gi_220 = 1539568800; string gs_224 = ""; int gi_232 = 181462; int start() { int li_0; int li_4; int l_ticket_8; double l_price_12; double l_price_20; double l_price_28; double l_lots_36; double l_pips_44; double l_pips_52; bool l_bool_60; if (gi_232 != AccountNumber()) { Comment("Trade on account :" + AccountNumber() + " FORBIDDEN!"); return (0); } Comment(""); datetime lt_64 = D'28.09.2009 11:30'; if (TimeCurrent() > lt_64) { Alert("Indrafxs_King`s Expired ! "); return (0); } if (gi_196 == TRUE) { for (int l_ord_total_68 = OrdersTotal(); l_ord_total_68 >= 0; l_ord_total_68--) { OrderSelect(l_ord_total_68, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() || gi_204 == 3 && OrderMagicNumber() == g_magic_192) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 5, CLR_NONE); if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket()); } } return (0); } int l_ticket_72 = 0; int l_ticket_76 = 0; int l_ticket_80 = 0; int l_ticket_84 = 0; int li_unused_88 = 0; int li_unused_92 = 0; double l_ord_lots_96 = 0; double l_ord_lots_104 = 0; double l_ord_open_price_112 = 0; double l_ord_open_price_120 = 0; double l_ord_takeprofit_128 = 0; double l_ord_takeprofit_136 = 0; double ld_unused_144 = 0; double ld_unused_152 = 0; double l_ord_lots_160 = 0; double l_ord_lots_168 = 0; double ld_176 = 0; double ld_184 = 0; double l_ord_lots_192 = 0; double l_ord_lots_200 = 0; string ls_208 = ""; string ls_216 = ""; string ls_224 = ""; string ls_232 = ""; string ls_240 = ""; string ls_248 = ""; string ls_256 = ""; string ls_264 = ""; string ls_272 = ""; if (gi_208 == TRUE) li_4 = 100; else li_4 = 1; if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) > iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) li_0 = 2; if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) < iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) li_0 = 1; for (int l_pos_280 = 0; l_pos_280 < OrdersTotal(); l_pos_280++) { OrderSelect(l_pos_280, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() || gi_204 == 3 && OrderMagicNumber() == g_magic_192) { if (OrderType() == OP_BUY && l_ticket_72 < OrderTicket()) { l_ord_lots_96 = OrderLots(); l_ord_open_price_112 = OrderOpenPrice(); l_ticket_72 = OrderTicket(); l_ord_takeprofit_136 = OrderTakeProfit(); } if (OrderType() == OP_BUY) { if (OrderLots() < l_ord_lots_192 || l_ord_lots_192 == 0.0) { l_ord_lots_192 = OrderLots(); ld_176 = OrderOpenPrice() - gi_88 * Point; } } if (OrderType() == OP_SELL && l_ticket_76 < OrderTicket()) { l_ord_lots_104 = OrderLots(); l_ord_open_price_120 = OrderOpenPrice(); l_ticket_76 = OrderTicket(); l_ord_takeprofit_128 = OrderTakeProfit(); } if (OrderType() == OP_SELL) { if (OrderLots() < l_ord_lots_200 || l_ord_lots_200 == 0.0) { l_ord_lots_200 = OrderLots(); ld_184 = OrderOpenPrice() + gi_88 * Point; } } if (OrderType() == OP_BUYLIMIT) { l_ticket_80 = OrderTicket(); l_ord_lots_160 = OrderLots(); } if (OrderType() == OP_SELLLIMIT) { l_ticket_84 = OrderTicket(); l_ord_lots_168 = OrderLots(); } } } if (l_ticket_72 == 0 && l_ticket_80 != 0) OrderDelete(l_ticket_80); if (l_ticket_72 == 0 && l_ticket_80 == 0) { if (TimeCurrent() >= gi_216 && TimeCurrent() <= gi_220) { l_price_20 = Ask - gi_88 * Point; if (gi_88 <= 0) l_price_20 = 0; l_price_28 = Ask + gi_84 * Point; if ((gi_184 < gi_188 && TimeHour(TimeCurrent()) >= gi_184 && TimeHour(TimeCurrent()) < gi_188) || (gi_184 > gi_188 && TimeHour(TimeCurrent()) >= gi_184 || TimeHour(TimeCurrent()) < gi_188)) { if (DayOfWeek() != 5 || Hour() < gi_212) { if ((li_0 == 2 && l_ticket_76 == 0) || gi_200 == FALSE) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, Lots * li_4) >= 0.0) { if (gi_204 != 2 && gi_204 != 3) OrderSend(Symbol(), OP_BUY, Lots, Ask, g_slippage_176, l_price_20, l_price_28, "Indrafxs" + g_magic_192, g_magic_192, 0, CLR_NONE); else { l_ticket_8 = OrderSend(Symbol(), OP_BUY, Lots, Ask, g_slippage_176, 0, 0, "Indrafxs" + g_magic_192, g_magic_192, 0, CLR_NONE); l_bool_60 = OrderModify(l_ticket_8, OrderOpenPrice(), l_price_20, l_price_28, 0, CLR_NONE); if (l_bool_60 == FALSE) Print("Error modifying BUY order : ", GetLastError()); } } else { if (AccountFreeMarginCheck(Symbol(), OP_BUY, Lots) >= 0.0) ls_272 = "we recommend you to decrease your start lot or increase deposit"; else ls_224 = "BUY, " + DoubleToStr(Lots, 2) + " lots. "; } } } } } else ls_216 = gs_224; } if (l_ticket_76 == 0 && l_ticket_84 != 0) OrderDelete(l_ticket_84); if (l_ticket_76 == 0 && l_ticket_84 == 0) { if (TimeCurrent() >= gi_216 && TimeCurrent() <= gi_220) { l_price_20 = Bid + gi_88 * Point; if (gi_88 <= 0) l_price_20 = 0; l_price_28 = Bid - gi_84 * Point; if ((gi_184 < gi_188 && TimeHour(TimeCurrent()) >= gi_184 && TimeHour(TimeCurrent()) < gi_188) || (gi_184 > gi_188 && TimeHour(TimeCurrent()) >= gi_184 || TimeHour(TimeCurrent()) < gi_188)) { if (DayOfWeek() != 5 || Hour() < gi_212) { if ((li_0 == 1 && l_ticket_72 == 0) || gi_200 == FALSE) { if (AccountFreeMarginCheck(Symbol(), OP_SELL, Lots * li_4) >= 0.0) { if (gi_204 != 2 && gi_204 != 3) OrderSend(Symbol(), OP_SELL, Lots, Bid, g_slippage_176, l_price_20, l_price_28, "Indrafxs" + g_magic_192, g_magic_192, 0, CLR_NONE); else { l_ticket_8 = OrderSend(Symbol(), OP_SELL, Lots, Bid, g_slippage_176, 0, 0, "Indrafxs" + g_magic_192, g_magic_192, 0, CLR_NONE); l_bool_60 = OrderModify(l_ticket_8, OrderOpenPrice(), l_price_20, l_price_28, 0, CLR_NONE); if (l_bool_60 == FALSE) Print("Error modifying SELL order : ", GetLastError()); } } else { if (AccountFreeMarginCheck(Symbol(), OP_SELL, Lots) >= 0.0) ls_272 = "we recommend you to decrease your start lot or increase deposit"; else ls_232 = "SELL, " + DoubleToStr(Lots, 2) + " lots. "; } } } } } else ls_216 = gs_224; } if (l_ticket_72 != 0 && l_ticket_80 != 0) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, l_ord_lots_160) < 0.0) { ls_256 = "BUYLIMIT, " + DoubleToStr(l_ord_lots_160, 2) + " lots. "; OrderDelete(l_ticket_80); } } if (l_ticket_72 != 0 && l_ticket_80 == 0) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, 2.0 * l_ord_lots_96) >= 0.0) { l_pips_52 = FinalStep(NormalizeDouble(l_ord_lots_96 / l_ord_lots_192, 0)); l_pips_44 = FinalTP(NormalizeDouble(l_ord_lots_96 / l_ord_lots_192, 0)); l_price_12 = l_ord_open_price_112 - l_pips_52 * Point; if (gi_92 == FALSE) l_price_20 = l_price_12 - gi_88 * Point; else l_price_20 = ld_176; if (gi_88 <= 0) l_price_20 = 0; l_price_28 = l_price_12 + l_pips_44 * Point; l_lots_36 = NormalizeDouble(2.0 * l_ord_lots_96, gi_180); OrderSend(Symbol(), OP_BUYLIMIT, l_lots_36, l_price_12, g_slippage_176, l_price_20, l_price_28, "Indrafxs" + g_magic_192, g_magic_192, 0, CLR_NONE); } else ls_240 = "BUYLIMIT, " + DoubleToStr(2.0 * l_ord_lots_96, 2) + " lots. "; } if (l_ticket_76 != 0 && l_ticket_84 != 0) { if (AccountFreeMarginCheck(Symbol(), OP_SELL, l_ord_lots_168) < 0.0) { ls_264 = "SELLLIMIT, " + DoubleToStr(l_ord_lots_168, 2) + " lots. "; OrderDelete(l_ticket_84); } } if (l_ticket_76 != 0 && l_ticket_84 == 0) { if (AccountFreeMarginCheck(Symbol(), OP_SELL, 2.0 * l_ord_lots_104) >= 0.0) { l_pips_52 = FinalStep(NormalizeDouble(l_ord_lots_104 / l_ord_lots_200, 0)); l_pips_44 = FinalTP(NormalizeDouble(l_ord_lots_104 / l_ord_lots_200, 0)); l_price_12 = l_ord_open_price_120 + l_pips_52 * Point; if (gi_92 == FALSE) l_price_20 = l_price_12 + gi_88 * Point; else l_price_20 = ld_184; if (gi_88 <= 0) l_price_20 = 0; l_price_28 = l_price_12 - l_pips_44 * Point; l_lots_36 = NormalizeDouble(2.0 * l_ord_lots_104, gi_180); OrderSend(Symbol(), OP_SELLLIMIT, l_lots_36, l_price_12, g_slippage_176, l_price_20, l_price_28, "Indrafxs" + g_magic_192, g_magic_192, 0, CLR_NONE); } else ls_248 = "SELLLIMIT, " + DoubleToStr(2.0 * l_ord_lots_104, 2) + " lots. "; } for (l_pos_280 = 0; l_pos_280 < OrdersTotal(); l_pos_280++) { OrderSelect(l_pos_280, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() || gi_204 == 3 && OrderType() == OP_BUY && l_ticket_72 != 0 && OrderMagicNumber() == g_magic_192) { if (gi_92 == FALSE) l_price_20 = l_ord_open_price_112 - gi_88 * Point; else l_price_20 = ld_176; if (gi_88 <= 0) l_price_20 = 0; if (l_ticket_72 > OrderTicket()) l_price_28 = l_ord_takeprofit_136; else l_price_28 = OrderTakeProfit(); if (l_price_28 != OrderTakeProfit() || l_price_20 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20, l_price_28, 0, CLR_NONE); } if (OrderSymbol() == Symbol() || gi_204 == 3 && OrderType() == OP_SELL && l_ticket_76 != 0 && OrderMagicNumber() == g_magic_192) { if (gi_92 == FALSE) l_price_20 = l_ord_open_price_120 + gi_88 * Point; else l_price_20 = ld_184; if (gi_88 <= 0) l_price_20 = 0; if (l_ticket_76 > OrderTicket()) l_price_28 = l_ord_takeprofit_128; else l_price_28 = OrderTakeProfit(); if (l_price_28 != OrderTakeProfit() || l_price_20 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20, l_price_28, 0, CLR_NONE); } } if (ls_224 != "" || ls_232 != "" || ls_240 != "" || ls_248 != "" || ls_256 != "" || ls_264 != "") ls_208 = "Not enough margin for opening orders: "; Comment(ls_216, "\n", ls_208, ls_224, ls_232, ls_240, ls_248, ls_256, ls_264, "\n", ls_272); return (0); } int FinalStep(double ad_0) { switch (ad_0) { case 1.0: return (gi_96); case 2.0: return (gi_104); case 4.0: return (gi_112); case 8.0: return (gi_120); case 16.0: return (gi_128); case 32.0: return (gi_136); case 64.0: return (gi_144); case 128.0: return (gi_152); case 256.0: return (gi_160); case 512.0: return (gi_168); } return (gi_168); } int FinalTP(double ad_0) { switch (ad_0) { case 1.0: return (gi_100); case 2.0: return (gi_108); case 4.0: return (gi_116); case 8.0: return (gi_124); case 16.0: return (gi_132); case 32.0: return (gi_140); case 64.0: return (gi_148); case 128.0: return (gi_156); case 256.0: return (gi_164); case 512.0: return (gi_172); } return (gi_172); }