Load a Set File while Expert is running?(Help)

Farshad Saremifar
158
Farshad Saremifar  

hello guys,


how can i load a set file while expert is running??

gordon
2327
gordon  

You have 2 options:

1. Manually - just press F7 and the properties window will pop-up, load your set file and press OK.

2. Automatically - u can write a function to read a set file and set all extern variables. You can call this function as needed in the code.


Notes:

- The properties window can only be opened while the expert is NOT working (when start() finished it's work for last incoming tick and is waiting for next incoming tick).

- Hence, the properties window cannot be opened for experts running in an endless while loop directly.

- Regarding the 'automatic' method - this could be very problematic if not done properly. Specifically note that changing extern variables via code might lead to potential problems (see -> https://www.mql5.com/en/forum/123535).

Farshad Saremifar
158
Farshad Saremifar  
gordon:

You have 2 options:

1. Manually - just press F7 and the properties window will pop-up, load your set file and press OK.

2. Automatically - u can write a function to read a set file and set all extern variables. You can call this function as needed in the code.


Notes:

- The properties window can only be opened while the expert is NOT working (when start() finished it's work for last incoming tick and is waiting for next incoming tick).

- Hence, the properties window cannot be opened for experts running in an endless while loop directly.

- Regarding the 'automatic' method - this could be very problematic if not done properly. Specifically note that changing extern variables via code might lead to potential problems (see -> https://www.mql5.com/en/forum/123535).

Thanks for the reply, i want to change it from code, i think i have to remove all the extern variables and change them via code

gordon
2327
gordon  
kimitrio:

Thanks for the reply, i want to change it from code, i think i have to remove all the extern variables and change them via code

If u want to change it from code, then I recommend u use non-extern variables and have a function to read their values form file. As I said, changing extern variables values form code if not done properly could lead to problems/bugs.

Farshad Saremifar
158
Farshad Saremifar  
gordon:

If u want to change it from code, then I recommend u use non-extern variables and have a function to read their values form file. As I said, changing extern variables values form code if not done properly could lead to problems/bugs.

Thank you man.

I want to change my expert to use 3 kind of parameters for 3 kind of market condition(bear,bull,range), i think i have to set them in a file and load them manualy with code, thanks bro

gordon
2327
gordon  
kimitrio:

Thank you man.

I want to change my expert to use 3 kind of parameters for 3 kind of market condition(bear,bull,range), i think i have to set them in a file and load them manualy with code, thanks bro

If u have many extern variables then that would be a good idea. But if u have just a few, then perhaps having extern parameters for each market condition and using 3-by-1 arrays (for each parameter) throughout the code would be a better and more reliable solution. Just need to make a proper function for loading those 3 sets of extern parameters into the arrays. But either way would work.