Debug: array out of range issue + 2 buffers return value of 1 on live chart for every bar

Specification

Only for developers with experience in debugging, and array-out-of-range issues.


A custom indicator seems to work on a static chart, but 1 buffer still has mistakes in it, resulting in a value of 1 for every bar: the code needs to be reviewed and modified, resulting in a working indicator for every symbol, for every timeframe: sometimes when the timeframe is switched, the chart closes automatically, but all the time the value of ExtMapBuffer2 (Aqua) is 1 on the live chart, sometimes there is an "array out of range" issue. The second buffer: NonRepaintBuffer (red line on the image below) is based on the first one:  ExtMapBuffer2. ExtMapBuffer2 repaints around turning points, so this second buffer is added ( NonRepaintBuffer ) that does not change values in the past. As the red line is calculated based on the aqua line, the error must be contained within the  ExtMapBuffer2 calculation.



So review, edit & fix please.

I'm happy to answer any questions.

- - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - -  - - - - - 

About the indicator:

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.

To fix this, a new buffer that does not repaint is added.



Responded

1
Developer 1
Rating
(268)
Projects
603
34%
Arbitration
65
22% / 57%
Overdue
147
24%
Working
Published: 1 article, 22 codes
2
Developer 2
Rating
(453)
Projects
566
26%
Arbitration
24
42% / 38%
Overdue
85
15%
Free
Published: 6 codes
3
Developer 3
Rating
(618)
Projects
721
33%
Arbitration
46
48% / 41%
Overdue
14
2%
Loaded
4
Developer 4
Rating
(4)
Projects
5
20%
Arbitration
2
0% / 100%
Overdue
1
20%
Free
Published: 3 codes
5
Developer 5
Rating
(279)
Projects
341
37%
Arbitration
6
50% / 17%
Overdue
7
2%
Free
Published: 5 codes
6
Developer 6
Rating
(461)
Projects
488
70%
Arbitration
6
67% / 0%
Overdue
2
0%
Free
7
Developer 7
Rating
(87)
Projects
121
68%
Arbitration
5
80% / 0%
Overdue
12
10%
Working
8
Developer 8
Rating
(2675)
Projects
3414
68%
Arbitration
77
48% / 14%
Overdue
342
10%
Free
Published: 1 code
9
Developer 9
Rating
(102)
Projects
105
60%
Arbitration
0
Overdue
0
Free
10
Developer 10
Rating
(132)
Projects
178
39%
Arbitration
4
25% / 50%
Overdue
14
8%
Free
11
Developer 11
Rating
(3)
Projects
2
50%
Arbitration
2
0% / 100%
Overdue
0
Free
Similar orders
UnixFirmanMln 30 - 200 USD
I am an MQL5 Developer specializing in Forex trading automation, Expert Advisors, custom indicators, and trading strategy optimization. I provide services for developing, debugging, modifying, and improving trading robots and indicators. My technical skills include MQL5, C++, Linux, algorithmic trading logic, debugging, and performance optimization. I pay close attention to trading rules, execution logic, risk
I DO NOT need any programming or strategy development. I already have a working NinjaTrader 8 automated strategy based on a 3/5 EMA crossover. I need you to run my existing strategy through NinjaTrader Strategy Analyzer/Optimizer, test the existing adjustable parameters, and find robust settings with the best profit factor and lowest reasonable drawdown. I will provide the existing NinjaScript ZIP. I do not want the
I am looking to acquire an EXISTING and PROVEN MetaTrader 5 Expert Advisor. I am NOT looking for someone to develop a random new strategy from scratch. The objective is to find a robust EA with an existing track record, verify its performance and robustness, and purchase the MQL5 source code together with clearly defined commercial rights. MAIN REQUIREMENTS The EA should meet most or all of the following
Looking to acquire an existing, proven EA. Not looking for new strategy development. REQUIREMENTS — non-negotiable: Minimum 12 months verified LIVE history (Myfxbook or MQL5 Signals, real money — not demo, not backtest) Hard stop loss on EVERY trade, set at order placement NO martingale, NO grid, NO averaging into losers, NO lot multiplication after a loss Max historical drawdown under 30% Minimum 5 trades per
Mr quetta 100+ USD
Yes, that is exactly what I need. The bot should not be restricted to a fixed list of currency pairs. It should technically scan all available Quotex pairs in real time and automatically select the pair where the market conditions are strongest. The bot should analyze each pair using multiple confirmations, such as short-term price momentum, trend direction, market structure, support/resistance, candle formation
Platform: TradingView Programming Language: Pine Script v6 Type: Custom Indicator Project Name: Scalping Reaction Zones + Valid Order Blocks MAIN GOAL I need a custom TradingView indicator for scalping. The indicator must detect: 1. Reaction / Explosion Zones 2. Valid Order Blocks 3. Combined Reaction Zone + Order Block zones The indicator should NOT generate: Buy signals Sell signals TP SL Entry signals Trading
Hello, I trade on HFM MT5. Need SCALPING EA for scalping, budget $30. SYMBOLS: XAUUSD (GOLD), US30, NAS100, GER40, EURUSD TIMEFRAME: M1 and M5 PLATFORM: MT5, must work on HFM VPS STRATEGY: - EMA 9 crosses EMA 21 - RSI 14: BUY only if RSI >45, SELL only if RSI <55 - Bollinger Bands: Only trade when price returns inside BB after breakout - 1 trade at a time per symbol - SL: 150 points Gold / 100 points indices (must be
Project Description I am looking for an experienced MQL5/MT5 Expert Advisor developer to develop an automated trading EA for XAUUSD on the M3 timeframe , running on an Exness account . The EA will automate a manual strategy based on SNR/GAP zones , using two setup types: Price Rejection Price Correction The EA should identify valid BUY/SELL setups around predefined SNR/GAP areas, apply configurable RSI, SMA, EMA and
I need an MT5 Expert Advisor for XAUUSD (Gold) running on an Exness account. STRATEGY LOGIC The exact entry and exit rules will be provided in writing before development starts. Please quote for a single rule-based strategy with clearly separated logic, so the rules can be adjusted later without rewriting the whole EA. RISK MANAGEMENT (this is the priority of the project) - Risk per trade as a percentage of account
Modification of Trade_Panel_7 7.05 Objective . I have this utility “Trade_Panel_7 7.05” with which I open and close positions. Please refer to attached “Trade Panel Modification.jpg”. It shows an input parameter “Volume Step”. This parameter has the initial value of 0.02 as shown. This feature needs to be amended. Present Status . Value of lot size is increased by this “Volume Step”. I have built a whole series of

Project information

Budget
90+ USD
Deadline
from 1 to 3 day(s)