完整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;}}