Download MetaTrader 5

Change Input Parameters During Runtime

To add comments, please log in or register
No time to learn MQL5? The source code library is at your service!
Andrei Moraru
1157
Andrei Moraru 2013.02.14 17:28 

Hi all!

Is there any way to change the value of the input parameters from within the code of EA/indicator, so that when the EA/indicator is reloaded, the updated values are used?

Ernie Gunning
1147
Ernie Gunning 2013.02.14 17:48  

I had similar requirement on a indicator once. I used global variables in the terminal. 

 

So when your Indicator\expert starts take the value of the input parm and assign it to the global variable. In your OnTick(Expert) or OnCalculate  (Indicator) get the value of the global variable before using the variable....while you code is running go inn the terminal Tools->Global Variables and change your variable

Basic check first need to be done if the global variable exist if not create etc.. this all in onInit.

I needed a Bollingar indicator who's deviation was dynamic...worked 100%.

Goodluck

Andrei Moraru
1157
Andrei Moraru 2013.02.14 19:43  
Interesting solution, will try it. Thanks!
phi nuts
2184
phi nuts 2013.02.15 09:25  

An EA will still running when its property Window is opened (by pressing f7) please read Will a static variable lose its value when EA restart from disconecting? and EA continues to run after the Autotrading button is pressed to disable it, however same thing does NOT happen in an indicator.

You could also use script that write to a file (or Global Variable as suggested by ToolMaker) and the EA reads from that file. It much more convenience that way.

phi nuts
2184
phi nuts 2013.02.18 06:38  

Here'a an article which I only read the title but not the content which may gives some idea ;D

Change Expert Advisor Parameters From the User Panel "On the Fly" 

To add comments, please log in or register