ARTICLE · 1179114
订单风控管家EA源码分享:自动给单子加止损、止盈、平保、移动止损
订单风控管家EA源码分享:自动给单子加止损、止盈、平保、移动止损HI,大家好 今天分析一个辅助的EA软件的源码
这是一款轻量化 MT4 持仓风控辅助 EA,主打保本保护 + 分段移动追踪止损,优点是逻辑简单上手快;最大硬伤是缺少魔术号过滤、平保与移动止损同时开启会互相争夺修改止损,适合手动交易者做持仓保护,不建议不加修改直接实盘多 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());}}}}}















































































