studyea 发表于 2021-6-7 17:59:00

【漆学军】分享我自用多年的马丁策略EA完整源码及参数(winkey),曾半年将我账户翻3倍

马丁策略一直都是具有很大争议的,因为有太多的人使用这个策略爆仓了,但是依然有人使用这个赚钱了。那些使用这个策略爆仓了的人会认为马丁策略不行,是垃圾,我是不同意这种说法的。
比如说过马路有人被车撞死了,你是要取消马路,还是要取消汽车呢?吃饭有人被噎死了,那就不要在吃饭了吗?
正因为上面问题的答案都是不能,所以我们也不能说马丁策略是垃圾策略。

天下大势,分久必合,合久必分。外汇行情,涨久必跌,跌久必涨。
万事万物无不遵从这种因果循环的规律。
就像正弦曲线图一样,上下上下周而复始,循环往复。

而马丁策略正是适合这种波动形状的震荡行情。如果行情只上涨不下跌,或者只下跌不上涨,那么使用马丁策略是不适合的。
为什么大多数人使用马丁策略会亏损?是因为太贪婪了。
打个比方,EURUSD,一波行情波动个100点不回头是很常见的,但是有些人10000美金账户,0.1手起步,每隔10个点就加仓,而且加仓手数是直接翻倍为0.2手,0.4手,0.8手,1.6手。。。,这么做,盈利起来自然是很快,但是账户很可能抗不过100点就会显示资金不够用,无法下更多的单子,最终导致账户很快爆仓。
如果能够想到办法降低预期盈利,那么也就大大降低了风险。
有两种方法可做到:加大加仓间隔,每隔60点到600点加仓。
减少加仓手数倍数,交易手数不要每次直接2倍往上翻,可以设定每次的手数是前一次单子手数的1.5倍即可。
使用了低风险的马丁策略之后,盈利的时间就变得越来越长了,虽然盈利并不多,但是在长时间积累之后,实际的盈利率其实并不低。

