有您的持续关注
我们会做得更好

智能交易系统 Logical Scalper v.1.892 EA



Logical Scalper v.1.892 EA对不同的货币对采用不同的盈利、止损及指标参数交易。

本网收集整理智能交易EA仅为MQL4编程爱好者提供语法及相关编程技巧的学习研究之用,智能交易存在极高的风险测试请用模拟盘,请勿用于实盘。Logical Scalper v.1.892 EA源码:

 //+------------------------------------------------------------------+
//|                                       Logical Scalper v.1.892.mq4 |
//|                                          Copyright WWW.SCALPER.RU |
//+-------------------------------------------------------------------+

#property copyright "WWW.SCALPER.RU"
#property link      "WWW.SCALPER.RU"

extern int TakeProfit = 44;
extern int StopLoss = 80;
extern int TrailingStop = 40;
bool gi_88 = FALSE;
bool gi_92 = FALSE;
extern double Lots = 1.0;
extern bool MM = TRUE;
extern double MaximumRisk = 10.0;
extern double DecreaseFactor = 2.0;
bool gi_124 = TRUE;
bool gi_128 = TRUE;
bool gi_132 = TRUE;
bool gi_136 = TRUE;
bool gi_140 = TRUE;
bool gi_144 = TRUE;
extern int MAPeriod = 3;
extern int MABars = 14;
extern double Percent = 0.0026;
extern int EnvPer = 6;
extern int OscPer1 = 23;
extern int OscPer2 = 17;
extern double OscSigPer = 15.0;
int gi_184 = 0;
int gi_188 = 24;
int gi_192 = 0;
int gi_196 = 0;
int gi_200 = 0;
int gi_204 = 0;
int gi_208 = 0;
int gi_212 = 0;
extern int FT_Per = 25;
extern int SL_Per = 36;
int gi_224 = 1;
int gi_228 = 1;
extern double TradeRatio = 0.00042;
extern double TradeOffRatio = 0.05;
extern string Comm = "Logical Scalper";
int g_magic_256;
int gi_unused_260;

 

 
double setpoint() {
   double ld_ret_0;
   if (Digits == 3) ld_ret_0 = 0.01;
   else
      if (Digits == 5) ld_ret_0 = 0.0001;
   return (ld_ret_0);
}

int init() {
   gi_unused_260 = 3;
   g_magic_256 = 123456;
   HideTestIndicators(TRUE);
   return (0);
}
void deinit() {
   Comment("www.125808047.com");
}

int CalculateCurrentOrders(string as_unused_0) {
   int l_count_8 = 0;
   int l_count_12 = 0;
   for (int l_pos_16 = 0; l_pos_16 < OrdersTotal(); l_pos_16++) {
      if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_256) {
         if (OrderType() == OP_BUY) l_count_8++;
         if (OrderType() == OP_SELL) l_count_12++;
      }
   }
   if (l_count_8 > 0) return (l_count_8);
   return (-l_count_12);
}

double LotsOptimized() {
   double ld_ret_0 = Lots;
   int l_hist_total_8 = OrdersHistoryTotal();
   int l_count_12 = 0;
   ld_ret_0 = NormalizeDouble(0.00001 * (AccountFreeMargin() * MaximumRisk), 1);
   if (DecreaseFactor > 0.0) {
      for (int l_pos_16 = l_hist_total_8 - 1; l_pos_16 >= 0; l_pos_16--) {
         if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_HISTORY) == FALSE) {
            Print("Error in history!");
            break;
         }
         if (OrderSymbol() != Symbol() || OrderType() > OP_SELL) continue;
         if (OrderProfit() > 0.0) break;
         if (OrderProfit() < 0.0) l_count_12++;
      }
      if (l_count_12 > 1) ld_ret_0 = NormalizeDouble(ld_ret_0 - ld_ret_0 * l_count_12 / DecreaseFactor, 1);
   }
   if (ld_ret_0 < 0.1) ld_ret_0 = 0.1;
   if (MM == FALSE) ld_ret_0 = Lots;
   if (gi_92 == TRUE) ld_ret_0 /= 10.0;
   return (ld_ret_0);
}

