Questions from Beginners MQL5 MT5 MetaTrader 5 - page 195

 
barabashkakvn:

Look again at the indicator code from the help https://www.mql5.com/ru/docs/indicators/ima . Note the lines in OnInit():

This creates the indicator handle for the period - "period".

I have found the error in the array size, it was my main error from the initial code. I can't understand why the terminal chart behaves inadequately (blurs, updates, shifts, etc.). Thank you.
Files:
macd2.mq5  4 kb
 
Hi. What are the advantages betweenIndicatorCreate() andiCustom() and which one is better to use. Thank you
 

Good afternoon.

I'm trying to get the last value of a fractal:

Handle[Number]=iFractals(Symbol_,0);

CopyBuffer(Handle[Number],UPPER_LINE,4,100,Upper)

upenv[Number]=Upper[0];


but sometimes I get some strange number upenv[Number]=1.797693134862316e+308

If this number were 0, the problem would be solved this way

if(upenv[Number]=Upper[0] && Upper[0]!=0)

upenv[Number]=Upper[0];

Where is my mistake? What am I doing wrong? How can I get the last value of the fractal before it changes?

 
Vikon:
barabashkakvn:

Once again you should look through the indicator code from https://www.mql5.com/ru/docs/indicators/ima . Note the lines in OnInit():

This is where theindicator handle for the periodis created- "period".

I have found error in the array size, it was my main error from initial code. I can't understand why the terminal chart behaves inadequately (blurs, updates, shifts, etc.). Thanks.

You have created an indicator handle at every tick (i.e. in the OnCalculate() function. This is not correct. Indicator handle should be created in OnInit().

 
barabashkakvn:

All found error in array size, that was my main error in original code. But why does the terminal chart behave inadequately (blinks, updates, shifts, etc.). Thanks.

You have created an indicator handle at every tick (i.e. in the OnCalculate() function. This is not correct. Indicator handle must be created in OnInit().

And if I need MACD readings in an indicator (M1;M5;M15;H1;H4;D1;W1), then I need to create a handle for each period?
 
Vikon:
And if I need MACD readings in an indicator (M1;M5;M15;H1;H4;D1;W1), then I need to create a handle for each period?
Yes, make as many indicator handles as you need in OnInit.
 
paladin800:
Yes, make as many indicator handles as needed in OnInit.
It's not because of the handle, I can't figure it out yet, in fact the code works correctly and gives comparably correct data. But the computer takes off, the terminal jumps, the hell with it.
 
barabashkakvn:

All found error in array size, that was my main error in original code. But why does the terminal chart behave inadequately (blinks, updates, shifts, etc.). Thanks.

You have created an indicator handle at every tick (i.e. in the OnCalculate() function. This is not correct. Indicator handle must be created in OnInit().

It is more probable that on a chart with M15 you use D1 data, or I am mistaken.
 
Hi, maybe someone will have time to look at my izvoyanie, where is my main mistake or is it a mistake of the developers.
Files:
macd2.mq5  7 kb
 
Vikon:
It's more likely that the M15 chart uses D1 data, or I'm wrong.

You create an indicator handle on each tick (i.e. in OnCalculate()). This is incorrect. The indicator handle should be created in OnInit(). On the M15 chart, you can use the data from D1. However, in this case, the data may be incomplete - read "Organizing data access" https://www.mql5.com/ru/docs/series/timeseries_access.

Документация по MQL5: Доступ к таймсериям и индикаторам / Организация доступа к данным
Документация по MQL5: Доступ к таймсериям и индикаторам / Организация доступа к данным
  • www.mql5.com
Доступ к таймсериям и индикаторам / Организация доступа к данным - Документация по MQL5
Reason: