夜雨聆风学习资料网

ARTICLE · 1220618

辅助手单EA源码分享:支持设置平保和移动止损的简单辅助玩法.

辅助手单EA源码分享:支持设置平保和移动止损的简单辅助玩法.
HI,大家好
一款辅助的简单的EA,就不多介绍了,功能在配置参数里面就有了,非常简单,支持一键设置平保另外就是还有移动止损的功能。很适合手单的玩家。
直接上源码:
#property copyright "浪人微信:waihuipai"extern double 止损点数=0;extern double 止盈点数=0;extern bool 是否启用平保=true;extern double 平保点数=150;extern bool 是否启用移动止损=true;extern double 移动止损启动点数=250;extern double 移动止损点数=200;//+------------------------------------------------------------------+//| expert initialization function                                   |//+------------------------------------------------------------------+intinit()  {//----//----   return(0);  }//+------------------------------------------------------------------+//| expert deinitialization function                                 |//+------------------------------------------------------------------+intdeinit()  {//----//----   return(0);  }//+------------------------------------------------------------------+//| expert start function                                            |//+------------------------------------------------------------------+intstart()  {//----iDisplayInfo("banquan1", "拂晓映辉 QQ:964063050", 0, 6, 18, 12, "微软雅黑", Yellow); if(止损点数!=0) 修改止损();if(止盈点数!=0) 修改止盈();if(是否启用平保)平保();if(是否启用移动止损)移动止损(); //----   return(0);  }//+------------------------------------------------------------------+void 移动止损(){        for (int cnt=0;cnt<OrdersTotal();cnt++)        {           if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)==true)             {               if (OrderSymbol()==Symbol())                 {                                                          if (OrderType()==OP_BUY)                         {                       if(OrderClosePrice()>=OrderOpenPrice()+移动止损启动点数*Point)                          {                           if (OrderClosePrice()-OrderStopLoss()>Point*移动止损点数||OrderStopLoss()==0)                             {                                 bool chenggong=  OrderModify(OrderTicket(),OrderOpenPrice(),OrderClosePrice()-Point*移动止损点数,OrderTakeProfit(),0,CLR_NONE);                                if (chenggong)Print("单号:"+OrderTicket()+"移动止损成功");                                if(chenggong==false)Print("单号:"+OrderTicket()+"移动止损失败:"+GetLastError());                              }                          }                      }                   if (OrderType()==OP_SELL)                       {                          if(OrderClosePrice()<=OrderOpenPrice()-移动止损启动点数*Point)                             {                              if (OrderStopLoss()-OrderClosePrice()>Point*移动止损点数||OrderStopLoss()==0)                               chenggong=  OrderModify(OrderTicket(),OrderOpenPrice(),OrderClosePrice()+Point*移动止损点数,OrderTakeProfit(),0,CLR_NONE);                               if (chenggong)Print("单号:"+OrderTicket()+"移动止损成功");                               if(chenggong==false)Print("单号:"+OrderTicket()+"移动止损失败:"+GetLastError());                             }                       }                  }              }           } }void 平保(){    int cnt, total;    total=OrdersTotal();    for(cnt=total-1;cnt>=0;cnt--)     {          if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)==true)          {                        if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderStopLoss()<OrderOpenPrice() && Bid-OrderOpenPrice()>平保点数*Point)             {                 bool chenggong= OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green);                 if (chenggong)                   {                   Print("单号:"+OrderTicket()+"平保成功");                   }                 if(chenggong==false)                   {                   Print("单号:"+OrderTicket()+"平保失败:"+GetLastError());                   }             }             if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && (OrderStopLoss()>OrderOpenPrice()||OrderStopLoss()==0)&&OrderOpenPrice()-Ask>平保点数*Point)             {                 chenggong=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green);                 if (chenggong)                    {                    Print("单号:"+OrderTicket()+"平保成功");                    }                  if(chenggong==false)                    {                    Print("单号:"+OrderTicket()+"平保失败:"+GetLastError());                    }             }          }      }   }
另外就是,大家对什么样的EA有兴趣,主要是策略还是功能的,可以留言,后续可以多分享一些相关的EA源码!

相关学习资料