How to make a script persistent when changing timeframe ?

 

Hello,

I made a simple MQL5 script. No problem to attach it to a chart, it runs properly.

But if I'm changing the Timeframe of the chart (for example from M1 to M5): the script is automatically removed from the chart.

Any help appreciated,
Thanks
 

Hi DavidS777,

If it is really script (not EA) so as far as I know - then script is executed once after attaching it to the chart, or based on some special condition. I mean: you will need to attach it every time you will need something from this script. 

 
All right, thanks for the reply. Maybe I'll convert it to an indicator to make it persistent (or EA) but only one EA is possible per chart ?
 

Yes, only 1 EA per chart. But you can have many same charts with many same EAs on it - just change magic number of your EA to any "unique number per chart" - and attach your EA to many charts with different magic number.

And there are some Eas which are working for all (pre-selected) the pairs (or for whole the account) if you attach it to any one chart for example.

 
thanks a lot for your prompt answer.
 
DavidS777:

Hello,

I made a simple MQL5 script. No problem to attach it to a chart, it runs properly.

But if I'm changing the Timeframe of the chart (for example from M1 to M5): the script is automatically removed from the chart.

Any help appreciated,
Thanks
You can't make a script "persistent" when changing timeframe. Depending on what you want to do, you can use EA or indicator. See documentation about different types of program.
Reason: