If you know the names of inputs, the second option is better. It allows you not to think about the order of inputs in the Expert Advisor. And it is technically better implemented.
Despite the fact that inpFirst is the second in order, it can be set to anything (in this case it is set to be the first and the only one). Those that are not set will be default.
For experiments I needed to clone a robot for several charts. I did it through this function.
#include <fxsaber\Expert.mqh> // https://www.mql5.com/en/code/19003// Copies the running Expert Advisor with current settings from one chart to the otherbool ExpertFromTo( constlong ChartSource, constlong ChartTarget )
{
bool Res = false;
MqlParam Params[];
string Names[];
constint ExpertMode = EXPERT::Parameters(ChartSource, Params, Names);
constint Size = ArraySize(Params);
if (Size)
{
Params[0].string_value += "\nexpertmode=" + (string)ExpertMode;
for (int i = 1; i < Size; i++)
EXPERT::AddInputName(Params[i], (Names[i - 1] == NULL) ? " " : Names[i - 1]);
Res = EXPERT::Run(ChartTarget, Params);
}
return(Res);
}
I used it like this.
#property script_show_inputsinputint inAmount = 5; // How many clonesvoidOnStart()
{
constint Size = SymbolsTotal(true);
if (Size > inAmount)
for (int i = 0, Count = 0; i < Size; i++)
{
conststring Symb = SymbolName(i, true);
if (Symb != _Symbol)
{
ExpertFromTo(0, ChartOpen(Symb, PERIOD_CURRENT)); // Run the current EA on new charts-symbols.
Count++;
if (Count == inAmount)
break;
}
}
}
The task of restarting a dozen different Expert Advisors on more than one Terminal arises. In general, a big routine.
For example, we corrected something. Then batch compilation in ME and restart. I use such a script for it.
// Reloads EAs on all charts.inputint inInterval = 5; // Interval in seconds between chart restartsbool ReloadChart( constlong Chart )
{
return (ChartSaveTemplate(Chart, "\\Files\\" + __FILE__ + ".tpl") &&
ChartApplyTemplate(Chart, "\\Files\\" + __FILE__ + ".tpl") && // Put the task in the chart queue.ChartGetInteger(Chart, CHART_WINDOW_HANDLE)); // Make the queue move.
}
voidOnStart()
{
constlong chartID = ::ChartID();
for (long Chart = ChartFirst(); (Chart != -1) && !IsStopped(); Chart = ChartNext(Chart))
if ((Chart != chartID) && (ChartGetString(Chart, CHART_EXPERT_NAME) != NULL) && (ReloadChart(Chart)))
Sleep(inInterval * 1000);
}
I have marked an important place in the code. Without it, the application of the template will not be until the end of the script. By analogy, you can solve the launch of Expert Advisors after reloading the Terminal, etc.
This function allows you to select a file as an input variable. This implementation.
inputstring inFileName = NULL; // Selected file#define TOSTRING(A) #A
intOnInit()
{
if (!FileIsExist(inFileName))
return(FileDialogToInput(TOSTRING(inFileName)) || INIT_FAILED);// Code if a valid file is specified in the input variable.return(INIT_SUCCEEDED);
}
Startup.
Click OK and select.
Click Open and see the properties (F7) of the running EA.
The same will work with any number of files.
inputstring inFileName1 = NULL; // Selected file1inputstring inFileName2 = NULL; // Selected file2#define TOSTRING(A) #A
intOnInit()
{
if (!FileIsExist(inFileName1))
return(FileDialogToInput(TOSTRING(inFileName1)) || INIT_FAILED);
if (!FileIsExist(inFileName2))
return(FileDialogToInput(TOSTRING(inFileName2)) || INIT_FAILED);
// Code if a valid file is specified in the input variable.return(INIT_SUCCEEDED);
}
Despite the fact that inpFirst is the second in order, it can be set to anything (in this case it is set to be the first and the only one). Those that are not set will be default.
I used it like this.
The task of restarting a dozen different Expert Advisors on more than one Terminal arises. In general, a big routine.
For example, we corrected something. Then batch compilation in ME and restart. I use such a script for it.
I have marked an important place in the code. Without it, the application of the template will not be until the end of the script. By analogy, you can solve the launch of Expert Advisors after reloading the Terminal, etc.
The task of restarting a dozen different Expert Advisors on more than one Terminal arises. In general, a big chore.
For example, we corrected something. Then batch compilation in ME and restart. I use this script for it.
I have highlighted an important place in the code. Without it, the template will not be used until the end of the script. By analogy, you can solve the launch of Expert Advisors after reloading the Terminal, etc.
It will be a complete set if you can get the name of the EA on the specified chart. If it is not difficult for you, finish it.
It would be complete if you could get the name of the councillor on said chart. If you don't mind, please complete it.
This is MT5. If you need cross-platform or full path to the Expert Advisor, then via Expert.mqh.
This is MT5. If you need cross-platform or full path to the Expert Advisor, then via Expert.mqh.
Need cross-platform...
Need a cros-platformer...
Forum on trading, automated trading systems and testing trading strategies.
Libraries: Expert
fxsaber, 2019.09.12 06:17 pm.
This function allows you to select a file as an input variable. This implementation.
Startup.
Click OK and select.
Click Open and see the properties (F7) of the running EA.
The same will work with any number of files.
And loading parameters from set-files is not supported yet, as I understand?
I haven't. But it's very simple.