How to programmatically add EA's to specific charts and automatically load their set files

 

Hi guys, 

One of my EA's implement various trading strategies and therefore I have a library of set files that constitutes a trading portfolio, i.o.w like for example 20 x different set files will be running on the same EA on one particular account. 

I am aware of ExpertAdd() and ExpertRemove() functions, but how would one go about in programmatically load the settings from a selected folder. Perhaps one should write a little EA that will run on only one chart with an input paramater to a folder where all these set files are stored, then the EA should scan the folder and load all set files and apply them to their relevant charts.

Your guys assistance and ideas to implement such a feature will be highly appreciated. 

P.S - I would like to stay away from the WIN32 API library and also refrain from using any DLL's 

Thank you

 
Paul Petrus Lombard:

Hi guys, 

One of my EA's implement various trading strategies and therefore I have a library of set files that constitutes a trading portfolio, i.o.w like for example 20 x different set files will be running on the same EA on one particular account. 

I am aware of ExpertAdd() and ExpertRemove() functions, but how would one go about in programmatically load the settings from a selected folder. Perhaps one should write a little EA that will run on only one chart with an input paramater to a folder where all these set files are stored, then the EA should scan the folder and load all set files and apply them to their relevant charts.

Your guys assistance and ideas to implement such a feature will be highly appreciated. 

P.S - I would like to stay away from the WIN32 API library and also refrain from using any DLL's 

Thank you

Look for chartapplytemplate function 
 
Michalis Phylactou #:
Look for chartapplytemplate function 

Hi, thank you for your feedback! I have considered the use of templates but then again one needs to create a template for each instance of the EA running a specific set file and then save those templates to a folder.

You see I want to create a folder where anyone can drop a set file in with a certain file name using a specific naming convention to identify which instrument or chart to load up by parsing the file name and then dynamically apply ALL set files to their charts in one batch, perhaps by using a little EA that will do all this. 

Also I don't think that file loading and reading functions within MQL will be very effective as it will be extremely time consuming to parse each line of a set file, and then how would one assign the values to 'read only' input parameters, so I was hoping there is a quick way to load a set file and apply the settings to the parameters in one go?

Thank you in advance for any other advice! :) 

 

In this case, the best option, in my opinion, is to hardcode all settings and to put as input a simple dropdown menu in which you select which "set of settings" to apply.

So, on each chart, you just need to change this input variable instead of severals, and you don't need to work with set files.

 
Paul Petrus Lombard:

Hi guys, 

One of my EA's implement various trading strategies and therefore I have a library of set files that constitutes a trading portfolio, i.o.w like for example 20 x different set files will be running on the same EA on one particular account. 

I am aware of ExpertAdd() and ExpertRemove() functions, but how would one go about in programmatically load the settings from a selected folder. Perhaps one should write a little EA that will run on only one chart with an input paramater to a folder where all these set files are stored, then the EA should scan the folder and load all set files and apply them to their relevant charts.

Your guys assistance and ideas to implement such a feature will be highly appreciated. 

P.S - I would like to stay away from the WIN32 API library and also refrain from using any DLL's 

Thank you

There are no ExpertAdd and ExpertRemove built-in functions. Probably you talked with GhatGPT or other AI, all of these do not know MQL5.

You can do it without DLLs, just by FileFindFirst/FileFindNext, ChartOpen, ChartApplyTemplate functions. Template files are similar to set-files, but format is different, and contains not only the settings but names of MQL5-programs (EA, indicators if you need them) and optional objects.

For example, look at the Expert library and use Expert::Run function.

Expert
Expert
  • 2017.11.03
  • www.mql5.com
A library for reading/writing the parameters of arbitrary Expert Advisors.