这款EA是我在2011年开发的,命名为Winkey,意为盈利的密码,今天稍加了修改,只是为了适应当前的MT4平台。当年测试这个EA的时候,我用了一个500美金的真实账户,半年账户做到了1800美金,当时用的参数加仓间隔是60点,加仓手数倍数是1.2倍。这就是我使用马丁策略盈利的经验,分享给大家。
EA程序完整源码如下,可复制粘贴过去使用,但是请注意参数做成了数组,需要在数组里面直接修改加仓间隔和加仓手数倍数:(截图为部分代码,截图下面是全部完整的winkey代码,200行左右。)
全部源码如下://+------------------------------------------------------------------+
//|                                                       Winkey.mq4 |
//|                              Copyright @2021, 80364276@qq.com|
//|                                          http://www.study-ea.com |
//+------------------------------------------------------------------+
//去掉了全局变量设置。
//去掉了加仓方案设置,加仓方案按照数组里面设置。
//增加了停止开新仓的设置,意思是当前一波结束了不再下单。
//ea运行途中可随时设置参数,不会影响运行效果。
//-------------------------------------------------------------------
#property copyright "Copyright @2011, 80364276@qq.com "
#property link      "http://www.study-ea.com"
#property version   "1.00"
#property description "间隔:0, 20,20,15,15,20,20,30。"
#property description "倍率:1, 2, 1, 2, 1, 3, 2, 4。"
#property description "最大交易量5手,大于5手不开仓。"
#property strict
//-------------------------------------------------------------------
input int Magic=1800; //魔术码
input bool IsStop=false; //当前一波结束是否停止
input double lots=0.01; //初始手数
//-加仓时的间隔点数,数组从0开始
int Interval_Pips= {0, 20,20,15,15,20,20,30};
//-加仓时的交易量倍数
int Interval_Lots= {1, 2, 1, 2, 1, 3, 2, 4};
int slippage=3;
input int TP=300; //止盈点数
input int SL=2000;//止损点数
//止损点数为第一单的止损点数计算出来的价格作为每一单的止损价。加仓的时候会考虑下单价格距离止损价太近就不加仓。
string comt="WinKey->";
int i,db=1;
int Digitslots;
//+------------------------------------------------------------------+
//| expert initialization function                                 |
//+------------------------------------------------------------------+
int OnInit()
{
//----
   double minlot=MarketInfo(Symbol(),MODE_MINLOT);
   if(minlot==0.001) Digitslots=3;
   if(minlot==0.01) Digitslots=2;
   if(minlot==0.1) Digitslots=1;

   if(MarketInfo(Symbol(),MODE_DIGITS)==5 || MarketInfo(Symbol(),MODE_DIGITS)==3)
   {
      Print("五位小数平台.");
      db=10;
   }
   else   Print("四位小数平台.");
//----
   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//----
   Comment("");
//----
   return;
}
//+------------------------------------------------------------------+
//| expert start function                                          |
//+------------------------------------------------------------------+
void OnTick()
{
//----
   int buys=0,sells=0,signal=0;
   int result=0;
   double LastBuyPrice=0,LastSellPrice=0,SLp=0,TPp=0;
   double top=0,tol=0,avp=0;
//----统计
   for(i=0; i<=OrdersTotal()-1; i++)
   {
      result=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
      {
         if(OrderType()==OP_BUY)
         {
            buys++;
            LastBuyPrice=OrderOpenPrice();
            tol=tol+OrderLots();
            top=top+OrderLots()*OrderOpenPrice();
            if(SLp==0 && SL>0) SLp=OrderOpenPrice()-SL*db*Point;
         }
         if(OrderType()==OP_SELL)
         {
            sells++;
            LastSellPrice=OrderOpenPrice();
            tol=tol+OrderLots();
            top=top+OrderLots()*OrderOpenPrice();
            if(SLp==0 && SL>0) SLp=OrderOpenPrice()+SL*db*Point;
         }
      }
   }
   if(tol>0)
   {
      avp=NormalizeDouble(top/tol,Digits);
      if(buys>0) TPp=avp+TP*db*Point;
      if(sells>0) TPp=avp-TP*db*Point;
   }
//----显示信息---
   int ti;
   if(buys>0) ti=buys;
   else ti=sells;
   string dsy="\nWinKey\n";
   dsy=dsy+"===================\n";
   dsy=dsy+"P.Lots             ="+DoubleToStr(NormalizeDouble(lots,Digitslots),Digitslots)    +"\n";
   dsy=dsy+"P.SL               ="+IntegerToString(SL)    +"\n";
   dsy=dsy+"P.TP            ="+IntegerToString(TP)    +"\n";
   dsy=dsy+"P.MAGIC       ="+IntegerToString(Magic)    +"\n";
   dsy=dsy+"===================\n";
   dsy=dsy+"B.Numbers      ="+IntegerToString(buys)    +"\n";
   dsy=dsy+"S.Numbers      ="+IntegerToString(sells)   +"\n";
   dsy=dsy+"LastB.Price      ="+DoubleToStr(LastBuyPrice,Digits)+"\n";
   dsy=dsy+"LastS.Price      ="+DoubleToStr(LastSellPrice,Digits)+"\n";
   dsy=dsy+"SL.Price          ="+DoubleToStr(SLp,Digits)+"\n";
   dsy=dsy+"TP.Price         ="+DoubleToStr(TPp,Digits)+"\n";
   dsy=dsy+"NEXT.Lots      ="+DoubleToStr(NormalizeDouble(Interval_Lots*lots,Digitslots),Digitslots)    +"\n";
   dsy=dsy+"NEXT.Pips      ="+IntegerToString(Interval_Pips)    +"\n";
   dsy=dsy+"===================\n";
   Comment(dsy);
//----修改订单
   for(i=0; i<=OrdersTotal()-1; i++)
   {
      result=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
      {
         if(OrderType()==OP_BUY)
         {
            if(SLp>0 && DoubleToStr(OrderStopLoss(),Digits)!=DoubleToStr(SLp,Digits))
            {
               result=OrderModify(OrderTicket(),OrderOpenPrice(),SLp,OrderTakeProfit(),0,Green);
               if(result<0) Print("BUY 止损修改出错"+DoubleToStr(OrderStopLoss(),Digits)+"-->"+DoubleToStr(SLp,Digits));
               else return;
            }
            if(TPp>0 && DoubleToStr(OrderTakeProfit(),Digits)!=DoubleToStr(TPp,Digits))
            {
               result=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),TPp,0,Green);
               if(result<0) Print("BUY 止盈修改出错"+DoubleToStr(OrderTakeProfit(),Digits)+"-->"+DoubleToStr(TPp,Digits));
               else return;
            }
         }
         if(OrderType()==OP_SELL)
         {
            if(SLp>0 && DoubleToStr(OrderStopLoss(),Digits)!=DoubleToStr(SLp,Digits))
            {
               result=OrderModify(OrderTicket(),OrderOpenPrice(),SLp,OrderTakeProfit(),0,Red);
               if(result<0) Print("SELL 止损修改出错"+DoubleToStr(OrderStopLoss(),Digits)+"-->"+DoubleToStr(SLp,Digits));
               else return;
            }
            if(TPp>0 && DoubleToStr(OrderTakeProfit(),Digits)!=DoubleToStr(TPp,Digits))
            {
               result=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),TPp,0,Red);
               if(result<0) Print("SELL 止盈修改出错"+DoubleToStr(OrderTakeProfit(),Digits)+"-->"+DoubleToStr(TPp,Digits));
               else return;
            }
         }
      }
   }