void CheckForOpen() {
   int l_ticket_0;
   int l_hour_4;
   int li_8;
   if (gi_88 == TRUE) {
      if (Symbol() == "USDJPY" || Symbol() == "USDJPYm") {
         MAPeriod = 2;
         MABars = 18;
         Percent = 0.0032;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 5;
         OscPer2 = 22;
         OscSigPer = 2;
         EnvPer = 2;
         FT_Per = 25;
         SL_Per = 15;
         TradeRatio = 0.0029;
         TradeOffRatio = 0.024;
      }
      if (Symbol() == "EURJPY" || Symbol() == "EURJPYm") {
         MAPeriod = 18;
         MABars = 10;
         Percent = 0.018;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 5;
         OscPer2 = 30;
         OscSigPer = 5;
         EnvPer = 6;
         FT_Per = 30;
         SL_Per = 16;
         TradeRatio = 0.0052;
         TradeOffRatio = 0.027;
      }
      if (Symbol() == "GBPJPY" || Symbol() == "GBPJPYm") {
         MAPeriod = 8;
         MABars = 12;
         Percent = 0.0072;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 5;
         OscPer2 = 36;
         OscSigPer = 10;
         EnvPer = 2;
         FT_Per = 17;
         SL_Per = 28;
         TradeRatio = 0.0034;
         TradeOffRatio = 0.063;
      }
      if (Symbol() == "CHFJPY" || Symbol() == "CHFJPYm") {
         MAPeriod = 30;
         MABars = 4;
         Percent = 0.012;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 7;
         OscPer2 = 45;
         OscSigPer = 8;
         EnvPer = 20;
         FT_Per = 52;
         SL_Per = 29;
         TradeRatio = 0.0016;
         TradeOffRatio = 0.034;
      }
      if (Symbol() == "EURUSD" || Symbol() == "EURUSDm") {
         MAPeriod = 11;
         MABars = 50;
         Percent = 0.001;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 8;
         OscPer2 = 40;
         OscSigPer = 10;
         EnvPer = 20;
         FT_Per = 4;
         SL_Per = 15;
         TradeRatio = 0.0003;
         TradeOffRatio = 0.006;
      }
      if (Symbol() == "GBPUSD" || Symbol() == "GBPUSDm") {
         MAPeriod = 3;
         MABars = 14;
         Percent = 0.0023;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 23;
         OscPer2 = 17;
         OscSigPer = 15;
         EnvPer = 6;
         FT_Per = 25;
         SL_Per = 37;
         TradeRatio = 0.00042;
         TradeOffRatio = 0.05;
      }
      if (Symbol() == "USDCHF" || Symbol() == "USDCHFm") {
         MAPeriod = 5;
         MABars = 9;
         Percent = 0.0056;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 5;
         OscPer2 = 12;
         OscSigPer = 11;
         EnvPer = 10;
         FT_Per = 5;
         SL_Per = 20;
         TradeRatio = 0.00022;
         TradeOffRatio = 0.0015;
      }
      if (Symbol() == "GBPCHF" || Symbol() == "GBPCHFm") {
         MAPeriod = 10;
         MABars = 20;
         Percent = 0.034;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 9;
         OscPer2 = 30;
         OscSigPer = 4;
         EnvPer = 7;
         FT_Per = 25;
         SL_Per = 50;
         TradeRatio = 0.001;
         TradeOffRatio = 0.03;
      }
      if (Symbol() == "AUDUSD" || Symbol() == "AUDUSDm") {
         MAPeriod = 12;
         MABars = 2;
         Percent = 0.008;
         TakeProfit = 24;
         StopLoss = 46;
         TrailingStop = 0;
         OscPer1 = 10;
         OscPer2 = 40;
         OscSigPer = 2;
         EnvPer = 4;
         FT_Per = 30;
         SL_Per = 5;
         TradeRatio = 0.0004;
         TradeOffRatio = 0.0005;
      }
      if (Symbol() == "EURCHF" || Symbol() == "EURCHFm") {
         MAPeriod = 19;
         MABars = 3;
         Percent = 0.008;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 3;
         OscPer2 = 30;
         OscSigPer = 3;
         EnvPer = 4;
         FT_Per = 35;
         SL_Per = 80;
         TradeRatio = 0.0004;
         TradeOffRatio = 0.0005;
      }
      if (Symbol() == "EURAUD" || Symbol() == "EURAUDm") {
         MAPeriod = 2;
         MABars = 6;
         Percent = 0.004;
         TakeProfit = 42;
         StopLoss = 84;
         TrailingStop = 0;
         OscPer1 = 4;
         OscPer2 = 45;
         OscSigPer = 10;
         EnvPer = 4;
         FT_Per = 20;
         SL_Per = 36;
         TradeRatio = 0.0005;
         TradeOffRatio = 0.0009;
      }
      if (Symbol() == "USDCAD" || Symbol() == "USDCADm") {
         MAPeriod = 2;
         MABars = 2;
         Percent = 0.0036;
         TakeProfit = 60;
         StopLoss = 65;
         TrailingStop = 0;
         OscPer1 = 3;
         OscPer2 = 10;
         OscSigPer = 3;
         EnvPer = 4;
         FT_Per = 5;
         SL_Per = 10;
         TradeRatio = 0.0005;
         TradeOffRatio = 0.001;
      }
   }
    
   bool li_12 = FALSE;
   bool li_16 = FALSE;
   double l_ienvelopes_20 = iEnvelopes(NULL, PERIOD_M15, EnvPer, MODE_SMA, 0, PRICE_CLOSE, Percent, MODE_UPPER, 1);
   double l_ienvelopes_28 = iEnvelopes(NULL, PERIOD_M15, EnvPer, MODE_SMA, 0, PRICE_CLOSE, Percent, MODE_LOWER, 1);
   double l_iclose_36 = iClose(NULL, PERIOD_M15, 1);
   if (gi_124) {
      if (l_iclose_36 > l_ienvelopes_20) li_16 = TRUE;
      if (l_iclose_36 < l_ienvelopes_28) li_12 = TRUE;
   } else {
      li_16 = TRUE;
      li_12 = TRUE;
   }
   bool li_44 = FALSE;
   bool li_48 = FALSE;
   double l_ima_52 = iMA(NULL, PERIOD_M15, MAPeriod, 0, MODE_SMA, PRICE_CLOSE, 1);
   double l_ima_60 = iMA(NULL, PERIOD_M15, MAPeriod, 0, MODE_SMA, PRICE_CLOSE, MABars);
   if (gi_128) {
      if (l_ima_60 - l_ima_52 > 0.0) li_44 = TRUE;
      if (l_ima_60 - l_ima_52 < 0.0) li_48 = TRUE;
   } else {
      li_48 = TRUE;
      li_44 = TRUE;
   }
   bool li_68 = FALSE;
   bool li_72 = FALSE;
   double l_iosma_76 = iOsMA(NULL, PERIOD_M15, OscPer2, OscPer1, OscSigPer, PRICE_CLOSE, 2);
   double l_iosma_84 = iOsMA(NULL, PERIOD_M15, OscPer2, OscPer1, OscSigPer, PRICE_CLOSE, 1);
   if (gi_132) {
      if (l_iosma_76 > l_iosma_84) li_72 = TRUE;
      if (l_iosma_76 < l_iosma_84) li_68 = TRUE;
   } else {
      li_72 = TRUE;
      li_68 = TRUE;
   }
   bool li_92 = FALSE;
   bool li_96 = FALSE;
   double ld_100 = divergence(FT_Per, SL_Per, gi_224, gi_228, 0);
   if (gi_136) {
      if (ld_100 >= TradeRatio && ld_100 <= TradeOffRatio) li_92 = TRUE;
      if (ld_100 <= (-1.0 * TradeRatio) && ld_100 >= (-1.0 * TradeOffRatio)) li_96 = TRUE;
   } else {
      li_96 = TRUE;
      li_92 = TRUE;
   }
   bool li_108 = FALSE;
   bool li_112 = FALSE;
   if (gi_140) {
      l_hour_4 = TimeHour(TimeLocal());
      li_8 = F_ValidTradeTime(l_hour_4);
      if (li_8 == 1) {
         li_108 = TRUE;
         li_112 = TRUE;
      }
   } else {
      li_112 = TRUE;
      li_108 = TRUE;
   }
   if (li_16 == TRUE && li_48 == TRUE && li_72 == TRUE && li_96 == TRUE && li_112 == TRUE) {
      l_ticket_0 = OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, 3, Bid + StopLoss * setpoint(), Bid - TakeProfit * setpoint(), Comm, g_magic_256, 0, Red);
      return;
   }
   if (li_12 == TRUE && li_44 == TRUE && li_68 == TRUE && li_92 == TRUE && li_108 == TRUE) l_ticket_0 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, 3, Ask - StopLoss * setpoint(), Ask + TakeProfit * setpoint(), Comm, g_magic_256, 0, Blue);
}

