Indicator correctly displayed in debug mode, but doesn't display any value when I add it below a chart
for(int i=limit; i>=0; i--) { if (iClose(sym2, 0, i) > 0) BufferRatio[i] = iClose(sym1, 0, i) / iClose(sym2, 0, i); }
A division by zero error has occurred.
-
BufferRatio[i] = iClose(sym1, 0, i) / iClose(sym2, 0, i);
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019) -
if(counted_bars > 0) counted_bars--; int limit=fmin(rates_total-counted_bars,rates_total-1);
You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)
Thanks! My indicator is ok now! :) (I didn't think to check the division by zero...)
-
You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)
Ok I will check this! I had written my indicator by looking at a lot of examples (maybe a bit old)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I try to create an indicator (i'm a beginner) and I have a problem to display my indicator below a chart.
In MetaEditor, when I press F5 to start the debug, a window opens with a chart and my indicator displays correctly below the chart (I see good values and the indicator is updated correctly at each bar). BUT then, when I want to add the indicator to a chart, it displays nothing... I don't understand why?? The lines "minimum" / "maximum" are displayed correctly, but the value of the indicator is not displayed...
The code of my indicator:
Thanks in advance!!