下载MetaTrader 5

请观看如何免费下载自动交易

有趣的脚本?
因此发布一个链接 -
让其他人评价

喜欢这个脚本? 在MetaTrader 5客户端尝试它

EA

ADX 系统System - MetaTrader 5EA

| Chinese English Русский Español Deutsch 日本語 Português

发布者:
Vladimir Karputov
显示:
443
等级:
投票: 17
已发布:
2017.02.07 11:42
已更新:
2018.02.16 11:04

思路提供者 — CollectorMQL5 代码作者 — barabashkakvn

信号来自 iADX (平均方向移动指数) 指标。

基于 iADX 数值进行开仓和平仓的决策:

//+------------------------------------------------------------------+
//| 交易系统即时报价函数                                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double ADXP,ADXC,ADXDIPP;
   double ADXDIPC,ADXDIMP,ADXDIMC;

   ADXP = iADXGet(MAIN_LINE, 2);
   ADXC = iADXGet(MAIN_LINE, 1);
   ADXDIPP = iADXGet(PLUSDI_LINE, 2);
   ADXDIPC = iADXGet(PLUSDI_LINE, 1);
   ADXDIMP = iADXGet(MINUSDI_LINE, 2);
   ADXDIMC = iADXGet(MINUSDI_LINE, 1);

   int total=0;
   for(int i=PositionsTotal()-1;i>=0;i--) // 返回开仓数量
      if(m_position.SelectByIndex(i))
         if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
            total++;

   if(total==0)
     {
      //--- 未有开仓
      if(m_account.FreeMargin()<(1000*Lots))
        {
         Print("我们没钱了。可用保证金 = ",m_account.FreeMargin());
         return;
        }
      //--- 检查多头 (买入) 可能性
      if((ADXP<ADXC) && (ADXDIPP<ADXP) && (ADXDIPC>ADXC))
        {
         if(!RefreshRates())
            return;

         if(m_trade.Buy(Lots,m_symbol.Name(),m_symbol.Ask(),m_symbol.Bid()-ExtStopLoss*Point(),
            m_symbol.Ask()+ExtTakeProfit*Point(),"adx sample"))
           {
            Print("已买入 : ",m_trade.ResultPrice());
           }
         else
           {
            Print("买入错误。结果返回码: ",m_trade.ResultRetcode(),
                  ", 结果说明: ",m_trade.ResultRetcodeDescription(),
                  ", 成交单号: ",m_trade.ResultDeal());
            return;
           }
        }
      //--- 检查空头 (卖出) 可能性
      if((ADXP<ADXC) && (ADXDIMP<ADXP) && (ADXDIMC>ADXC))
        {
         if(!RefreshRates())
            return;

         if(m_trade.Sell(Lots,m_symbol.Name(),m_symbol.Bid(),m_symbol.Ask()+ExtStopLoss*Point(),
            m_symbol.Bid()-ExtTakeProfit*Point(),"adx sample"))
           {
            Print("已卖出 : ",m_trade.ResultPrice());
           }
         else
            Print("卖出错误。结果返回码: ",m_trade.ResultRetcode(),
                  ", 结果说明: ",m_trade.ResultRetcodeDescription(),
                  ", 成交单号: ",m_trade.ResultDeal());
         return;
        }
      return;
     }

   for(int i=PositionsTotal()-1;i>=0;i--) // 返回开仓数量
      if(m_position.SelectByIndex(i))
         if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
           {
            if(m_position.PositionType()==POSITION_TYPE_BUY) // 多头仓位已开
              {
               if(ADXP>ADXC && ADXDIPP>ADXP && ADXDIPC<ADXC)
                 {
                  m_trade.PositionClose(m_position.Ticket()); // 平仓
                  return; // 退出
                 }
               if(ExtTrailingStop>0)
                 {
                  if(!RefreshRates())
                     return;

                  if(m_symbol.Bid()-m_position.PriceOpen()>Point()*ExtTrailingStop)
                    {
                     if(m_position.StopLoss()<m_symbol.Bid()-Point()*ExtTrailingStop)
                       {
                        m_trade.PositionModify(m_position.Ticket(),m_symbol.Bid()-Point()*ExtTrailingStop,
                                               m_position.TakeProfit());
                        return;
                       }
                    }
                 }
              }
            else
              {
               if(ADXP>ADXC && ADXDIMP>ADXP && ADXDIMC<ADXC)
                 {
                  m_trade.PositionClose(m_position.Ticket()); // 平仓
                  return; // 退出
                 }
               if(ExtTrailingStop>0)
                 {
                  if(!RefreshRates())
                     return;

                  if((m_position.PriceOpen()-m_symbol.Ask())>(Point()*ExtTrailingStop))
                    {
                     if((m_position.StopLoss()>(m_symbol.Ask()+Point()*ExtTrailingStop)) ||
                        (m_position.StopLoss()==0))
                       {
                        m_trade.PositionModify(m_position.Ticket(),m_symbol.Ask()+Point()*ExtTrailingStop,
                                               m_position.TakeProfit());
                        return;
                       }
                    }
                 }
              }
           }
   return;
  }

结果 EURUSD M15, 自 2016.06.01 到 2016.11.24, 初始本金 - 10000:

ADX 系统测试器

本文译自 MetaQuotes Software Corp. 撰写的俄文原文
官方代码: https://www.mql5.com/ru/code/17030

Exp_Fractal_ADX_Cloud Exp_Fractal_ADX_Cloud

基于 Fractal_ADX_Cloud 指标 DI+ 和 DI 线交叉的交易系统。

Fractal_ADX_HTF Fractal_ADX_HTF

指标 Fractal_ADX 在输入参数中有时间帧选项。

TREND_alexcud v_2 TREND_alexcud v_2

EA 使用 15 个 iMA 指标和两个 iAC 指标。

10 点值 10 点值

点值 EA. 未使用指标。