void CheckForClose() {
   for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) {
      if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
      if (OrderMagicNumber() != g_magic_256 || OrderSymbol() != Symbol()) continue;
      if (OrderType() == OP_BUY) {
         if (TrailingStop > 0) {
            if (Bid - OrderOpenPrice() > setpoint() * TrailingStop) {
               if (OrderStopLoss() < Bid - setpoint() * TrailingStop) {
                  bool cg = OrderModify(OrderTicket(), OrderOpenPrice(), Bid - setpoint() * TrailingStop, OrderTakeProfit(), 0, GreenYellow);
                  return;
               }
            }
         }
      }
      if (OrderType() == OP_SELL) {
         if (TrailingStop > 0) {
            if (OrderOpenPrice() - Ask > setpoint() * TrailingStop) {
               if (OrderStopLoss() > Ask + setpoint() * TrailingStop) {
                   cg = OrderModify(OrderTicket(), OrderOpenPrice(), Ask + setpoint() * TrailingStop, OrderTakeProfit(), 0, Red);
                  return;
               }
            }
         }
      }
   }
}

void start() {
   string ls_0;
   if (gi_144) {
      ls_0 = "(c)2007  HTTP://WWW.SCALPER.RU";
      Comment(ls_0);
   }
   if (!IsTradeAllowed()) {
      Comment("");
      return;
   }
   Comment("");
   if (Bars < 100 || IsTradeAllowed() == FALSE) return;
   if (CalculateCurrentOrders(Symbol()) == 0) {
      CheckForOpen();
      return;
   }
   CheckForClose();
}

