诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4 EA > 正文

根据KD信号开发的EURUSD自动交易EA Forex_Cyclone EU m30.mq4

Forex_Cyclone EU m30 EA用在欧美30分钟图表交易。

源码:

//+------------------------------------------------------------------+
//|                                         Forex_Cyclone EU m30.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.125808047.com"

bool gi_76 = FALSE;
double g_minlot_80;
double g_maxlot_88;
extern double PercentRisk = 5.0;
extern int MagicNumber = 177777;
extern int MaxSlippage = 3;
extern double Lots = 0.0;
int gi_120 = 45;
int gi_124 = 10;
int gi_128 = 65;
int gi_132 = 14;
int gi_136 = 14;
int gi_140 = 1440;
int gi_144 = 0;
double g_istochastic_148;
double g_isar_156;
double g_isar_164;
double gd_172;
bool cg = false;

int OnInit(void)
{
   if (MarketInfo(Symbol(), MODE_MINLOT) == 0.1) gi_76 = TRUE;
   g_minlot_80 = MarketInfo(Symbol(), MODE_MINLOT);
   g_maxlot_88 = MarketInfo(Symbol(), MODE_MAXLOT);
   if (Bars < 1000) Alert(" Error Number : 0001 - Contact support");
   if (Digits == 5) gd_172 = 10.0 * Point;
   else gd_172 = Point;
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}

void  OnTick()
{
   SL_TP_Corrected(CheckSL(gi_140, gi_136, gi_144, gi_120, gi_128), CheckTP(gi_140, gi_136, gi_144, gi_132, gi_132));
   if (CountingPositions() > 0) return;
   double ld_0 = Lots;
   if (PercentRisk != 0.0 && gi_120 != 0) ld_0 = GetLots(gi_120);
   else ld_0 = Lots;
   if (ld_0 < g_minlot_80) ld_0 = g_minlot_80;
   if (ld_0 > g_maxlot_88) ld_0 = g_maxlot_88;
   OpenBuyOrder(ld_0, gi_120, gi_128, gi_124, gi_132, MaxSlippage, MagicNumber, gd_172, gi_140, gi_136, gi_144, 1440, 34, 0);
   OpenSellOrder(ld_0, gi_120, gi_128, gi_124, gi_132, MaxSlippage, MagicNumber, gd_172, gi_140, gi_136, gi_144, 1440, 34, 0);
}

int CountingPositions() {
   int l_count_0 = 0;
   for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) {
      cg = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() && (OrderType() == OP_BUY || OrderType() == OP_SELL)) l_count_0++;
   }
   return (l_count_0);
}

void OpenBuyOrder(double a_lots_0, int ai_8, int ai_12, int ai_16, int ai_20, int a_slippage_24, int a_magic_28, double ad_32, int a_timeframe_40, int a_period_44, double ad_48, int ai_56, int ai_60, int ai_64) {
   int l_ticket_68;
   double l_price_72 = 0;
   double l_price_80 = 0;
   if (CheckEntryConditionBUY(a_timeframe_40, a_period_44, ad_48, ai_56, ai_60, ai_64)) {
      if (iATR(NULL, a_timeframe_40, a_period_44, 0) > ad_48) {
         ai_8 = ai_12;
         ai_16 = ai_20;
      }
      l_price_72 = 0;
      if (ai_8 > 0.0) l_price_72 = Ask - ai_8 * ad_32;
      l_price_80 = 0;
      if (ai_16 > 0.0) l_price_80 = Ask + ai_16 * ad_32;
      l_ticket_68 = OrderSend(Symbol(), OP_BUY, a_lots_0, Ask, a_slippage_24, 0, 0, "", a_magic_28, 0, Gold);
      cg = OrderSelect(l_ticket_68, SELECT_BY_TICKET);
      cg = OrderModify(l_ticket_68, OrderOpenPrice(), l_price_72, l_price_80, 0, White);
   }
}

void OpenSellOrder(double a_lots_0, int ai_8, int ai_12, int ai_16, int ai_20, int a_slippage_24, int a_magic_28, double ad_32, int a_timeframe_40, int a_period_44, double ad_48, int ai_56, int ai_60, int ai_64) {
   int l_ticket_68;
   double l_price_72 = 0;
   double l_price_80 = 0;
   if (CheckEntryConditionSELL(a_timeframe_40, a_period_44, ad_48, ai_56, ai_60, ai_64)) {
      if (iATR(NULL, a_timeframe_40, a_period_44, 0) > ad_48) {
         ai_8 = ai_12;
         ai_16 = ai_20;
      }
      l_price_72 = 0;
      if (ai_8 > 0.0) l_price_72 = Bid + ai_8 * ad_32;
      l_price_80 = 0;
      if (ai_16 > 0.0) l_price_80 = Bid - ai_16 * ad_32;
      l_ticket_68 = OrderSend(Symbol(), OP_SELL, a_lots_0, Bid, a_slippage_24, 0, 0, "", a_magic_28, 0, Gold);
      cg = OrderSelect(l_ticket_68, SELECT_BY_TICKET);
      cg = OrderModify(l_ticket_68, OrderOpenPrice(), l_price_72, l_price_80, 0, White);
   }
}

