黄金交易策略(Nerve Nnife.mql4):做单手数设计

本文详细介绍了EANerveKnife.ex4的交易策略,涉及参数设定、复利计算以及开仓规则,如基于点差和趋势反转的开仓决策,适用于黄金交易。
摘要由CSDN通过智能技术生成

 完整EA:
Nerve Knife.ex4黄金交易策略_黄金趋势ea-CSDN博客

NK的做单量是由参数设定的,以下分别是参数项:

考虑到复利的情况,若10000本金,在以上三个参数的设计下,第1单的购买量是0.01*10,第2单是0.01*10*2,第3单是0.01*10*4...

对应的开单代码如下:

//跟踪点差是否满足开仓条件
         if (count == 0  && (TimeLocal() + End_Time_After_H*60*60) <= StrToTime(End_Time))//第一笔开仓
         {
            if(follow)//一定是m1_down同向
            {
                followPrice = followPrice < Bid ? Bid : followPrice;
                if(isDown(1, 0, HeikenAshiSmoothed) == UP || breakThrough("up", Ask)) //追踪开仓的过程中1分钟上行情反转或反向突破,即停止追踪
                  {
                   follow = false;
                   followPrice = 0;
                   nextOrderTime = TimeCurrent() + 60 * 1;//等待60秒
                   printfPro("反向突破等待" + (60 * 1) + "秒", false);
                  }
               
            }
            if (isDown(small_timeframe,offset,small_indicator) == DOWN && follow && (followPrice - Bid) / Point > order1_interval && TimeCurrent() > nextOrderTime)
            {
          
               OrderSend(Symbol(),OP_SELL,order1_lots * multiple,MarketInfo(Symbol(),MODE_BID),0,0,0,"1",888,0,clrGreen);
               printf("大小趋势相同买入空单1");
               count = 1;
               lastPrice = MarketInfo(Symbol(),MODE_BID);
               nextOrderTime = TimeCurrent() + open_time;
               follow = false;
               followPrice = 0;
            }
         }else if (count >= 1 && count < 5 )//第二到五笔开仓
         {

            //落差大于500点小趋势反过来,开始跟踪买入空单
            if  (isDown(small_timeframe,offset,small_indicator) == DOWN && !follow && (Bid - lastPrice) / Point > order2_5_trigger && TimeCurrent() > nextOrderTime)
            {
               follow = true;      
               followPrice = Bid;
            }
            if(follow)
              {
               followPrice = Bid > followPrice ? Bid : followPrice;
               if(isDown(1, 0, HeikenAshiSmoothed) == UP  || breakThrough("up", Ask)) //追踪开仓的过程中1分钟上行情反转,即停止追踪
                  {
                   follow = false;
                   followPrice = 0;
                   nextOrderTime = TimeCurrent() + 60 * 1;//等待60秒
                   printfPro("反向突破等待" + (60 * 1) + "秒", false);
                  }
              }
            if (isDown(small_timeframe,offset,small_indicator) == DOWN  && follow && (followPrice - Bid) / Point > order2_5_interval)//下降300点,买入
            {
               //买入空单
               count ++;
               double buyTotalLots = calcBuyOrSellTotalLots((int)((Bid - lastPrice) / Point / 2), 0);//计算买入量
               OrderSend(Symbol(),OP_SELL,buyTotalLots > (order2_5_lots * multiple * MathPow(2,count - 1)) ? order2_5_lots * multiple * MathPow(2,count - 1) : buyTotalLots,MarketInfo(Symbol(),MODE_BID),0,0,0,"" + count,888,0,clrGreen);
               
               printf("大小趋势相同买入空单" + count);
               lastPrice = MarketInfo(Symbol(),MODE_BID);
               nextOrderTime = TimeCurrent() + open_time;
               follow = false;
               followPrice = 0;
            }

         
         }

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值