extern string SetExp = "<<< Parameters for EUR/USD 15m >>> (default)"; extern string MM = "-- Money Manegiment Parameters --"; extern string Account_Currency = " 0=USD,1=JPY,2=EUR : Your Account currency"; extern int Acnt_Currency = 0; extern bool UseMoneyMgmt = FALSE; extern double Risk_Percent = 1.0; extern string Common = "-- Commons Order Parameters --"; extern double Lots = 0.1; extern int slippage = 3; extern string Buy_Values = "-- Long Parameters --"; extern int MaxPositions_Buy = 6; extern string BalanceFiltter = "This parameter mainly influences BALANCE."; extern double Balance_Fillter_Buy = 52.0; extern string PF_filtter = "This parameter mainly influences PF."; extern double PF_Fillter_Buy = 85.0; extern string Main_filter = "Ggreatly influences, Balance, PF and Total trades."; extern string _Setting = " +30.0〜-30.0 Default is 0"; extern double MF_Buy = 0.0; extern string Order_VALUES = "Priority: Rate(%) to price specification"; extern int TP_Rate_Buy = 35; extern int TP_Pips_Buy = 0; extern int SL_Rate_Buy = 0; extern int SL_Pips_Buy = 128; extern int TrailStop_Buy = 0; extern string Sell_VALUES = "-- Short Parameters --"; extern int MaxPositions_Sell = 6; extern double Balance_Fillter_Sell = 85.0; extern double PF_Fillter_Sell = 31.0; extern double MF_Sell = 0.0; extern int TP_Rate_Sell = 16; extern int TP_Pips_Sell = 0; extern int SL_Rate_Sell = 230; extern int SL_Pips_Sell = 0; extern int TrailStop_Sell = 0; extern string UseMN = "If \'0\', the magic number is automatically given."; extern int UserMagicNum = 0; extern string sound = "ALERT When entry and exit"; extern bool EmailSend = TRUE; extern bool AlertMsg = TRUE; string g_str_concat_316 = "robowalk Rev.6 Magic="; int gi_324 = 10000; bool gi_328 = TRUE; double g_minlot_332 = 0.0; double g_maxlot_340 = 0.0; double g_lotstep_348 = 0.0; double gd_356 = 0.0; double gd_364 = 0.0; int g_leverage_372 = 0; int g_lotsize_376 = 0; int g_bars_380; int gi_384; bool gi_388 = TRUE; bool gi_392 = TRUE; int g_period_396 = 14; int g_period_400 = 5; int g_slowing_404 = 5; int g_period_408 = 14; int g_period_412 = 5; int g_slowing_416 = 5; double gd_420 = 1.0; double gd_428 = 0.0; double gd_436 = 0.0; double gd_444 = 0.0; double gd_452 = 0.0; double gd_460 = 0.0; double gd_468 = 0.0; int init() { Print("This EA works until last of December 2008.(depend in server time)"); if (Digits == 2) gd_420 = 0.01; if (MF_Buy > 30.0) MF_Buy = 30.0; if (MF_Sell > 30.0) MF_Sell = 30.0; if (MF_Sell < -30.0) MF_Sell = -30.0; if (MF_Buy < -30.0) MF_Buy = -30.0; if (Risk_Percent > 10.0) Risk_Percent = 10; gi_384 = MathAbs(UserMagicNum); if (gi_384 == 0) gi_384 = GetMagicNumber(gi_324, 0, 0, 0); else Print("Magic Number is ", gi_384); g_str_concat_316 = StringConcatenate(g_str_concat_316, gi_384); return (0); } int start() { int li_60; if (g_bars_380 == Bars) return (0); g_bars_380 = Bars; Calc_Money_Management(); double ld_0 = Balance_Fillter_Buy; double ld_8 = PF_Fillter_Buy; double ld_16 = Balance_Fillter_Sell; double ld_24 = PF_Fillter_Sell; bool li_32 = FALSE; bool li_36 = FALSE; int l_ord_total_40 = 0; int li_unused_44 = 0; int l_count_48 = 0; int l_count_52 = 0; bool li_112 = FALSE; bool li_116 = FALSE; if (TimeCurrent() > D'31.12.2008 03:30' && IsTesting() == FALSE) { Alert("このEAの使用期限は過ぎました。\n\r未決済のポジションは手動で決済してください\n\rRobowalk Rev.5a is Out of Expiration date. \n\rClose positions by manual."); return (0); } HideTestIndicators(FALSE); double ld_64 = (iStochastic(NULL, 0, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 1) + iStochastic(NULL, 0, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 2) + iStochastic(NULL, 0, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 3)) / 3.0; double ld_72 = (iStochastic(NULL, 0, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 2) + iStochastic(NULL, 0, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 3) + iStochastic(NULL, 0, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 4)) / 3.0; double ld_80 = (iStochastic(NULL, PERIOD_D1, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 1) + iStochastic(NULL, PERIOD_D1, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 2) + iStochastic(NULL, PERIOD_D1, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 3)) / 3.0; double ld_88 = (iStochastic(NULL, PERIOD_D1, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 2) + iStochastic(NULL, PERIOD_D1, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 3) + iStochastic(NULL, PERIOD_D1, g_period_396, g_period_400, g_slowing_404, MODE_SMA, 1, MODE_MAIN, 4)) / 3.0; double ld_96 = (iStochastic(NULL, PERIOD_W1, g_period_408, g_period_412, g_slowing_416, MODE_SMA, 1, MODE_MAIN, 1) + iStochastic(NULL, PERIOD_W1, g_period_408, g_period_412, g_slowing_416, MODE_SMA, 1, MODE_MAIN, 2) + iStochastic(NULL, PERIOD_W1, g_period_408, g_period_412, g_slowing_416, MODE_SMA, 1, MODE_MAIN, 3)) / 3.0; double ld_104 = (iStochastic(NULL, PERIOD_W1, g_period_408, g_period_412, g_slowing_416, MODE_SMA, 1, MODE_MAIN, 2) + iStochastic(NULL, PERIOD_W1, g_period_408, g_period_412, g_slowing_416, MODE_SMA, 1, MODE_MAIN, 3) + iStochastic(NULL, PERIOD_W1, g_period_408, g_period_412, g_slowing_416, MODE_SMA, 1, MODE_MAIN, 4)) / 3.0; if (gi_388 == FALSE && ld_64 > ld_0 + 10.0) gi_388 = TRUE; if (gi_392 == FALSE && ld_64 < ld_16 - 5.0) gi_392 = TRUE; if (ld_64 < ld_0 && ld_96 > ld_104 && ld_96 > ld_8 && ld_80 + MF_Buy > ld_88) li_112 = TRUE; if (ld_64 > ld_16 && ld_96 < ld_104 && ld_96 < ld_24 && ld_80 - MF_Sell < ld_88) li_116 = TRUE; if (ld_64 > ld_72 && li_112 && gi_388) { li_32 = TRUE; li_36 = FALSE; } if (ld_64 < ld_72 && li_116 && gi_392) { li_32 = FALSE; li_36 = TRUE; } if (SL_Rate_Buy != 0) SL_Pips_Buy = Ask * SL_Rate_Buy * gd_420; if (TP_Rate_Buy != 0) TP_Pips_Buy = Ask * TP_Rate_Buy * gd_420; if (SL_Rate_Sell != 0) SL_Pips_Sell = Bid * SL_Rate_Sell * gd_420; if (TP_Rate_Sell != 0) TP_Pips_Sell = Bid * TP_Rate_Sell * gd_420; if (SL_Pips_Buy != 0) gd_436 = Ask - SL_Pips_Buy * Point; if (TP_Pips_Buy != 0) gd_428 = Ask + TP_Pips_Buy * Point; if (SL_Pips_Sell != 0) gd_460 = Bid + SL_Pips_Sell * Point; if (TP_Pips_Sell != 0) gd_452 = Bid - TP_Pips_Sell * Point; if (TrailStop_Buy != 0) gd_444 = TrailStop_Buy * Point; if (TrailStop_Sell != 0) gd_468 = TrailStop_Sell * Point; l_ord_total_40 = OrdersTotal(); for (int l_pos_56 = 0; l_pos_56 < l_ord_total_40; l_pos_56++) { OrderSelect(l_pos_56, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == gi_384) { if (OrderType() == OP_BUY) l_count_48++; if (OrderType() == OP_SELL) l_count_52++; } } l_ord_total_40 = OrdersTotal(); if (l_ord_total_40 < MaxPositions_Buy && li_32) { li_60 = ExecBuy(Symbol(), gd_364, slippage, gd_436, gd_428, g_str_concat_316, gi_384); if (li_60 == 1) { gi_388 = FALSE; if (AlertMsg || EmailSend) { if (AlertMsg) Alert(StringConcatenate(Symbol(), " Position OPEN by Robowalk FX")); if (EmailSend) SendMail("Position OPEN by Robowalk FX", StringConcatenate("Now you have a ", Symbol(), " ", "new long position.")); } } } if (l_ord_total_40 < MaxPositions_Sell && li_36) { li_60 = ExecSell(Symbol(), gd_364, slippage, gd_460, gd_452, g_str_concat_316, gi_384); if (li_60 == 1) gi_392 = FALSE; if (AlertMsg || EmailSend) { if (AlertMsg) Alert(StringConcatenate(Symbol(), " Position OPEN by Robowalk FX")); if (EmailSend) SendMail("Position OPEN by Robowalk FX", StringConcatenate("Now you have a ", Symbol(), " ", "new short position.")); } } if (gd_444 > 0.0) lTrailStop(gd_444, gi_384); if (gd_468 > 0.0) sTrailStop(gd_468, gi_384); return (0); } int GetMagicNumber(int ai_0, int ai_unused_4, int ai_unused_8, int ai_unused_12) { string ls_60; string ls_20 = Symbol(); string ls_28 = StringSubstr(ls_20, 0, 3); string ls_36 = StringSubstr(ls_20, 3, 3); string ls_44 = "99"; if (ls_28 == "AED") ls_44 = "10"; if (ls_28 == "AUD") ls_44 = "11"; if (ls_28 == "BHD") ls_44 = "12"; if (ls_28 == "CAD") ls_44 = "13"; if (ls_28 == "CHF") ls_44 = "14"; if (ls_28 == "CZK") ls_44 = "15"; if (ls_28 == "DKK") ls_44 = "16"; if (ls_28 == "EEK") ls_44 = "17"; if (ls_28 == "EUR") ls_44 = "18"; if (ls_28 == "GBP") ls_44 = "19"; if (ls_28 == "HKD") ls_44 = "20"; if (ls_28 == "HRK") ls_44 = "21"; if (ls_28 == "HUF") ls_44 = "22"; if (ls_28 == "ILS") ls_44 = "23"; if (ls_28 == "ISK") ls_44 = "24"; if (ls_28 == "JOD") ls_44 = "25"; if (ls_28 == "JPY") ls_44 = "26"; if (ls_28 == "KWD") ls_44 = "27"; if (ls_28 == "LTL") ls_44 = "28"; if (ls_28 == "LVL") ls_44 = "29"; if (ls_28 == "MXN") ls_44 = "30"; if (ls_28 == "NOK") ls_44 = "31"; if (ls_28 == "NZD") ls_44 = "32"; if (ls_28 == "OMR") ls_44 = "33"; if (ls_28 == "PLN") ls_44 = "34"; if (ls_28 == "QAR") ls_44 = "35"; if (ls_28 == "RON") ls_44 = "36"; if (ls_28 == "RUB") ls_44 = "37"; if (ls_28 == "SAR") ls_44 = "38"; if (ls_28 == "SEK") ls_44 = "39"; if (ls_28 == "SGD") ls_44 = "40"; if (ls_28 == "SKK") ls_44 = "41"; if (ls_28 == "TRY") ls_44 = "42"; if (ls_28 == "USD") ls_44 = "43"; if (ls_28 == "ZAR") ls_44 = "44"; string ls_52 = "99"; if (ls_36 == "AED") ls_52 = "10"; if (ls_36 == "AUD") ls_52 = "11"; if (ls_36 == "BHD") ls_52 = "12"; if (ls_36 == "CAD") ls_52 = "13"; if (ls_36 == "CHF") ls_52 = "14"; if (ls_36 == "CZK") ls_52 = "15"; if (ls_36 == "DKK") ls_52 = "16"; if (ls_36 == "EEK") ls_52 = "17"; if (ls_36 == "EUR") ls_52 = "18"; if (ls_36 == "GBP") ls_52 = "19"; if (ls_36 == "HKD") ls_52 = "20"; if (ls_36 == "HRK") ls_52 = "21"; if (ls_36 == "HUF") ls_52 = "22"; if (ls_36 == "ILS") ls_52 = "23"; if (ls_36 == "ISK") ls_52 = "24"; if (ls_36 == "JOD") ls_52 = "25"; if (ls_36 == "JPY") ls_52 = "26"; if (ls_36 == "KWD") ls_52 = "27"; if (ls_36 == "LTL") ls_52 = "28"; if (ls_36 == "LVL") ls_52 = "29"; if (ls_36 == "MXN") ls_52 = "30"; if (ls_36 == "NOK") ls_52 = "31"; if (ls_36 == "NZD") ls_52 = "32"; if (ls_36 == "OMR") ls_52 = "33"; if (ls_36 == "PLN") ls_52 = "34"; if (ls_36 == "QAR") ls_52 = "35"; if (ls_36 == "RON") ls_52 = "36"; if (ls_36 == "RUB") ls_52 = "37"; if (ls_36 == "SAR") ls_52 = "38"; if (ls_36 == "SEK") ls_52 = "39"; if (ls_36 == "SGD") ls_52 = "40"; if (ls_36 == "SKK") ls_52 = "41"; if (ls_36 == "TRY") ls_52 = "42"; if (ls_36 == "USD") ls_52 = "43"; if (ls_36 == "ZAR") ls_52 = "44"; if (Period() == PERIOD_M1) ls_60 = "1"; if (Period() == PERIOD_M5) ls_60 = "2"; if (Period() == PERIOD_M15) ls_60 = "3"; if (Period() == PERIOD_M30) ls_60 = "4"; if (Period() == PERIOD_H1) ls_60 = "5"; if (Period() == PERIOD_H4) ls_60 = "6"; if (Period() == PERIOD_D1) ls_60 = "7"; if (Period() == PERIOD_W1) ls_60 = "8"; if (Period() == PERIOD_MN1) ls_60 = "9"; string l_dbl2str_76 = DoubleToStr(ai_0, 0); string ls_68 = l_dbl2str_76 + ls_44 + ls_52 + ls_60; int l_str2int_16 = StrToInteger(ls_68); Print("Magic Number is ", l_str2int_16); return (l_str2int_16); } int ExecBuy(string a_symbol_0, double a_lots_8, int a_slippage_16, double a_price_20, double a_price_28, string a_comment_36, int a_magic_44) { int l_ticket_48 = OrderSend(a_symbol_0, OP_BUY, a_lots_8, Ask, a_slippage_16, a_price_20, a_price_28, a_comment_36, a_magic_44, 0, Green); if (l_ticket_48 > 0) { if (OrderSelect(l_ticket_48, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened:", a_comment_36, " ", OrderOpenPrice()); return (1); } Print("Error opening BUY order : ", GetLastError()); return (0); } int ExecSell(string a_symbol_0, double a_lots_8, int a_slippage_16, double a_price_20, double a_price_28, string a_comment_36, int a_magic_44) { int l_ticket_48 = OrderSend(a_symbol_0, OP_SELL, a_lots_8, Bid, a_slippage_16, a_price_20, a_price_28, a_comment_36, a_magic_44, 0, Red); if (l_ticket_48 > 0) { if (OrderSelect(l_ticket_48, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened:", a_comment_36, " ", OrderOpenPrice()); return (1); } Print("Error opening SELL order : ", GetLastError()); return (0); } int lTrailStop(double ad_0, int a_magic_8) { int l_ord_total_12 = OrdersTotal(); for (int l_pos_16 = 0; l_pos_16 < l_ord_total_12; l_pos_16++) { OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_8 && Bid - OrderOpenPrice() > ad_0 && OrderStopLoss() < Bid - ad_0 || OrderStopLoss() == 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), Bid - ad_0, OrderTakeProfit(), 0, Green); } return (0); } int sTrailStop(double ad_0, int a_magic_8) { int l_ord_total_12 = OrdersTotal(); for (int l_pos_16 = 0; l_pos_16 < l_ord_total_12; l_pos_16++) { OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_8 && OrderOpenPrice() - Ask > ad_0 && OrderStopLoss() > Ask + ad_0 || OrderStopLoss() == 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), Ask + ad_0, OrderTakeProfit(), 0, Green); } return (0); } void Calc_Money_Management() { g_leverage_372 = AccountLeverage(); g_minlot_332 = MarketInfo(Symbol(), MODE_MINLOT); g_maxlot_340 = MarketInfo(Symbol(), MODE_MAXLOT); g_lotstep_348 = MarketInfo(Symbol(), MODE_LOTSTEP); g_lotsize_376 = MarketInfo(Symbol(), MODE_LOTSIZE); double ld_0 = Risk_Percent; double l_iopen_8 = 1; if (Acnt_Currency == 1) { l_iopen_8 = iOpen("USDJPY", PERIOD_D1, 0); ld_0 /= l_iopen_8; } if (Acnt_Currency == 2) { l_iopen_8 = iOpen("EURUSD", PERIOD_D1, 0); ld_0 /= l_iopen_8; } if (g_lotstep_348 == 0.01) gd_356 = 2; if (g_lotstep_348 == 0.1) gd_356 = 1; if (gi_328 == TRUE) { if (UseMoneyMgmt == TRUE) { gd_364 = AccountEquity() * (ld_0 / 100.0) / (g_lotsize_376 / g_leverage_372); gd_364 = StrToDouble(DoubleToStr(gd_364, gd_356)); if (gd_364 < g_minlot_332) gd_364 = g_minlot_332; if (gd_364 > g_maxlot_340) gd_364 = g_maxlot_340; } else { gd_364 = Lots; if (gd_364 < g_minlot_332) gd_364 = g_minlot_332; if (gd_364 > g_maxlot_340) gd_364 = g_maxlot_340; } } else { if (UseMoneyMgmt == TRUE) { gd_364 = AccountEquity() * (ld_0 / 100.0) / (g_lotsize_376 / g_leverage_372); gd_364 = MathRound(gd_364); if (gd_364 < g_minlot_332) gd_364 = g_minlot_332; if (gd_364 > g_maxlot_340) gd_364 = g_maxlot_340; } else { gd_364 = Lots; if (gd_364 < g_minlot_332) gd_364 = g_minlot_332; if (gd_364 > g_maxlot_340) gd_364 = g_maxlot_340; } } }