Array and indicators

 

Hi guys,

I have an indicator, which works with an array (not candle's data, but on-the-fly generated). This array is empty at the first starting.

When the indicator runs, this array gets new values.

My problem: when I change an input parameter and refresh the indicator on the chart, my array will be empty and starts to collect data from beginning.

Is it possible somehow to preserve the existing array-data?

(This is not problem for an expert, but problem for an indicator, because when refreshing it takes into account the initial values outside the OnInit() and frees the array.)

Thanks

 

This is normal.

You can transfer an array from an old copy of the indicator to a new one.

 
fxsaber:

This is normal.

You can transfer an array from an old copy of the indicator to a new one.

Thank you. Your solution is a bit circumstantial.

Is there any simpler solution (without those include files) or is it the one and only?

 
You only need to realize this
fxsaber:

You can transfer an array from an old copy of the indicator to a new one.

 
fxsaber:
You only need to realize this
OK, but how? I don't want to use OOP which I am not familiar with. Is there any other method?
 
DonFx:
OK, but how? I don't want to use OOP which I am not familiar with. Is there any other method?


fxsaber solution is only valid for mql5.  In mql4 you could save your array data to a file and re-load it at every new initialization.  Regards.

https://docs.mql4.com/files/filewritearray

 
DonFx:
OK, but how? I don't want to use OOP which I am not familiar with. Is there any other method?
This is not explained in a nutshell. It is necessary to write a library and use it.
 
Jose Francisco Casado Fernandez:

fxsaber solution is only valid for mql5.

And MQL4.

An array can also be passed through resources and global variables.

 
Jose Francisco Casado Fernandez:


fxsaber solution is only valid for mql5.  In mql4 you could save your array data to a file and re-load it at every new initialization.  Regards.

https://docs.mql4.com/files/filewritearray

Yes, it is a workaround solution, but I hoped that something simpler exists as well. But, eventually it is quite simple.
 
fxsaber:

And MQL4.

An array can also be passed through resources and global variables.


Yes, in mql4 you can use resources and global variables, but in your code, you use several functions (ChartIndicatorGet(), IndicatorParameters(), IndicatorRelease(), etc)  and structures (MqlParam) that don't work in mql4.

 
Jose Francisco Casado Fernandez:

Yes, in mql4 you can use resources and global variables, but in your code, you use several functions (ChartIndicatorGet(), IndicatorParameters(), IndicatorRelease(), etc)  and structures (MqlParam) that don't work in mql4.

Sorry, hurry up!
Reason: