#property copyright "Copyright (c)2009, ProgreFX" #property link "" extern string Name_Of_EA = "NAMINORI BILL_FINAL9"; extern bool MoneyManagement = TRUE; extern string Minimum_Lots_x_Risk = "Risk 0.1 to 0.6(MM=false then LOTS = 0.01 x Risk)"; extern double Risk = 0.6; int gi_104 = 42; extern int MA_FAST = 15; extern int MA_SLOW = 24; extern bool ENV_ON = FALSE; extern double ENV = 0.7; extern bool MaxLotsStop = TRUE; extern int MagicNumber_bill = 100; double gd_136 = 1.0; string gs_true_144 = "true"; int gi_152 = 1; int gi_156 = 1000; double gd_160 = 1.0; double g_price_168 = 0.0; double gd_176 = 160.0; double gd_184 = 160.0; bool gi_192 = FALSE; int gi_196 = 43; int gi_200 = 160; bool gi_unused_204 = TRUE; double g_lots_208 = 0.0; int gi_216 = 1; int gi_220 = 2; int g_count_224 = 0; int gi_228 = 0; int g_pos_232 = 0; int g_slippage_236 = 5; double g_price_240 = 0.0; int g_cmd_248 = OP_BUY; int gi_252 = 0; bool gi_256 = TRUE; double g_ord_open_price_260 = 0.0; int g_ticket_268 = 0; double g_price_272 = 0.0; double g_ord_lots_280 = 0.0; string gs_288 = ""; string gs_296 = ""; string gs_304 = ""; int g_count_312 = 0; int gi_316 = 12; double gd_320 = 0.0; double gd_328 = 0.0; double gd_336 = 0.0; double gd_344 = 0.0; double gd_352 = 0.0; double gd_360 = 0.0; double gd_368 = 0.0; double gd_376 = 0.0; double gd_384 = 0.0; double gd_392 = 0.0; double gd_400 = 0.0; double gd_408 = 0.0; double gd_416 = 0.0; int start() { int l_digits_0 = MarketInfo(Symbol(), MODE_DIGITS); double l_point_4 = MarketInfo(Symbol(), MODE_POINT); double l_lotsize_12 = MarketInfo(Symbol(), MODE_LOTSIZE); double l_minlot_20 = MarketInfo(Symbol(), MODE_MINLOT); double ld_28 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), 2); string ls_36 = AccountCurrency(); if ((IsTesting() == TRUE && Period() != PERIOD_M15) || Period() != PERIOD_M15) { Alert("USE M15!"); return (0); } if (AccountBalance() < 900.0 && l_minlot_20 != 0.01) { Alert("AccountBalance is Under $1000.Start Over $1000.Need Money!"); return; } if (AccountBalance() < 9000.0 && l_minlot_20 != 0.01) { Alert("Need Over $10000 or Minimum Lots Should be 0.01."); return; } if (Digits == 4 || Digits == 2) gi_152 = 1; if (Digits == 5 || Digits == 3) gi_152 = 10; if (ls_36 == "JPY") gd_160 = 100; else gd_160 = 1; double ld_44 = MarketInfo(Symbol(), MODE_SPREAD) / gi_152; if (gd_416 > ld_28 && MaxLotsStop) { gs_288 = "Congratulations ! Lots will be reached MAXLOTS ! MM changed to `FALSE`. "; MoneyManagement = FALSE; } if (l_minlot_20 == 0.01) { gi_216 = 1; gi_220 = 2; } if (l_minlot_20 == 0.1) { gi_216 = 10; gi_220 = 1; } if (l_minlot_20 == 1.0) { gi_216 = 100; gi_220 = 0; } if (MoneyManagement) { gd_136 = MathFloor(AccountBalance() / (gi_156 * gd_160 * gi_216)); gs_true_144 = "true"; } else { if (l_minlot_20 == 0.01) { gi_216 = 1; gi_220 = 2; } if (l_minlot_20 == 0.1) { gi_216 = 10; gi_220 = 1; } if (l_minlot_20 == 1.0) { gi_216 = 100; gi_220 = 0; } gs_true_144 = "false"; if (Risk < 1.0) Risk = 1; } gd_328 = gi_216 / 100.0 * gd_136 * Risk; gd_336 = 0.03 * gi_216 * gd_136 * Risk; gd_344 = 0.05 * gi_216 * gd_136 * Risk; gd_352 = 0.08 * gi_216 * gd_136 * Risk; gd_360 = 0.13 * gi_216 * gd_136 * Risk; gd_368 = 0.21 * gi_216 * gd_136 * Risk; gd_376 = gi_216 / 2.0 * gd_136 * Risk; gd_384 = 0.55 * gi_216 * gd_136 * Risk; gd_392 = 0.89 * gi_216 * gd_136 * Risk; gd_400 = 1.0 * gi_216 * gd_136 * Risk; gd_408 = 1.0 * gi_216 * gd_136 * Risk; gd_416 = 1.0 * gi_216 * gd_136 * Risk; double l_ima_52 = iMA(NULL, PERIOD_H1, MA_FAST, 0, MODE_EMA, PRICE_CLOSE, 0); double l_ima_60 = iMA(NULL, PERIOD_H1, MA_SLOW, 0, MODE_SMA, PRICE_CLOSE, 0); double l_ienvelopes_68 = iEnvelopes(NULL, PERIOD_H4, 24, MODE_SMA, 0, PRICE_CLOSE, ENV, MODE_UPPER, 0); double l_ienvelopes_76 = iEnvelopes(NULL, PERIOD_H4, 24, MODE_SMA, 0, PRICE_CLOSE, ENV, MODE_LOWER, 0); double l_ienvelopes_84 = iEnvelopes(NULL, PERIOD_H1, 24, MODE_SMA, 1, PRICE_CLOSE, ENV, MODE_UPPER, 1); double l_ienvelopes_92 = iEnvelopes(NULL, PERIOD_H1, 24, MODE_SMA, 1, PRICE_CLOSE, ENV, MODE_LOWER, 1); double l_ienvelopes_100 = iEnvelopes(NULL, PERIOD_H4, 24, MODE_SMA, 2, PRICE_CLOSE, ENV, MODE_UPPER, 2); double l_ienvelopes_108 = iEnvelopes(NULL, PERIOD_H4, 24, MODE_SMA, 2, PRICE_CLOSE, ENV, MODE_LOWER, 2); double l_ima_116 = iMA(NULL, PERIOD_M5, 3, 0, MODE_EMA, PRICE_CLOSE, 0); double l_ima_124 = iMA(NULL, PERIOD_M5, 16, 0, MODE_EMA, PRICE_CLOSE, 0); double l_icci_132 = iCCI(NULL, PERIOD_H1, 16, PRICE_CLOSE, 0); double l_iac_140 = iAC(NULL, PERIOD_H1, 0); g_count_224 = 0; g_count_312 = 0; for (g_pos_232 = 0; g_pos_232 < OrdersTotal(); g_pos_232++) { OrderSelect(g_pos_232, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_bill) g_count_224++; if (OrderMagicNumber() == MagicNumber_bill) g_count_312++; } if (gi_228 > g_count_224) { for (g_pos_232 = OrdersTotal(); g_pos_232 >= 0; g_pos_232--) { OrderSelect(g_pos_232, SELECT_BY_POS, MODE_TRADES); g_cmd_248 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_bill) { if (g_cmd_248 == OP_BUY) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_236, Blue); if (g_cmd_248 == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_236, Red); return (0); } } } gi_228 = g_count_224; if (g_count_224 >= gi_316) gi_256 = FALSE; else gi_256 = TRUE; if (g_ord_open_price_260 == 0.0) { for (g_pos_232 = 0; g_pos_232 < OrdersTotal(); g_pos_232++) { OrderSelect(g_pos_232, SELECT_BY_POS, MODE_TRADES); g_cmd_248 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_bill) { g_ord_open_price_260 = OrderOpenPrice(); if (g_cmd_248 == OP_SELL) gi_252 = 1; if (g_cmd_248 == OP_BUY) gi_252 = 2; } } } double l_ihigh_148 = iHigh(NULL, PERIOD_H1, 0); double l_ilow_156 = iLow(NULL, PERIOD_H1, 0); double l_ihigh_164 = iHigh(NULL, PERIOD_H1, 1); double l_ilow_172 = iLow(NULL, PERIOD_H1, 1); double l_ihigh_180 = iHigh(NULL, PERIOD_H4, 2); double l_ilow_188 = iLow(NULL, PERIOD_H4, 2); if (g_count_312 == 0 && ENV_ON == TRUE) { gi_252 = 3; gi_192 = FALSE; if (l_ienvelopes_84 > l_ihigh_164 && l_ilow_172 > l_ienvelopes_92 && l_ienvelopes_68 > l_ihigh_148 && l_ilow_156 > l_ienvelopes_76) { if (l_ima_52 < l_ima_60 && l_icci_132 > -100.0 && l_iac_140 < 0.001 && l_iac_140 > -0.001 && l_ilow_188 > l_ienvelopes_108) gi_252 = 1; if (l_ima_52 > l_ima_60 && l_icci_132 < 100.0 && l_iac_140 < 0.001 && l_iac_140 > -0.001 && l_ihigh_180 < l_ienvelopes_100) gi_252 = 2; } } if (g_count_312 == 0 && ENV_ON == FALSE) { gi_252 = 3; gi_192 = FALSE; if (l_ima_52 < l_ima_60 && l_icci_132 > -100.0 && l_iac_140 < 0.001 && l_iac_140 > -0.001) gi_252 = 1; if (l_ima_52 > l_ima_60 && l_icci_132 < 100.0 && l_iac_140 < 0.001 && l_iac_140 > -0.001) gi_252 = 2; } for (g_pos_232 = OrdersTotal(); g_pos_232 >= 0; g_pos_232--) { OrderSelect(g_pos_232, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_bill) { if (OrderType() == OP_SELL) { if (OrderOpenPrice() - Ask >= gi_196 * (Point * gi_152) + gi_104 * (Point * gi_152) && OrderStopLoss() > Ask + Point * gi_152 * gi_196) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * gi_152 * gi_196, OrderClosePrice() - gi_200 * (Point * gi_152) - gi_196 * (Point * gi_152), 0, Green); gi_192 = TRUE; return (0); } } if (OrderType() == OP_BUY) { if (Bid - OrderOpenPrice() >= gi_196 * (Point * gi_152) + gi_104 * (Point * gi_152) && OrderStopLoss() < Bid - Point * gi_152 * gi_196) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * gi_152 * gi_196, OrderClosePrice() + gi_200 * (Point * gi_152) + gi_196 * (Point * gi_152), 0, Green); gi_192 = TRUE; return (0); } } } } g_ticket_268 = 0; g_price_272 = 0; g_ord_lots_280 = 0; for (g_pos_232 = 0; g_pos_232 < OrdersTotal(); g_pos_232++) { OrderSelect(g_pos_232, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_bill) { g_ticket_268 = OrderTicket(); g_price_272 = OrderClosePrice(); g_ord_lots_280 = OrderLots(); } } gd_320 = 0; if (gi_252 == 1) gs_296 = "I WANT TO SELL !"; if (gi_252 == 2) gs_296 = "I WANT TO BUY !"; if (gi_252 == 3) gs_296 = "WAITING FOR NAMINORI TIME..."; for (g_pos_232 = OrdersTotal(); g_pos_232 >= 0; g_pos_232--) { OrderSelect(g_pos_232, SELECT_BY_POS, MODE_TRADES); g_cmd_248 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_bill) gd_320 += OrderProfit(); } if (gi_192 == TRUE) gs_304 = "GO GO TRAILING!!! YOU LOVE TRAILING!!!"; else gs_304 = ""; Comment("\n", "\n", "---------------------------------------------------------------------------", "\n", " EXPERT NAME: ", Name_Of_EA, "\n", " ACCOUNT: ", AccountNumber(), "\n", "-------------------------------------Balance Info------------------", "\n", " BALANCE: ", DoubleToStr(AccountBalance(), 2), "\n", " EQUITY: ", DoubleToStr(AccountEquity(), 2), "\n", " ORDER TOTAL PROFIT: $", gd_320, "\n", "--------------------------------------Broker Info------------------", "\n", " LAVERAGE: 1:", AccountLeverage(), "\n", " DIGITS: ", l_digits_0, "\n", " SPREAD: ", ld_44, "\n", " MAXLOTS: ", ld_28, "\n", " MINIMUMLOTS: ", l_minlot_20, "\n", "------------Optimization Setting & Current Status---------", "\n", " MONEY MANAGEMENT: ", gs_true_144, "\n", " RISK: ", Risk, "\n", " FIRST LOTS: ", NormalizeDouble(gd_328, gi_220), "\n", " TRAILING: ", gs_304, "\n", " POSITIONS: ", g_count_224, "\n", " TREND SIGNAL: ", gs_296, "\n", "----------------------------------------------------------------", "\n", " ", gs_288); if (gd_320 > 0.0 || l_iac_140 > 0.002 || l_iac_140 < -0.002) { if (gi_192 == FALSE) { if (gi_252 == 1 && g_count_224 >= 2 && g_ord_open_price_260 - Ask >= gi_104 * (Point * gi_152)) { gi_256 = FALSE; OrderClose(g_ticket_268, g_ord_lots_280, g_price_272, g_slippage_236, Yellow); return (0); } if (gi_252 == 2 && g_count_224 >= 2 && Bid - g_ord_open_price_260 >= gi_104 * (Point * gi_152)) { gi_256 = FALSE; OrderClose(g_ticket_268, g_ord_lots_280, g_price_272, g_slippage_236, Yellow); return (0); } } if (gi_192 == TRUE) { if (gi_252 == 1 && l_ima_124 <= l_ima_116) { gi_256 = FALSE; OrderClose(g_ticket_268, g_ord_lots_280, g_price_272, g_slippage_236, Yellow); return (0); } if (gi_252 == 2 && l_ima_124 >= l_ima_116) { gi_256 = FALSE; OrderClose(g_ticket_268, g_ord_lots_280, g_price_272, g_slippage_236, Yellow); return (0); } } } if (gi_252 == 1 && gi_256) { if (Bid - g_ord_open_price_260 >= gi_104 * (Point * gi_152) || g_count_224 == 0) { g_ord_open_price_260 = 0; g_price_168 = Bid - gd_176 * (Point * gi_152); g_price_240 = NormalizeDouble(Bid + gd_184 * (Point * gi_152) + (gi_316 - g_count_224) * gi_104 * (Point * gi_152), Digits); if (g_count_224 != 0) { for (g_pos_232 = 1; g_pos_232 <= g_count_224; g_pos_232++) { if (g_count_224 == 1) g_lots_208 = NormalizeDouble(gd_336, gi_220); if (g_count_224 == 2) g_lots_208 = NormalizeDouble(gd_344, gi_220); if (g_count_224 == 3) g_lots_208 = NormalizeDouble(gd_352, gi_220); if (g_count_224 == 4) g_lots_208 = NormalizeDouble(gd_360, gi_220); if (g_count_224 == 5) g_lots_208 = NormalizeDouble(gd_368, gi_220); if (g_count_224 == 6) g_lots_208 = NormalizeDouble(gd_376, gi_220); if (g_count_224 == 7) g_lots_208 = NormalizeDouble(gd_384, gi_220); if (g_count_224 == 8) g_lots_208 = NormalizeDouble(gd_392, gi_220); if (g_count_224 == 9) g_lots_208 = NormalizeDouble(gd_400, gi_220); if (g_count_224 == 10) g_lots_208 = NormalizeDouble(gd_408, gi_220); if (g_count_224 == 11) g_lots_208 = NormalizeDouble(gd_416, gi_220); } } else g_lots_208 = NormalizeDouble(gd_328, gi_220); if (g_lots_208 >= ld_28) g_lots_208 = ld_28; OrderSend(Symbol(), OP_SELL, g_lots_208, Bid, g_slippage_236, g_price_240, g_price_168, "", MagicNumber_bill, 0, Red); return (0); } } if (gi_252 == 2 && gi_256) { if (g_ord_open_price_260 - Ask >= gi_104 * (Point * gi_152) || g_count_224 == 0) { g_ord_open_price_260 = 0; g_price_168 = Ask + gd_176 * (Point * gi_152); g_price_240 = NormalizeDouble(Ask - gd_184 * (Point * gi_152) - (gi_316 - g_count_224) * gi_104 * (Point * gi_152), Digits); if (g_count_224 != 0) { for (g_pos_232 = 1; g_pos_232 <= g_count_224; g_pos_232++) { if (g_count_224 == 1) g_lots_208 = NormalizeDouble(gd_336, gi_220); if (g_count_224 == 2) g_lots_208 = NormalizeDouble(gd_344, gi_220); if (g_count_224 == 3) g_lots_208 = NormalizeDouble(gd_352, gi_220); if (g_count_224 == 4) g_lots_208 = NormalizeDouble(gd_360, gi_220); if (g_count_224 == 5) g_lots_208 = NormalizeDouble(gd_368, gi_220); if (g_count_224 == 6) g_lots_208 = NormalizeDouble(gd_376, gi_220); if (g_count_224 == 7) g_lots_208 = NormalizeDouble(gd_384, gi_220); if (g_count_224 == 8) g_lots_208 = NormalizeDouble(gd_392, gi_220); if (g_count_224 == 9) g_lots_208 = NormalizeDouble(gd_400, gi_220); if (g_count_224 == 10) g_lots_208 = NormalizeDouble(gd_408, gi_220); if (g_count_224 == 11) g_lots_208 = NormalizeDouble(gd_416, gi_220); } } else g_lots_208 = NormalizeDouble(gd_328, gi_220); if (g_lots_208 >= ld_28) g_lots_208 = ld_28; OrderSend(Symbol(), OP_BUY, g_lots_208, Ask, g_slippage_236, g_price_240, g_price_168, "", MagicNumber_bill, 0, Blue); return (0); } } return (0); }