//--------------------------------------------------
//第一单
   if(buys+sells==0 && IsStop==false)
   {
      signal=signal();
      if(signal==1 && NormalizeDouble(lots*Interval_Lots,Digitslots)<=5)
         result=OrderSend(Symbol(), OP_BUY, NormalizeDouble(lots*Interval_Lots,Digitslots), Ask, slippage*db, 0, 0, comt+"0", Magic, 0, Green);
      if(signal==-1 && NormalizeDouble(lots*Interval_Lots,Digitslots)<=5)
         result=OrderSend(Symbol(), OP_SELL, NormalizeDouble(lots*Interval_Lots,Digitslots), Bid, slippage*db, 0, 0, comt+"0", Magic, 0, Red);
      return;
   }
//----
   if(buys==0 && sells>0 && NormalizeDouble(lots*Interval_Lots,Digitslots)<=5)
   {
      if(Bid-LastSellPrice>=Interval_Pips*db*Point && TimeCurrent()-Time<60 && SLp-Bid>Interval_Pips*db*Point)
      {
         result=OrderSend(Symbol(),OP_SELL,NormalizeDouble(lots*Interval_Lots,Digitslots),Bid,slippage*db,0,0,comt+IntegerToString(sells),Magic,0,Red);
         return;
      }
   }
   if(buys>0 && sells==0 && NormalizeDouble(lots*Interval_Lots,Digitslots)<=5)
   {
      if(LastBuyPrice-Ask>=Interval_Pips*db*Point && TimeCurrent()-Time<60 && Ask-SLp>Interval_Pips*db*Point)
      {
         result=OrderSend(Symbol(),OP_BUY,NormalizeDouble(lots*Interval_Lots,Digitslots),Ask,slippage*db,0,0,comt+IntegerToString(buys),Magic,0,Green);
         return;
      }
   }
//----
   return;
}
//+------------------------------------------------------------------+
int signal()
{
   int res;
   if(Close<Open) res=-1;
   else res=1;
   return(res);
}
//+------------------------------------------------------------------+

daerwushen 发表于 2021-6-10 18:56:21

谢谢分享

Leonjo 发表于 2021-6-10 19:08:56

感謝分享資訊

zjfzjf2 发表于 2021-6-10 23:36:38

谢谢分享

漢聲山峰 发表于 2021-6-11 14:18:09

謝謝分享

巴比伦雄鹰 发表于 2021-6-11 15:36:58

感谢分享

hao 发表于 2021-6-21 13:09:16

谢谢分享。

erwinlyj 发表于 2021-7-2 19:21:58

谢谢分享。

如鱼得水 发表于 2021-7-4 10:33:05

学习学习

daerbushen 发表于 2021-7-4 14:13:34

謝謝分享

罪恶小兵 发表于 2021-7-6 11:25:10

謝謝分享

kcen 发表于 2021-7-6 12:01:27

感谢分享

whyast123 发表于 2021-7-7 13:25:50

非常不错 谢谢分享

yuiran 发表于 2021-7-7 13:35:53

非常感谢

yifu0821 发表于 2021-7-8 01:30:17

感謝分享資訊

xly68130 发表于 2021-7-17 23:02:35

非常不错 谢谢分享

cgd998 发表于 2021-7-18 09:07:55

你太牛叉了,谢谢分享

tianping 发表于 2021-7-18 11:39:12

谢谢分享

daerwushen 发表于 2021-7-18 15:15:04

感谢分享

daerbushen 发表于 2021-7-19 14:10:17

谢谢分享
页: [1] 2 3 4 5 6 7 8
查看完整版本: 【漆学军】分享我自用多年的马丁策略EA完整源码及参数(winkey),曾半年将我账户翻3倍