无厘头 发表于 2016-10-27 17:23:26

任意货币对自动添加止损和平包

1. 在任意一个k线窗口运行,对所有挂单和持仓单有效
2. 如果发现未设置止损,则添加止损。
3.如果浮盈超过一定点数,自动平保。
4. 手动调整止损后本ea不再起作用

参数:   1. 平保点数
            2. 止损点数
            3. 止盈点数

//+------------------------------------------------------------------+
//|                                                   MoveEven.mq4 |
//|                     Copyright ?2011, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2011, MetaQuotes Software Corp."

extern int PointWin = 50;
extern int TakeProfit = 200;
extern int StopLoss = 35;
int      PointScale = 10; //在5位小数点报价平台为10,在4位小数点报价平台为1
//+------------------------------------------------------------------+
//| expert initialization function                                 |
//+------------------------------------------------------------------+
int init()
{
//----
//----
   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
   return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                          |
//+------------------------------------------------------------------+
int start()
{
//----
//调整止损
if(OrdersTotal()>0)
{
   ChangeStopLoss();
}   
//----
   return(0);
}

   void ChangeStopLoss ()
{
    int i;

    for(i = OrdersTotal()-1; i>=0; i--)
    {
       OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
       int tick = OrderTicket();
       double point = MarketInfo(OrderSymbol(), MODE_POINT);
       if((OrderType()==OP_BUY )|| (OrderType()==OP_BUYLIMIT))
       {
         if(OrderStopLoss()== 0)
         {
            if(OrderModify(tick, OrderOpenPrice(), (OrderOpenPrice()- StopLoss*PointScale*point), (OrderOpenPrice()+ TakeProfit*PointScale*point ),0, Red))
            {
               Print("++++++++++Currency pair: ", Symbol(), "Add StopLoss to ticket: ", tick, " successfully!!!");
               Sleep(5000);
               }
         }
         else if( (Bid > (OrderOpenPrice()+PointWin*PointScale*point))&&(OrderStopLoss()<OrderOpenPrice()) && (OrderType()==OP_BUY ) )
         {
            if(OrderModify(tick, OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(),0, Red))
            {
               Print("*********Currency pair: ", OrderSymbol(), "MoveEvento ticket: ", tick, " successfully!!!");
               Sleep(5000);
            }
         }
      } else
      if((OrderType() == OP_SELL) || (OrderType() == OP_SELLLIMIT))
      {
         if(OrderStopLoss()== 0)
         {
            if(OrderModify(tick, OrderOpenPrice(), (OrderOpenPrice()+ StopLoss*PointScale*point), (OrderOpenPrice()- TakeProfit*PointScale*point ),0, Red))
            {
               Print("++++++++++Currency pair: ", OrderSymbol(), "Add StopLoss to ticket: ", tick, " successfully!!!");
               Sleep(5000);
            }
         }
         else if( (Ask < (OrderOpenPrice()-PointWin*PointScale*point )) && (OrderStopLoss()>OrderOpenPrice()) && (OrderType() == OP_SELL))
         {
            if(OrderModify(tick, OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(),0, Red))
            {
               Print("*********Currency pair: ", OrderSymbol(), "MoveEvento ticket: ", tick, " successfully!!!");
               Sleep(5000);
            }
         }
      }
    }
}

//+------------------------------------------------------------------+



wcwfnsse 发表于 2017-4-8 15:51:36

5555555555555

灌灌灌灌 发表于 2018-3-19 22:52:45

66666666666666666666666666

粉红色的信笺 发表于 2020-2-26 21:03:27

:lol不错

我爱迩 发表于 2020-7-10 18:10:52

学习了,不错

等你两世 发表于 2020-8-14 21:31:23

谢谢楼主分享

sunnyhaolang 发表于 2020-8-14 22:48:56

这个可以有

pkvszl 发表于 2020-9-8 12:44:47

谢谢楼主分享

asdfwer94 发表于 2020-11-25 10:00:39

支持下

lining777 发表于 2021-6-24 18:21:44

怎么下载呢?
页: [1] 2
查看完整版本: 任意货币对自动添加止损和平包