Fix this custom Zigzag indicator (on an oscillator + counter)

Tarea técnica

A zig-zag NRP close is applied to an oscillator.

On this, a counter is added, to keep track of the number of bars since the last "zag" (that does not repaint). The counter adds 0 for a counter-trend bar, and 1 for a trend bar. So when in a rising segment, you have a small counter-trend down-swing, the counter is flat. If after this counter-trend down-swing the trend goes back up, and a new high is made, the counter takes the value as if there would not have been a counter-trend piece (like only rising bars). (& vice versa for falling segment).

Every trend change starts with a retracement against the current trend, so the counter will be flat during this time, but when the trend goes further (than an acceptable retracement as in the setting for the zigzag), a new leg of the zig zag is created. 

The problem with the current code, is that at that moment (when a new leg of the zigzag close nrp on the oscillator appears), the counter jumps back to the start of the retracement (of the flat part), instead of the end of the flat part. 

So it is not a repainting error, it is a code error.

I refer to the image below: the Aqua colored line is how the counter jumps back, while the red line is how it should be.

I'm happy to answer any questions.


example_eurusd_visual_backtest.png


Archivos adjuntos:

Han respondido

1
Desarrollador 1
Evaluación
(6)
Proyectos
8
25%
Arbitraje
2
50% / 0%
Caducado
2
25%
Libre
2
Desarrollador 2
Evaluación
(19)
Proyectos
22
23%
Arbitraje
5
40% / 60%
Caducado
2
9%
Trabaja
3
Desarrollador 3
Evaluación
(16)
Proyectos
35
23%
Arbitraje
4
0% / 50%
Caducado
2
6%
Trabaja
4
Desarrollador 4
Evaluación
(55)
Proyectos
66
58%
Arbitraje
1
0% / 0%
Caducado
0
Libre
5
Desarrollador 5
Evaluación
(9)
Proyectos
19
16%
Arbitraje
3
67% / 0%
Caducado
0
Libre
6
Desarrollador 6
Evaluación
(70)
Proyectos
91
25%
Arbitraje
26
19% / 54%
Caducado
25
27%
Libre
7
Desarrollador 7
Evaluación
(45)
Proyectos
91
13%
Arbitraje
34
26% / 59%
Caducado
37
41%
Libre
Solicitudes similares
We are looking for a professional developer or trader who already has a proven profitable EA or strategy based mainly on price action logic. Important requirements: No Martingale No Grid No Micro-scalping Avoid heavy indicator-based strategies Strategy should be based mainly on price behavior / market structure We are not looking for aggressive systems that promise unrealistic returns. Our focus is on stable
I run an ea it makes good profits bit that one bad grid blows up the account. I want an EA which runs parallel to it which can intelligently close bad trades or grids. It shouldn't close recoverable trades but close very bad entries and grids. It can even close with hedging. The goal recover max and also not blow up the account
I am looking for an expert MQL5 developer to build a high-precision Hedging System between two different MT5 brokers running on the same local PC. Core Objective: Execute opposite (inverse) trades between a Master and Slave account (e.g., Master BUY = Slave SELL, Master SELL = Slave BUY). The Challenge: Standard "Trade Copiers" are insufficient as they cannot prevent single-legged exposure when using manual trading
I want robot that can help me trade and make some money so that I can be able to learn from it while I'm still in depot account now.Is how it gonna help me with some money
Hello, I have two requests: First: Feature Modification Request Currently, the EA places only one pending order at a time. I want to modify this to place two opposite pending orders (Buy Stop and Sell Stop) simultaneously, with the distance between them aligned with the existing Breakeven and Trailing Stop settings in the bot. How it should work: The EA places a Buy Stop above current price and a Sell Stop
Hello, I need a professional MT5 Expert Advisor for currency trading. PAIRS: EURUSD, GBPUSD, USDJPY, USDCHF TIMEFRAME: M15 STRATEGY: - EMA 8 cross EMA 21 (entry signal) - EMA 50 for trend filter - RSI 14 confirmation (Buy > 52, Sell < 48) - No trade if RSI > 75 or < 25 SESSION: London + New York only 07:00 to 17:00 GMT No weekend trading TRADE MANAGEMENT: - Lot size: 0.06 - Take Profit: $15 per trade - Stop Loss: $8
I need a MetaTrader 5 Expert Advisor (EA) for Forex trading. Account size: $1000 Requirements: 1. The EA should work only on Forex pairs. 2. Automatic Buy and Sell trades. 3. Lot size starting from 0.04. 4. Stop Loss and Take Profit settings. 5. Only one trade at a time. 6. Works on pairs like EURUSD, GBPUSD, USDJPY etc. 7. Risk management suitable for a $1000 account. 8. Easy settings for lot size, SL, TP and risk
I want to design an EA that can identify key Supports and Resistances. This should be able to work on any timeframe from 1 minute to 1 hour (i.e 1 minute, 5 minutes, 15 minutes and 1 hour time frames.) The EA should be able to determine a Fibonacci retracement from a support and the next resistance point in an uptrend and vice versa (i.e the EA should be able to determine a Fibonacci retracement from a resistance and
Product Requirements Document (PRD) Project Title: Liquidity Sniper Semi-EA (Fibonacci & SMC Based) Platform: MetaTrader 5 (MQL5) Target Asset: XAUUSD (High Volatility) / M5 Timeframe 1. EA Operating Concept (Semi-Automated) Human-Machine Collaboration: The trader manually draws a standard Fibonacci Retracement object on the M15 chart to define the market structure (setting the 1.0 and 0.0 anchor points). EA's Role
I am seeking an experienced MQL5 developer to build a high-precision Gold (XAUUSD) scalping Expert Advisor. The objective is to achieve a Profit Factor (PF) of 2.0 or higher with a focus on institutional logic rather than retail lagging indicators.The EA must be designed to pass a "100% Real Ticks" backtest (Exness/Dukascopy data) over a 30-day period with a $500 initial deposit.Core Requirements & Strategy

Información sobre el proyecto

Presupuesto
100+ USD
Plazo límite de ejecución
de 1 a 8 día(s)