bool CheckEntryConditionBUY(int a_timeframe_0, int a_period_4, double ad_8, int a_timeframe_16, int a_period_20, int ai_24) {
   double l_iatr_28 = iATR(NULL, a_timeframe_0, a_period_4, 0);
   if (ai_24 == 1 || l_iatr_28 > ad_8)
      if (iCCI(NULL, a_timeframe_16, a_period_20, PRICE_CLOSE, 0) < 0.0) return (FALSE);
   g_istochastic_148 = iStochastic(NULL, 0, 2, 3, 4, MODE_SMA, 0, MODE_MAIN, 0);
   if (g_istochastic_148 >= 23.0) return (FALSE);
   g_isar_156 = iSAR(NULL, 0, 0.02, 0.1, 1);
   if (g_isar_156 > Ask) return (FALSE);
   g_isar_164 = iSAR(NULL, 0, 0.03, 0.3, 1);
   if (g_isar_164 < g_isar_156) return (FALSE);
   return (TRUE);
}

bool CheckEntryConditionSELL(int a_timeframe_0, int a_period_4, double ad_8, int a_timeframe_16, int a_period_20, int ai_24) {
   double l_iatr_28 = iATR(NULL, a_timeframe_0, a_period_4, 0);
   if (ai_24 == 1 || l_iatr_28 > ad_8)
      if (iCCI(NULL, a_timeframe_16, a_period_20, PRICE_CLOSE, 0) > 0.0) return (FALSE);
   g_istochastic_148 = iStochastic(NULL, 0, 3, 3, 1, MODE_SMA, 0, MODE_MAIN, 0);
   if (g_istochastic_148 <= 66.0) return (FALSE);
   g_isar_156 = iSAR(NULL, 0, 0.04, 0.4, 0);
   if (g_isar_156 < Bid) return (FALSE);
   g_isar_164 = iSAR(NULL, 0, 0.04, 0.2, 1);
   if (g_isar_164 >= g_isar_156) return (FALSE);
   return (TRUE);
}

int CheckSL(int a_timeframe_0, int a_period_4, double ad_8, int ai_16, int ai_20) {
   if (iATR(NULL, a_timeframe_0, a_period_4, 0) > ad_8) return (ai_20);
   return (ai_16);
}

int CheckTP(int a_timeframe_0, int a_period_4, double ad_8, int ai_16, int ai_20) {
   if (iATR(NULL, a_timeframe_0, a_period_4, 0) > ad_8) return (ai_20);
   return (ai_16);
}

void SL_TP_Corrected(int ai_0, int ai_4) {
   double l_price_8;
   double l_price_16;
   for (int l_pos_24 = 0; l_pos_24 < OrdersTotal(); l_pos_24++) {
      if (OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
            if ((OrderStopLoss() == 0.0 && ai_0 != 0.0) || (OrderTakeProfit() == 0.0 && ai_4 != 0.0)) {
               l_price_8 = 0;
               l_price_16 = 0;
               if (OrderType() == OP_BUY) {
                  if (ai_0 > 0) l_price_8 = Ask - ai_0 * gd_172;
                  if (ai_4 > 0) l_price_16 = Ask + ai_4 * gd_172;
                  cg = OrderModify(OrderTicket(), OrderOpenPrice(), l_price_8, l_price_16, 0, Green);
               }
               if (OrderType() == OP_SELL) {
                  if (ai_0 > 0) l_price_8 = Bid + ai_0 * gd_172;
                  if (ai_4 > 0) l_price_16 = Bid - ai_4 * gd_172;
                  cg = OrderModify(OrderTicket(), OrderOpenPrice(), l_price_8, l_price_16, 0, Green);
               }
            }
         }
      }
   }
}

double GetLots(double ad_0) {
   double ld_ret_8;
   double ld_16 = AccountEquity() * PercentRisk / 100.0;
   double ld_24 = ld_16 / ad_0;
   if (MarketInfo(Symbol(), MODE_LOTSIZE) == 100000.0) ld_ret_8 = ld_24 / 10.0;
   if (MarketInfo(Symbol(), MODE_LOTSIZE) == 10000.0) ld_ret_8 = 1.0 * ld_24;
   if (gi_76) ld_ret_8 = NormalizeDouble(ld_ret_8, 1);
   return (ld_ret_8);
}
打赏
版权所有转载请注明标题及链接:峰汇在线 » 根据KD信号开发的EURUSD自动交易EA Forex_Cyclone EU m30.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