Hello, can you set a variable for stop loss and take profit? Thanks!
This advisor was coined without stop loss and take profit.
Perhaps, when I want, it will be realized in ANOTHER advisor.
Hello, nice EA to open trade!
But for example later, we must close position manually, or by trailing?
metaangel :
Hello, nice EA to open trade!
But for example later, we must close position manually, or by trailing?
Positions are closed with an opposite signal: for example, a signal appeared to open BUY - then first we close the SELL positions and then we open the BUY.
Anyway you could add Money Management to this vs. using fixed lots?
Brian Sinclair :
Anyway you could add Money Management to this vs. using fixed lots?
Anyway you could add Money Management to this vs. using fixed lots?
Specify your question.
Brian Sinclair :
Anyway you could add Money Management to this vs. using fixed lots?
Anyway you could add Money Management to this vs. using fixed lots?
I released version 2: DoubleZigZag 2
New in version 2:
- Money management: Lot OR Risk - more in the section Position Size Management (lot calculation)
- The value for "Money management" - more in the section Position size management (lot calculation)
- Only one positions - there is always only one position in the market
- Reverse - a reversal of a trading signal
- Close opposite - closing positions opposite to the trading signal, and first there is a guaranteed closing of the opposite position and only then opening a new position in the signal direction
- There can only be one 'market entry' transaction on the bar (this is an internal parameter, it is not put out to the input parameters and this is not related to the ' Only one positions ' parameter).
Советники: DoubleZigZag 2
- 2020.02.08
- www.mql5.com
Статьи и техническая библиотека по автоматическому трейдингу: Советники: DoubleZigZag 2
//+------------------------------------------------------------------+ //|Hatorii_Total_Coverage.mq5 | //|Copyright 2026, MetaQuotes Ltd. | //| 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 (English menu [cite: 2025-12-23]) input group "=== Operational Settings ===" input ENUM_DIRECTION InpTradeMode = DIR_BOTH; // Address input double InpLot = 0.1; // Batch input int InpMagic = 882025; // Magic Number input group "=== FILTROS DE ESTRUCTURA (ZIGZAG) ===" input bool InpUseMacroZZ = true; // Use ZigZag X8 (Major Trend Filter) input bool InpSLatZZ = true; // Place exact SL in ZigZag Point [cite: 2026-01-02]. input group "=== FILTROS DE TENDENCIA (EMA) ===" input bool InpUseEMA = false; // Activate EMA Filter [cite: 2025-12-21]. input int InpEMAPeriod = 200; // Personalised EMA value [cite: 2025-12-21]. input group "=== RUTA DEL INDICADOR ===" input string InpIndiPath = "nuevos\\hf"; // Mandatory route [cite: 2025-12-24]. input int InpAmplitude = 2; // HalfTrend Amplitude //--- GLOBAL CTrade trade; int handleHT, handleEMA, handleZZ_Fast, handleZZ_Macro; datetime lastTradeTime = 0; //+------------------------------------------------------------------+ int OnInit() { //--- Initialise HalfTrend handleHT = iCustom(_Symbol, _Period, InpIndiPath, InpAmplitude); //--- Initialise EMA handleEMA = iMA(_Symbol, _Period, InpEMAPeriod, 0, MODE_EMA, PRICE_CLOSE); //--- Initialise ZigZags (Your corrected code inside 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 (If HF colour changes, close) GestionarCierres(trendHT); //--- 2. INPUT LOGIC BY BREAKING if(!PositionExists() && iTime(_Symbol, _Period, 0) != lastTradeTime) { double highPrev = iHigh(_Symbol, _Period, 1); double lowPrev = iLow(_Symbol, _Period, 1); // Filters bool emaBuyOK = !InpUseEMA || (ask > bufEMA[0]); bool emaSellOK = !InpUseEMA || (bid < bufEMA[0]); // ZigZag Macro Filter (Last line direction) bool macroBuyOK = true; bool macroSellOK = true; if(InpUseMacroZZ) { // Simplified logic: We check the direction of the last section of the ZigZag Macro. // (Here you could add more complex peak logic) } //--- BUY (Blue HF + Break of Previous High) 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); } } //--- SELL (Red HF + Break of Previous Low) 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); } } } } //--- Function to find the exact ZigZag point for the Stop Loss [cite: 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; }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
DoubleZigZag:
Two ZigZag indicators are used for analysis.
Author: Vladimir Karputov