乐于分享
好东西不私藏

剥头皮ea源码分享:5 分钟周期双均线顺势单开仓,开单快,无测试,模拟用

剥头皮ea源码分享:5 分钟周期双均线顺势单开仓,开单快,无测试,模拟用
昨天给大家讲了为什么现在看不到剥头皮的策略了
今天周六,就必须响应一下,所以,分享一个均线玩法的顺势开单策略,开单确实很快哈,所以也可以叫剥头皮!
功能我就不介绍了,免费分享的ea,只能模拟哈,别上实盘,单纯就为了给大家试试功能玩法。

交易逻辑还是要讲一下的(5 分钟周期双均线顺势单开仓)

  1. 数据读取:固定读取M5 周期价格,两条简单均线 SMA
    • 均线 1:周期 5,MEDIAN 价格,偏移 1 根 K 线 
    • 均线 2:周期 4,MEDIAN 价格,偏移 1 根 K 线 
  2. 开仓条件(同一品种只允许持有 1 单,无持仓才开新单
    • 做多:当前收盘价 < 5 周期均线 → 开多单
    • 做空:当前收盘价 > 4 周期均线 → 开空单
  3. 止盈机制(固定点数止盈)
    • 多单止盈:入场价 + lTakeProfit(默认 40 点)
    • 空单止盈:入场价 - sTakeProfit(默认 40 点)
  4. 移动止损(多空分开独立追踪)
    • 多单追踪止损:盈利超过 20 点后,止损跟随现价锁定 20 点利润
    • 空单追踪止损:盈利超过 10 点后,止损跟随现价锁定 10 点利润
老规矩,直接要源码的:
源码:
*/extern double lTakeProfit = 40.0;extern double sTakeProfit = 40.0;extern double lTrailingStop = 20.0;extern double sTrailingStop = 10.0;extern color clOpenBuy = Blue;extern color clCloseBuy = Aqua;extern color clOpenSell = Red;extern color clCloseSell = Violet;extern color clModiBuy = Blue;extern color clModiSell = Red;extern string Name_Expert = "escape";extern int Slippage = 1;extern bool UseSound = TRUE;extern string NameFileSound = "Alert.wav";extern double Lots = 0.01;extern int bi = 2;void deinit() {   Comment("");}int start() {   if (Bars < 100) {      Print("bars less than 100");      return (0);   }   if (lTakeProfit < 1.0) {      Print("TakeProfit less than 1");      return (0);   }   if (sTakeProfit < 1.0) {      Print("TakeProfit less than 1");      return (0);   }   double l_iclose_0 = iClose(NULL, PERIOD_M5, 0);   double l_ima_8 = iMA(NULL, PERIOD_M5, 50, MODE_SMA, PRICE_MEDIAN, 1);   double l_iclose_16 = iClose(NULL, PERIOD_M5, 0);   double l_ima_24 = iMA(NULL, PERIOD_M5, 40, MODE_SMA, PRICE_MEDIAN, 1);   if (AccountFreeMargin() < 1000.0 * Lots) {      Print("We have no money. Free Margin = ", AccountFreeMargin());      return (0);   }   if (!ExistPositions()) {      if (l_iclose_0 < l_ima_8) {         OpenBuy();         return (0);      }      if (l_iclose_16 > l_ima_24) {         OpenSell();         return (0);      }   }   TrailingPositionsBuy(lTrailingStop);   TrailingPositionsSell(sTrailingStop);   return (0);}bool ExistPositions() {   for (int l_pos_0 = bi; l_pos_0 < OrdersTotal(); l_pos_0++) {      if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES))         if (OrderSymbol() == Symbol()) return (TRUE);   }   return (FALSE);}void TrailingPositionsBuy(int ai_0) {   for (int l_pos_4 = bi; l_pos_4 < OrdersTotal(); l_pos_4++) {      if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {         if (OrderSymbol() == Symbol()) {            if (OrderType() == OP_BUY) {               if (Bid - OrderOpenPrice() > ai_0 * Point)                  if (OrderStopLoss() < Bid - ai_0 * Point) ModifyStopLoss(Bid - ai_0 * Point);            }         }      }   }}void TrailingPositionsSell(int ai_0) {   for (int l_pos_4 = bi; l_pos_4 < OrdersTotal(); l_pos_4++) {      if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {         if (OrderSymbol() == Symbol()) {            if (OrderType() == OP_SELL) {               if (OrderOpenPrice() - Ask > ai_0 * Point)                  if (OrderStopLoss() > Ask + ai_0 * Point || OrderStopLoss() == 0.0) ModifyStopLoss(Ask + ai_0 * Point);            }         }      }   }}void ModifyStopLoss(double a_price_0) {   int l_bool_8 = OrderModify(OrderTicket(), OrderOpenPrice(), a_price_0, OrderTakeProfit(), 0, CLR_NONE);   if (l_bool_8 && UseSound) PlaySound(NameFileSound);}void OpenBuy() {   double l_lots_0 = GetSizeLot();   double l_price_8 = 0;   double l_price_16 = GetTakeProfitBuy();   string l_comment_24 = GetCommentForOrder();   OrderSend(Symbol(), OP_BUY, l_lots_0, Ask, Slippage, l_price_8, l_price_16, l_comment_24, 00, clOpenBuy);   if (UseSound) PlaySound(NameFileSound);}void OpenSell() {   double l_lots_0 = GetSizeLot();   double l_price_8 = 0;   double l_price_16 = GetTakeProfitSell();   string l_comment_24 = GetCommentForOrder();   OrderSend(Symbol(), OP_SELL, l_lots_0, Bid, Slippage, l_price_8, l_price_16, l_comment_24, 00, clOpenSell);   if (UseSound) PlaySound(NameFileSound);}string GetCommentForOrder() {   return (Name_Expert);}double GetSizeLot() {   return (Lots);}double GetTakeProfitBuy() {   return (Ask + lTakeProfit * Point);}double GetTakeProfitSell() {   return (Bid - sTakeProfit * Point);}