EaCode小胖李 发表于 2022-12-26 18:24:00

TrailStopLoss4()4阶移动止损,可以分4级设置移动止损

函数名称
void TrailStopLoss4(int TrailSLStartX1,int TrailSLX1,int TrailSLStartX2,int TrailSLX2,int TrailSLStartX3,int TrailSLX3,int TrailSLStartX4,int TrailSLX4,int MagicX)
函数介绍

TrailStopLoss4()可以分4级,对所有的订单设置移动止损。当订单盈利达到TrailSLStartX1,移动止损为TrailSLX1;当订单盈利达到TrailSLStartX2,移动止损为TrailSLX2;当订单盈利达到TrailSLStartX3,移动止损为TrailSLX3;当订单盈利达到TrailSLStartX4,移动止损为TrailSLX4;
//举例:打印出当前所有多单的平均成本价格。
Print(CostPrice(Symbol(),OP_BUY,MAGIC));

参数介绍

TrailSLStartX1:订单盈利达到此点数1
TrailSLX1:移动止损点数1
TrailSLStartX2:订单盈利达到此点数2
TrailSLX2:移动止损点数2
TrailSLStartX3:订单盈利达到此点数3
TrailSLX3:移动止损点数3
TrailSLStartX4:订单盈利达到此点数4
TrailSLX4:移动止损点数4
MagicX:订单的魔术码,你的EA的魔术码是多少,这里填上即可。

函数定义

注意:本人发布的函数均为实战开发所用,低价或免费发布并不赚钱,仅限懂编程的朋友使用,不提供指导,因为人工成本巨贵,感谢朋友们海涵。void TrailStopLoss4(int TrailSLStartX1,int TrailSLX1,int TrailSLStartX2,int TrailSLX2,int TrailSLStartX3,int TrailSLX3,int TrailSLStartX4,int TrailSLX4,int MagicX)
{
      for(int i=OrdersTotal()-1; i>=0; i--)
      {
         if(OrderSelect(i,SELECT_BY_POS))
            if(OrderMagicNumber()==MagicX)
            {
               if(OrderType()==OP_SELL)
               {

                  if(OrderOpenPrice()-Ask>TrailSLStartX4*Point && TrailSLStartX4>0)
                  {
                     if(Ask+TrailSLX4*Point<OrderStopLoss())
                        if(!OrderModify(OrderTicket(),0,Ask+TrailSLX4*Point,OrderTakeProfit(),0,Yellow))
                           Print("OrderModify Error!",GetLastError());
                  }
                  else
                     if(OrderOpenPrice()-Ask>TrailSLStartX3*Point && TrailSLStartX3>0)
                     {
                        if(Ask+TrailSLX3*Point<OrderStopLoss())
                           if(!OrderModify(OrderTicket(),0,Ask+TrailSLX3*Point,OrderTakeProfit(),0,Yellow))
                              Print("OrderModify Error!",GetLastError());
                     }
                     else
                        if(OrderOpenPrice()-Ask>TrailSLStartX2*Point && TrailSLStartX2>0)
                        {
                           if(Ask+TrailSLX2*Point<OrderStopLoss())
                              if(!OrderModify(OrderTicket(),0,Ask+TrailSLX2*Point,OrderTakeProfit(),0,Yellow))
                                 Print("OrderModify Error!",GetLastError());
                        }
                        else
                           if(OrderOpenPrice()-Ask>TrailSLStartX1*Point && TrailSLStartX1>0)
                           {
                              if(Ask+TrailSLX1*Point<OrderStopLoss())
                                 if(!OrderModify(OrderTicket(),0,Ask+TrailSLX1*Point,OrderTakeProfit(),0,Yellow))
                                    Print("OrderModify Error!",GetLastError());
                           }

               }

               else
                  if(OrderType()==OP_BUY)
                  {
                     if(Bid-OrderOpenPrice()>TrailSLStartX4*Point && TrailSLStartX4>0)
                     {
                        if(Bid-TrailSLX4*Point>OrderStopLoss())
                           if(!OrderModify(OrderTicket(),0,Bid-TrailSLX4*Point,OrderTakeProfit(),0,Yellow))
                              Print("OrderModify Error!",GetLastError());
                     }
                     else
                        if(Bid-OrderOpenPrice()>TrailSLStartX3*Point && TrailSLStartX3>0)
                        {
                           if(Bid-TrailSLX3*Point>OrderStopLoss())
                              if(!OrderModify(OrderTicket(),0,Bid-TrailSLX3*Point,OrderTakeProfit(),0,Yellow))
                                 Print("OrderModify Error!",GetLastError());

                        }
                        else
                           if(Bid-OrderOpenPrice()>TrailSLStartX2*Point && TrailSLStartX2>0)
                           {
                              if(Bid-TrailSLX2*Point>OrderStopLoss())
                                 if(!OrderModify(OrderTicket(),0,Bid-TrailSLX2*Point,OrderTakeProfit(),0,Yellow))
                                    Print("OrderModify Error!",GetLastError());
                           }
                           else
                              if(Bid-OrderOpenPrice()>TrailSLStartX1*Point && TrailSLStartX1>0)

                              {
                                 if(Bid-TrailSLX1*Point>OrderStopLoss())
                                    if(!OrderModify(OrderTicket(),0,Bid-TrailSLX1*Point,OrderTakeProfit(),0,Yellow))
                                       Print("OrderModify Error!",GetLastError());
                              }
                  }
            }
      }
}










193578 发表于 2022-12-26 18:41:42

可以分4级设置移动止损

a451780267 发表于 2022-12-27 00:03:59

[糗]把一个程序拆开刷流量这个网站没人管理了吗?

18198000989 发表于 2023-1-19 19:36:09

这么黑吗,分开赚钱

dongxu64 发表于 2023-1-22 23:06:18

挺贵的函数

ken138888 发表于 2023-2-3 06:06:18

很实用的功能

痴墨鼠 发表于 2023-4-9 22:35:56

还是很有想法和思路的

翠翠6666 发表于 2023-4-16 07:00:26

不错,想法很好

zhenjin 发表于 2023-4-16 09:12:53

楼主发财 谢谢分享

kenlee1628 发表于 2023-4-27 18:29:14

拓宽思路

tststs 发表于 2023-5-18 23:42:57

支持发布

tt17538929361 发表于 2023-5-20 00:16:55

支持,详细介绍下啊

ken138888 发表于 2023-6-2 06:10:19

可以写个mt5的吗

sunyu007 发表于 2023-7-19 18:46:55

这个可以有

qwe11 发表于 2023-7-24 21:01:52

什么意思

石头1968 发表于 2023-7-25 01:41:39

牛逼的编程工程师!

ken138888 发表于 2023-8-6 13:28:14

这个是止盈还是止损

Comprocess 发表于 2023-11-23 11:04:10

这个实战起来不知道会怎么样?

aliang9887 发表于 2023-12-11 06:45:18

这个真是太好了

ken138888 发表于 2023-12-12 05:53:43

谢谢分享
页: [1] 2
查看完整版本: TrailStopLoss4()4阶移动止损,可以分4级设置移动止损