#property copyright "Copyright © 2009, FXPROMaker Trading Solutions, http://www.fxpromaker.com" #property link "http://www.fxpromaker.com" #import "fdd.dll" void Determine(int a0, int a1, double a2, double a3, double a4, double& a5[], double& a6[], int a7, int a8, double a9, int& a10[], int& a11[], int& a12[], int& a13[], int& a14[], int& a15[], int& a16[], int& a17[], double& a18[], double& a19[], double& a20[], double& a21[], double& a22[], double& a23[], double& a24[], double& a25[], double& a26[], double& a27[], int a28, int a29, int a30, int a31); void Finish(int a0, int a1, int a2, int a3, int a4, double a5, double a6, double a7, int& a8[], int& a9[], int& a10[], int& a11[], double& a12[], double& a13[], double& a14[], double& a15[], double& a16[], double& a17[], double& a18[], double& a19[]); #import extern int TakeProfit = 6; extern int StopLoss = 0; extern bool ConstantStop = FALSE; extern double Lots = 0.1; extern double Lot1 = 0.2; extern double Lot2 = 0.4; extern double Lot3 = 0.8; extern double Lot4 = 1.6; extern double Lot5 = 3.2; extern double Lot6 = 6.4; extern double Lot7 = 12.8; extern double Lot8 = 25.6; extern double Lot9 = 51.2; extern double Lot10 = 51.3; extern double Lot11 = 51.4; extern double Lot12 = 51.5; extern double Lot13 = 51.6; extern double Lot14 = 51.7; extern double Lot15 = 51.8; extern double Lot16 = 51.9; extern double Lot17 = 52.0; extern double Lot18 = 52.1; extern double Lot19 = 52.2; extern double Lot20 = 52.3; extern double Lot21 = 52.4; extern double Lot22 = 52.5; extern double Lot23 = 52.6; extern double Lot24 = 52.7; extern double Lot25 = 52.8; extern int Step1 = 6; extern int TP1 = 6; extern int Step2 = 10; extern int TP2 = 10; extern int Step3 = 10; extern int TP3 = 10; extern int Step4 = 20; extern int TP4 = 20; extern int Step5 = 40; extern int TP5 = 40; extern int Step6 = 60; extern int TP6 = 60; extern int Step7 = 90; extern int TP7 = 90; extern int Step8 = 100; extern int TP8 = 100; extern int Step9 = 120; extern int TP9 = 120; extern int Step10 = 120; extern int TP10 = 120; extern int Step11 = 130; extern int TP11 = 130; extern int Step12 = 120; extern int TP12 = 160; extern int Step13 = 120; extern int TP13 = 160; extern int Step14 = 120; extern int TP14 = 180; extern int Step15 = 120; extern int TP15 = 200; extern int Step16 = 120; extern int TP16 = 200; extern int Step17 = 120; extern int TP17 = 200; extern int Step18 = 120; extern int TP18 = 220; extern int Step19 = 120; extern int TP19 = 220; extern int Step20 = 120; extern int TP20 = 220; extern int Step21 = 120; extern int TP21 = 220; extern int Step22 = 120; extern int TP22 = 220; extern int Step23 = 120; extern int TP23 = 220; extern int Step24 = 120; extern int TP24 = 220; extern int Step25 = 120; extern int TP25 = 220; extern int Slippage = 3; int gi_500 = 2; extern int StartHour = 0; extern int EndHour = 24; extern int Magic = 9994; extern bool CloseAllNow = FALSE; extern bool UseMACD = FALSE; extern int BrokerMode = 1; extern int FridayCloseTime = 24; int gi_532 = D'10.01.2010 03:30'; int gi_536 = D'31.01.2010 03:30'; string gs_540 = "This version is expired. Visit www.fxpromaker.com"; string gs_548 = "Invalid Account. Visit www.fxpromaker.com"; string gs_556 = "Set \"Allow DLL Imports\""; int init() { if (!IsDemo() && !IsTesting()) { Alert(gs_548); return (-1); } if (!IsDllsAllowed()) { Alert(gs_556); return (0); } Comment(" "); return (1); } int start() { int li_92; int l_ticket_100; int li_104; double l_price_108; double l_price_116; double l_price_124; double l_lots_132; double l_pips_148; double l_pips_156; bool l_bool_276; if (!IsDemo() && !IsTesting()) { Comment(gs_548); return (-1); } if (!IsDllsAllowed()) { Comment(gs_556); return (-1); } if (CloseAllNow == TRUE) { for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); if (StringSubstr(OrderSymbol(), 0, 6) == StringSubstr(Symbol(), 0, 6) || BrokerMode == 3 && OrderMagicNumber() == Magic) { 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 lia_4[] = {0}; int lia_8[] = {0}; int lia_12[] = {0}; int lia_16[] = {0}; int lia_20[] = {0}; int lia_24[] = {0}; double lda_28[] = {0}; double lda_32[] = {0}; double lda_36[] = {0}; double lda_40[] = {0}; double lda_44[] = {0}; double lda_48[] = {0}; double lda_52[] = {0}; double lda_56[] = {0}; double lda_60[] = {0}; double lda_64[] = {0}; double lda_68[] = {0}; double lda_72[] = {0}; double lda_76[] = {0}; double lda_80[] = {0}; int lia_84[] = {0}; int lia_88[] = {0}; string ls_188 = ""; string ls_196 = ""; string ls_204 = ""; string ls_212 = ""; string ls_220 = ""; string ls_228 = ""; string ls_236 = ""; string ls_244 = ""; string ls_252 = ""; string ls_260 = ""; string ls_268 = ""; bool li_96 = TRUE; int l_timeframe_280 = Period(); int l_datetime_284 = iTime(NULL, l_timeframe_280, 0); int l_shift_288 = iBarShift(NULL, 0, l_datetime_284 - 60 * l_timeframe_280, FALSE); if (iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, l_shift_288) > iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, l_shift_288)) li_92 = 2; else li_92 = 1; for (int l_pos_292 = 0; l_pos_292 < OrdersTotal(); l_pos_292++) { OrderSelect(l_pos_292, SELECT_BY_POS, MODE_TRADES); if (StringSubstr(OrderSymbol(), 0, 6) == StringSubstr(Symbol(), 0, 6) || BrokerMode == 3 && OrderMagicNumber() == Magic) Determine(OrderType(), StopLoss, OrderLots(), OrderOpenPrice(), Point, lda_28, lda_32, NormalizeDouble(StrToDouble(OrderComment()), 0), OrderTicket(), OrderTakeProfit(), lia_84, lia_88, lia_4, lia_8, lia_20, lia_24, lia_12, lia_16, lda_36, lda_40, lda_72, lda_68, lda_80, lda_76, lda_52, lda_56, lda_60, lda_64, l_timeframe_280, l_datetime_284, l_shift_288, li_92); } if (lia_4[li_104] == 0 && lia_12[li_104] != 0) OrderDelete(lia_12[li_104]); if (lia_4[li_104] == 0 && lia_12[li_104] == 0) { if (TimeCurrent() >= gi_532 && TimeCurrent() <= gi_536) { l_price_116 = NormalizeDouble(Ask - StopLoss * Point, Digits); if (StopLoss <= 0) l_price_116 = 0; l_price_124 = NormalizeDouble(Ask + TakeProfit * Point, Digits); if ((StartHour < EndHour && TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) || (StartHour > EndHour && TimeHour(TimeCurrent()) >= StartHour || TimeHour(TimeCurrent()) < EndHour)) { if (DayOfWeek() != 5 || Hour() < FridayCloseTime) { if ((li_92 == 2 && lia_8[li_104] == 0) || UseMACD == FALSE) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, Lots * li_96) >= 0.0) { if (BrokerMode != 2 && BrokerMode != 3) OrderSend(Symbol(), OP_BUY, Lots, NormalizeDouble(Ask, Digits), Slippage, l_price_116, l_price_124, "1", Magic, 0, CLR_NONE); else { l_ticket_100 = OrderSend(Symbol(), OP_BUY, Lots, NormalizeDouble(Ask, Digits), Slippage, 0, 0, "1", Magic, 0, CLR_NONE); if (l_ticket_100 > 0) { l_bool_276 = OrderModify(l_ticket_100, OrderOpenPrice(), l_price_116, l_price_124, 0, CLR_NONE); if (l_bool_276 == FALSE) Print("Error modifying BUY order : ", GetLastError()); } } } else { if (AccountFreeMarginCheck(Symbol(), OP_BUY, Lots) >= 0.0) ls_252 = "we recommend you to decrease your start lot or increase deposit"; else ls_204 = "BUY, " + DoubleToStr(Lots, 2) + " lots. "; } } } } } else ls_196 = gs_540; } if (lia_8[li_104] == 0 && lia_16[li_104] != 0) OrderDelete(lia_16[li_104]); if (lia_8[li_104] == 0 && lia_16[li_104] == 0) { if (TimeCurrent() >= gi_532 && TimeCurrent() <= gi_536) { l_price_116 = NormalizeDouble(Bid + StopLoss * Point, Digits); if (StopLoss <= 0) l_price_116 = 0; l_price_124 = NormalizeDouble(Bid - TakeProfit * Point, Digits); if ((StartHour < EndHour && TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) || (StartHour > EndHour && TimeHour(TimeCurrent()) >= StartHour || TimeHour(TimeCurrent()) < EndHour)) { if (DayOfWeek() != 5 || Hour() < FridayCloseTime) { if ((li_92 == 1 && lia_4[li_104] == 0) || UseMACD == FALSE) { if (AccountFreeMarginCheck(Symbol(), OP_SELL, Lots * li_96) >= 0.0) { if (BrokerMode != 2 && BrokerMode != 3) OrderSend(Symbol(), OP_SELL, Lots, NormalizeDouble(Bid, Digits), Slippage, l_price_116, l_price_124, "1", Magic, 0, CLR_NONE); else { l_ticket_100 = OrderSend(Symbol(), OP_SELL, Lots, NormalizeDouble(Bid, Digits), Slippage, 0, 0, "1", Magic, 0, CLR_NONE); if (l_ticket_100 > 0) { l_bool_276 = OrderModify(l_ticket_100, OrderOpenPrice(), l_price_116, l_price_124, 0, CLR_NONE); if (l_bool_276 == FALSE) Print("Error modifying SELL order : ", GetLastError()); } } } else { if (AccountFreeMarginCheck(Symbol(), OP_SELL, Lots) >= 0.0) ls_252 = "we recommend you to decrease your start lot or increase deposit"; else ls_212 = "SELL, " + DoubleToStr(Lots, 2) + " lots. "; } } } } } else ls_196 = gs_540; } if (lia_4[li_104] != 0 && lia_12[li_104] == 0) { l_pips_156 = FinalStep(lia_84[li_104]); l_pips_148 = FinalTP(lia_84[li_104]); l_price_108 = NormalizeDouble(lda_36[li_104] - l_pips_156 * Point, Digits); if (ConstantStop == FALSE) l_price_116 = NormalizeDouble(l_price_108 - StopLoss * Point, Digits); else l_price_116 = NormalizeDouble(lda_80[li_104], Digits); if (StopLoss <= 0) l_price_116 = 0; l_price_124 = NormalizeDouble(l_price_108 + l_pips_148 * Point, Digits); l_lots_132 = NormalizeDouble(FinalLot(lia_84[li_104]), gi_500); lia_12[li_104] = OrderSend(Symbol(), OP_BUYLIMIT, l_lots_132, l_price_108, Slippage, l_price_116, l_price_124, DoubleToStr(lia_84[li_104] + 1, 0), Magic, 0, CLR_NONE); } if (lia_8[li_104] != 0 && lia_16[li_104] == 0) { l_pips_156 = FinalStep(lia_88[li_104]); l_pips_148 = FinalTP(lia_88[li_104]); l_price_108 = NormalizeDouble(lda_40[li_104] + l_pips_156 * Point, Digits); if (ConstantStop == FALSE) l_price_116 = NormalizeDouble(l_price_108 + StopLoss * Point, Digits); else l_price_116 = NormalizeDouble(lda_76[li_104], Digits); if (StopLoss <= 0) l_price_116 = 0; l_price_124 = NormalizeDouble(l_price_108 - l_pips_148 * Point, Digits); l_lots_132 = NormalizeDouble(FinalLot(lia_88[li_104]), gi_500); lia_16[li_104] = OrderSend(Symbol(), OP_SELLLIMIT, l_lots_132, l_price_108, Slippage, l_price_116, l_price_124, DoubleToStr(lia_88[li_104] + 1, 0), Magic, 0, CLR_NONE); } for (l_pos_292 = 0; l_pos_292 < OrdersTotal(); l_pos_292++) { OrderSelect(l_pos_292, SELECT_BY_POS, MODE_TRADES); if (StringSubstr(OrderSymbol(), 0, 6) == StringSubstr(Symbol(), 0, 6) || BrokerMode == 3 && OrderMagicNumber() == Magic && (OrderType() == OP_BUY && lia_4[li_104] != 0) || (OrderType() == OP_SELL && lia_8[li_104] != 0)) { Finish(OrdersTotal(), OrderType(), ConstantStop, StopLoss, NormalizeDouble(StrToDouble(OrderComment()), 0), OrderLots(), OrderTakeProfit(), Point, lia_4, lia_8, lia_84, lia_88, lda_36, lda_40, lda_44, lda_48, lda_80, lda_72, lda_76, lda_68); if (NormalizeDouble(lda_48[li_104], Digits) != NormalizeDouble(OrderTakeProfit(), Digits) || NormalizeDouble(lda_44[li_104], Digits) != NormalizeDouble(OrderStopLoss(), Digits)) OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(lda_44[li_104], Digits), NormalizeDouble(lda_48[li_104], Digits), 0, CLR_NONE); } } if (ls_204 != "" || ls_212 != "" || ls_220 != "" || ls_228 != "" || ls_236 != "" || ls_244 != "" || ls_260 != "" || ls_268 != "") ls_188 = "Not enough margin for opening orders: "; Comment(ls_196, "\n", ls_188, ls_204, ls_212, ls_220, ls_228, ls_236, ls_244, ls_260, ls_268, "\n", ls_252); return (0); } double FinalLot(double ad_0) { switch (ad_0) { case 1.0: return (Lot1); case 2.0: return (Lot2); case 3.0: return (Lot3); case 4.0: return (Lot4); case 5.0: return (Lot5); case 6.0: return (Lot6); case 7.0: return (Lot7); case 8.0: return (Lot8); case 9.0: return (Lot9); case 10.0: return (Lot10); case 11.0: return (Lot11); case 12.0: return (Lot12); case 13.0: return (Lot13); case 14.0: return (Lot14); case 15.0: return (Lot15); case 16.0: return (Lot16); case 17.0: return (Lot17); case 18.0: return (Lot18); case 19.0: return (Lot19); case 20.0: return (Lot20); case 21.0: return (Lot21); case 22.0: return (Lot22); case 23.0: return (Lot23); case 24.0: return (Lot24); case 25.0: return (Lot25); } return (Lot25); } int FinalStep(double ad_0) { switch (ad_0) { case 1.0: return (Step1); case 2.0: return (Step2); case 3.0: return (Step3); case 4.0: return (Step4); case 5.0: return (Step5); case 6.0: return (Step6); case 7.0: return (Step7); case 8.0: return (Step8); case 9.0: return (Step9); case 10.0: return (Step10); case 11.0: return (Step11); case 12.0: return (Step12); case 13.0: return (Step13); case 14.0: return (Step14); case 15.0: return (Step15); case 16.0: return (Step16); case 17.0: return (Step17); case 18.0: return (Step18); case 19.0: return (Step19); case 20.0: return (Step20); case 21.0: return (Step21); case 22.0: return (Step22); case 23.0: return (Step23); case 24.0: return (Step24); case 25.0: return (Step25); } return (Step25); } int FinalTP(double ad_0) { switch (ad_0) { case 1.0: return (TP1); case 2.0: return (TP2); case 3.0: return (TP3); case 4.0: return (TP4); case 5.0: return (TP5); case 6.0: return (TP6); case 7.0: return (TP7); case 8.0: return (TP8); case 9.0: return (TP9); case 10.0: return (TP10); case 11.0: return (TP11); case 12.0: return (TP12); case 13.0: return (TP13); case 14.0: return (TP14); case 15.0: return (TP15); case 16.0: return (TP16); case 17.0: return (TP17); case 18.0: return (TP18); case 19.0: return (TP19); case 20.0: return (TP20); case 21.0: return (TP21); case 22.0: return (TP22); case 23.0: return (TP23); case 24.0: return (TP24); case 25.0: return (TP25); } return (TP25); }