Summary: EURUSD三核EA是一款融合EMA趋势、随机震荡指标和K线形态三重确认的MQL4智能交易系统。专为欧美稳定低风险运行设计,适合H1周期。




EURUSD三核EA融合了三类互补逻辑:趋势跟踪(EMA)、动量/均值回归(随机指标)以及价格行为确认(K线形态)。EA仅当三个条件同时满足时才开仓,有效减少假信号。包含基于ATR的波动率过滤、每日亏损限制、点差控制和周五平仓保护。策略追求稳步复利增长,而非高频交易。

推荐加载周期: H1
策略核心逻辑:
  • 趋势过滤:EMA(50)判断方向(价格高于EMA只做多,低于EMA只做空)。

  • 随机指标过滤:做多要求Stochastic(14,3,3)低于20(超卖区);做空要求高于80(超买区)。

  • K线确认:做多需要看涨吞没或锤子线;做空需要看跌吞没或射击之星。

  • 风险管理:固定止损250点,止盈450点。同时持仓最多1单,每日亏损上限5%,最大点差25点。


  • ``mql4
    //+------------------------------------------------------------------+
    //| EURUSDTriCoreEA.mq4 |
    //+------------------------------------------------------------------+
    #property copyright ""
    #property link ""
    #property version "1.00"
    #property strict

    //--- 输入参数及注释
    input double LotSize = 0.01; // 固定交易手数(0.01手)
    input int StopLossPoints = 250; // 止损点数(25个标准点)
    input int TakeProfitPoints = 450; // 止盈点数(45个标准点)
    input int TrendMAPeriod = 50; // EMA趋势过滤周期
    input int StochK = 14; // 随机指标%K周期
    input int StochD = 3; // 随机指标%D周期
    input int StochSlowing = 3; // 随机指标减速参数
    input int StochOversold = 20; // 随机指标超卖水平(买入区)
    input int StochOverbought = 80; // 随机指标超买水平(卖出区)
    input int ATRPeriod = 14; // ATR波动率周期
    input double MaxATRMultiplier = 1.8; // 最大ATR倍数(超过avgATR倍数则跳过)
    input int MagicNumber = 202416; // EA魔术号
    input int MaxSpread = 25; // 最大允许点差(单位:点)
    input double DailyLossLimit = 5.0; // 每日亏损限额(账户余额百分比)
    input bool UseFridayClose = true; // 周五21:00 GMT前平仓

    //--- 全局变量
    double dailyStartBalance = 0;
    datetime lastBarTime = 0;
    bool fridayCloseExecuted = false;
    double avgATR = 0;

    //+------------------------------------------------------------------+
    //| EA初始化函数 |
    //+------------------------------------------------------------------+
    int OnInit()
    {
    dailyStartBalance = AccountBalance();
    lastBarTime = 0;
    fridayCloseExecuted = false;
    avgATR = iATR(Symbol(), PERIOD_H1, ATRPeriod, 1);
    if(avgATR <= 0) avgATR = 120 Point;
    return(INIT_SUCCEEDED);
    }

    //+------------------------------------------------------------------+
    //| EA退出函数 |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
    Comment("");
    }

    //+------------------------------------------------------------------+
    //| 检测看涨K线形态(吞没或锤子) |
    //+------------------------------------------------------------------+
    bool IsBullishCandle()
    {
    double open = iOpen(Symbol(), PERIOD_H1, 1);
    double close = iClose(Symbol(), PERIOD_H1, 1);
    double high = iHigh(Symbol(), PERIOD_H1, 1);
    double low = iLow(Symbol(), PERIOD_H1, 1);
    double body = close - open;
    double upperShadow = high - close;
    double lowerShadow = open - low;

    // 看涨吞没:前一根阴线,当前阳线且完全覆盖前一根
    double prevOpen = iOpen(Symbol(), PERIOD_H1, 2);
    double prevClose = iClose(Symbol(), PERIOD_H1, 2);
    bool engulfing = (prevClose < prevOpen) && (close > open) && (close > prevOpen) && (open < prevClose);

    // 锤子线:下影线长,上影线短,实体靠近上方
    bool hammer = (lowerShadow > 2
    body) && (upperShadow < body) && (body > 0);

    return (engulfing || hammer);
    }

    //+------------------------------------------------------------------+
    //| 检测看跌K线形态(吞没或射击之星) |
    //+------------------------------------------------------------------+
    bool IsBearishCandle()
    {
    double open = iOpen(Symbol(), PERIOD_H1, 1);
    double close = iClose(Symbol(), PERIOD_H1, 1);
    double high = iHigh(Symbol(), PERIOD_H1, 1);
    double low = iLow(Symbol(), PERIOD_H1, 1);
    double body = open - close;
    double upperShadow = high - open;
    double lowerShadow = close - low;

    // 看跌吞没:前一根阳线,当前阴线且完全覆盖前一根
    double prevOpen = iOpen(Symbol(), PERIOD_H1, 2);
    double prevClose = iClose(Symbol(), PERIOD_H1, 2);
    bool engulfing = (prevClose > prevOpen) && (close < open) && (close < prevOpen) && (open > prevClose);

    // 射击之星:上影线长,下影线短,实体靠近下方
    bool shootingStar = (upperShadow > 2 body) && (lowerShadow < body) && (body > 0);

    return (engulfing || shootingStar);
    }

    //+------------------------------------------------------------------+
    //| EA主循环函数(每Tick执行) |
    //+------------------------------------------------------------------+
    void OnTick()
    {
    // 每日净值保护
    double currentEquity = AccountEquity();
    double lossPercent = (dailyStartBalance - currentEquity) / dailyStartBalance
    100;
    if(lossPercent >= DailyLossLimit)
    {
    Comment("已达每日亏损上限,停止开新仓");
    return;
    }

    // 周五收盘前平仓(规避周末跳空)
    if(UseFridayClose && !fridayCloseExecuted)
    {
    datetime currentTime = TimeCurrent();
    if(TimeDayOfWeek(currentTime) == 5 && TimeHour(currentTime) >= 21)
    {
    CloseAllOrders();
    fridayCloseExecuted = true;
    return;
    }
    if(TimeDayOfWeek(currentTime) != 5)
    fridayCloseExecuted = false;
    }

    // 点差过滤
    if(MarketInfo(Symbol(), MODE_SPREAD) > MaxSpread)
    {
    Comment("当前点差过大:", MarketInfo(Symbol(), MODE_SPREAD));
    return;
    }

    // 仅在新K线开始时检测入场(H1)
    if(Time[0] == lastBarTime)
    return;
    lastBarTime = Time[0];

    // 检查现有持仓
    if(CountPositions() > 0)
    return;

    // 计算指标
    double ema = iMA(Symbol(), PERIOD_H1, TrendMAPeriod, 0, MODE_EMA, PRICE_CLOSE, 1);
    double close1 = iClose(Symbol(), PERIOD_H1, 1);
    double stochMain = iStochastic(Symbol(), PERIOD_H1, StochK, StochD, StochSlowing, MODE_SMA, 0, MODE_MAIN, 1);
    double atr = iATR(Symbol(), PERIOD_H1, ATRPeriod, 1);

    // 更新平均ATR用于波动率过滤
    if(atr > 0) avgATR = (avgATR 0.95) + (atr 0.05);

    // 波动率过滤:当前ATR过高则跳过
    if(atr > avgATR MaxATRMultiplier && avgATR > 0)
    {
    Comment("当前波动率过高,ATR: ", atr);
    return;
    }

    int cmd = -1;
    double sl = 0, tp = 0;
    double ask = Ask;
    double bid = Bid;

    // 做多条件:价格高于EMA,随机指标超卖,看涨K线形态
    if(close1 > ema && stochMain < StochOversold && IsBullishCandle())
    {
    cmd = OP_BUY;
    sl = bid - StopLossPoints
    Point;
    tp = bid + TakeProfitPoints Point;
    }
    // 做空条件:价格低于EMA,随机指标超买,看跌K线形态
    else if(close1 < ema && stochMain > StochOverbought && IsBearishCandle())
    {
    cmd = OP_SELL;
    sl = ask + StopLossPoints
    Point;
    tp = ask - TakeProfitPoints * Point;
    }

    if(cmd != -1)
    {
    int ticket = OrderSend(Symbol(), cmd, LotSize, (cmd==OP_BUY?ask:bid), 3, sl, tp, "EURUSD TriCore", MagicNumber, 0, clrNONE);
    if(ticket < 0)
    Print("开仓失败,错误码:", GetLastError());
    }
    }

    //+------------------------------------------------------------------+
    //| 统计当前魔术号的持仓数量 |
    //+------------------------------------------------------------------+
    int CountPositions()
    {
    int count = 0;
    for(int i = OrdersTotal()-1; i >= 0; i--)
    {
    if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
    if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
    count++;
    }
    }
    return count;
    }

    //+------------------------------------------------------------------+
    //| 平仓当前品种下所有属于该EA的订单 |
    //+------------------------------------------------------------------+
    void CloseAllOrders()
    {
    for(int i = OrdersTotal()-1; i >= 0; i--)
    {
    if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
    if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
    {
    if(OrderType() == OP_BUY)
    OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrNONE);
    else if(OrderType() == OP_SELL)
    OrderClose(OrderTicket(), OrderLots(), Ask, 3, clrNONE);
    }
    }
    }
    }
    //+------------------------------------------------------------------+
    `
    参考来源: 原创MQL4代码,仅供学习参考。
    免责声明: 外汇交易具有重大风险。本EA按“原样”提供,不保证盈利。实盘交易前请在模拟账户充分测试。历史表现不代表未来结果。
    ``