您好,开仓交易的 EA 很不错!
但是,举例来说,我们必须手动平仓,还是通过追踪平仓?
Brian Sinclair :
与使用固定手数相比,您是否可以添加资金管理功能?
与使用固定手数相比,您是否可以添加资金管理功能?
请具体说明您的问题。
Brian Sinclair :
与使用固定手数相比,您是否可以添加资金管理功能?
与使用固定手数相比,您是否可以添加资金管理功能?
我发布了第 2 版:DoubleZigZag 2
第 2 版的新功能:
- 资金管理:手数或风险- 更多内容请参阅 "头寸大小管理(手数计算)"部分。
- 资金管理 "的值- 更多内容请参阅 "头寸大小管理(手数计算)"部分
- 只有一个仓位- 市场上始终只有一个仓位
- 反转- 交易信号的反转
- 反向平仓- 关闭与交易信号相反的仓位,首先保证关闭相反的仓位,然后才按信号方向开立新仓位
- 在条形图上只能有一个 "市场进入 "交易(这是一个内部参数,不会输出到输入参数中,也与 "只有一个仓位"参数无关)。
Советники: DoubleZigZag 2
- 2020.02.08
- www.mql5.com
Статьи и техническая библиотека по автоматическому трейдингу: Советники: DoubleZigZag 2
//+------------------------------------------------------------------+ //|Hatorii_Total_Coverage.mq5 //|2026年,MetaQuotes有限公司版权所有。| //| pro system: double zigzag + break + sl in zigzag point | //| pro system: double zigzag + break + sl in zigzag point | //... //+------------------------------------------------------------------+ #property copyright "Copyright 2026" #property version "1.50" #property strict #include <Trade\Trade.mqh> //--- ENUMS enum ENUM_DIRECTION { DIR_BOTH = 0, DIR_ONLY_BUY = 1, DIR_ONLY_SELL = 2 }; //--- INPUTS(英文菜单 [引用日期:2025-12-23) input group "=== 运行配置 ===" input ENUM_DIRECTION InpTradeMode = DIR_BOTH; // 地址 input double InpLot = 0.1; // 批量 input int InpMagic = 882025; // 神奇数字 input group "=== FILTROS DE ESTRUCTURA (ZIGZAG) ===" input bool InpUseMacroZZ = true; // 使用 ZigZag X8(主要趋势过滤器) input bool InpSLatZZ = true; // 将精确 SL 置于 ZigZag 点[引用日期:2026-01-02]。 input group "=== FILTROS DE TENDENCIA (EMA) ===" input bool InpUseEMA = false; // 激活 EMA 过滤器[引用日期:2025-12-21]。 input int InpEMAPeriod = 200; // 个性化 EMA 价值[引用日期:2025-12-21]. input group "=== RUTA DEL INDICADOR ===" input string InpIndiPath = "nuevos\\hf"; // 必经之路[引用日期:2025-12-24]。 input int InpAmplitude = 2; // 半趋势振幅 //--- 全球 CTrade trade; int handleHT, handleEMA, handleZZ_Fast, handleZZ_Macro; datetime lastTradeTime = 0; //+------------------------------------------------------------------+ int OnInit() { //--- 初始化 HalfTrend handleHT = iCustom(_Symbol, _Period, InpIndiPath, InpAmplitude); //--- 初始化 EMA handleEMA = iMA(_Symbol, _Period, InpEMAPeriod, 0, MODE_EMA, PRICE_CLOSE); //--- 初始化 ZigZags(您在 OnInit 内更正的代码) handleZZ_Fast = iCustom(_Symbol, _Period, "Examples\\ZigZag", 13, 5, 3); handleZZ_Macro = iCustom(_Symbol, _Period, "Examples\\ZigZag", 13*8, 5*8, 3*8); if(handleHT == INVALID_HANDLE || handleZZ_Fast == INVALID_HANDLE || handleZZ_Macro == INVALID_HANDLE) { Alert("Error al cargar indicadores. Revisa la ruta: ", InpIndiPath); return(INIT_FAILED); } trade.SetExpertMagicNumber(InpMagic); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ void OnTick() { double bufHT[], bufEMA[], bufMacroZZ[]; ArraySetAsSeries(bufHT, true); ArraySetAsSeries(bufEMA, true); ArraySetAsSeries(bufMacroZZ, true); if(CopyBuffer(handleHT, 7, 0, 1, bufHT) < 1) return; if(CopyBuffer(handleEMA, 0, 0, 1, bufEMA) < 1) return; if(CopyBuffer(handleZZ_Macro, 0, 0, 2, bufMacroZZ) < 1) return; double trendHT = bufHT[0]; double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID); //--- 1. AGGRESSIVE CLOSE(如果高频颜色发生变化,则关闭) 2. GestionarCierres(trendHT); //--- 2. if(!PositionExists() && iTime(_Symbol, _Period, 0) != lastTradeTime) { double highPrev = iHigh(_Symbol, _Period, 1); double lowPrev = iLow(_Symbol, _Period, 1); // 过滤器 bool emaBuyOK = !InpUseEMA || (ask > bufEMA[0]); bool emaSellOK = !InpUseEMA || (bid < bufEMA[0]); // 之字形宏滤波器(最后一行方向) bool macroBuyOK = true; bool macroSellOK = true; if(InpUseMacroZZ) { // 简化逻辑:我们检查之字形宏最后一段的方向。 // (这里可以添加更复杂的峰值逻辑) } //--- 买入(蓝色高频 + 突破前期高点) if(trendHT == 0.0 && InpTradeMode != DIR_ONLY_SELL && emaBuyOK && macroBuyOK) { if(ask > highPrev) { double sl = InpSLatZZ ? BuscarUltimoPuntoZZ(false) : 0; if(trade.Buy(InpLot, _Symbol, ask, sl, 0, "Ruptura + ZZ SL")) lastTradeTime = iTime(_Symbol, _Period, 0); } } //--- 卖出(红色高频 + 突破前低) if(trendHT == 1.0 && InpTradeMode != DIR_ONLY_BUY && emaSellOK && macroSellOK) { if(bid < lowPrev) { double sl = InpSLatZZ ? BuscarUltimoPuntoZZ(true) : 0; if(trade.Sell(InpLot, _Symbol, bid, sl, 0, "Ruptura + ZZ SL")) lastTradeTime = iTime(_Symbol, _Period, 0); } } } } //--- 用于查找止损点的 ZigZag 精确点的函数 [引用日期: 2026-01-02]。 double BuscarUltimoPuntoZZ(bool buscarAlto) { double zzVal[]; ArraySetAsSeries(zzVal, true); for(int i=1; i<100; i++) { if(CopyBuffer(handleZZ_Fast, 0, i, 1, zzVal) > 0) { if(zzVal[0] > 0) return zzVal[0]; } } return 0; } void GestionarCierres(double trend) { for(int i=PositionsTotal()-1; i>=0; i--) { ulong ticket = PositionGetTicket(i); if(PositionSelectByTicket(ticket) && PositionGetInteger(POSITION_MAGIC) == InpMagic) { if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY && trend == 1.0) trade.PositionClose(ticket); if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL && trend == 0.0) trade.PositionClose(ticket); } } } bool PositionExists() { for(int i=PositionsTotal()-1; i>=0; i--) { if(PositionSelectByTicket(PositionGetTicket(i))) { if(PositionGetInteger(POSITION_MAGIC) == InpMagic && PositionGetString(POSITION_SYMBOL) == _Symbol) return true; } } return false; }
DoubleZigZag:
用于分析的两个之字转向指标。
作者: Vladimir Karputov