double divergence(int a_period_0, int a_period_4, int a_applied_price_8, int a_applied_price_12, int ai_16) {
   double l_ima_20 = iMA(Symbol(), 0, a_period_0, 0, MODE_SMA, a_applied_price_8, ai_16);
   double l_ima_28 = iMA(Symbol(), 0, a_period_4, 0, MODE_SMA, a_applied_price_12, ai_16);
   double ld_36 = l_ima_20 - l_ima_28;
   double l_ima_44 = iMA(Symbol(), 0, a_period_0, 0, MODE_SMA, a_applied_price_8, ai_16 + 1);
   double l_ima_52 = iMA(Symbol(), 0, a_period_4, 0, MODE_SMA, a_applied_price_12, ai_16 + 1);
   double ld_60 = l_ima_20 - l_ima_28 - (l_ima_44 - l_ima_52);
   return (ld_36 - ld_60);
}

int F_ValidTradeTime(int ai_0) {
   if ((ai_0 >= gi_184 && ai_0 <= gi_188 - 1) || (ai_0 >= gi_192 && ai_0 <= gi_196 - 1) || (ai_0 >= gi_200 && ai_0 <= gi_204 - 1) || (ai_0 >= gi_208 && ai_0 <= gi_212 - 1)) return (1);
   return (0);
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 智能交易系统 Logical Scalper v.1.892 EA
上一篇:
下一篇:
分享到:更多 ()