Download MetaTrader 5

Array and indicators

To add comments, please log in or register
DonFx
964
DonFx  

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

fxsaber
10942
fxsaber  

This is normal.

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

DonFx
964
DonFx  
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?

fxsaber
10942
fxsaber  
You only need to realize this
fxsaber:

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

DonFx
964
DonFx  
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?
Jose Francisco Casado Fernandez
4486
Jose Francisco Casado Fernandez  
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

fxsaber
10942
fxsaber  
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.
fxsaber
10942
fxsaber  
Jose Francisco Casado Fernandez:

fxsaber solution is only valid for mql5.

And MQL4.

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

DonFx
964
DonFx  
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.
Jose Francisco Casado Fernandez
4486
Jose Francisco Casado Fernandez  
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.

fxsaber
10942
fxsaber  
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!
12
To add comments, please log in or register