Usually, I unload the bot, if it is impossible to create a Turkey handle with which you need to work so writing such lines in OnInit():
MqlParam inputParameters[];
Everything works as it should.
setInputParameters(inputParameters, "INDICATOR NAME", i_ZZ_tf);
if (!createHandle(inputParameters)) {
int retCode = MessageBox("Indicator '" + inputParameters[0].string_value + "' wasn't created", "", MB_OK | MB_ICONSTOP);
if (retCode == IDOK)
ExpertRemove();
}
I tried this in the indicator and.. it doesn’t work. Although, the help says that this is not recommended, but that it does not work.. not said. And I, in General, do not care that this will suspend the flow, because if the Turkey is not initialized, then the bot will not trade. Moreover, as I understand it, then it will pause only for this Turkey, and not for everyone in the terminal.
So it’s weird.
I rewritten it differently:
if (!createHandle(inputParameters)) {
All the same, the indicator is not unloaded.
return INIT_FAILED;
}
How to force it to be unloaded in case of not successful initialization? After all, this is not adequate. Why would a Turkey hang on the chart if it couldn’t initialize? For example, I have an indicator that is used in another to calculate and draw levels. If the first one was not initialized, then the other one will not show the necessary values…
alexeyvik
In mql5, there is no need to specify this, there is initially in strict mode
tecciztecatl
I checked it again – it doesn’t work)
savinkins
Does this work in MT5 too?
tecciztecatl
everything is unloaded if specified
#property strict
mvs
If it fails, you can try several more initialization attempts.
The current algorithm works correctly!
hoz
Nope. They didn’t come back)) Sergey, here the question is different. I’m not a fan of using indicators, so I don’t really work with them.
But I had to because I was writing a complicated algorithm and constantly shoveling certain operations is not an option. How to remove a Turkey from the chart I already understood. There is also a ChartIndicatorDelete function()
Current all the same, some nonsense turns out. I’ll explain what I think. For example, here is the type OnInit() such an abstract:
int OnInit(){
line 1
line 2
line 3
..
line 4 .
.
line 5
}
All variants of what the initialization method returns are worthless in the full sense of the word. This is not a reproach to developers, but even advice.
Logically, if the return from OnInit() is, for example, INIT_FAILED, then logically you need to unload everything from the graph. Then there is no reason to continue to do something. Otherwise, it turns out absurd. For example, do this:
IndicatorSetString(INDICATOR_SHORTNAME, "m_IndicatorName");
MqlParam inputParameters[];
setInputParameters(inputParameters, "_myIndicators/ZigZag_HightLow_MTF", i_ZZ_tf);
if (!createHandle(inputParameters)) {
ChartIndicatorDelete(0, 0, "m_IndicatorName");
return INIT_FAILED;
}
The absurdity is that the string:
ChartIndicatorDelete(0, 0, "m_IndicatorName");
it’s like an extra one here. It should be on the mind to immediately unload everything, because initialization was crowned with failure..
savinkins
So we’re back to the good old topic. )))))