Hi everyone
In MQL5
I use the sequences above to load a custom indicator from EA to manage its results.
When I change the TF, the same indicator is reloaded with each change of TF, confusing the EA
How can I solve the problem?
I don't add it, it does it automatically when changing TF.
And that's what I'd like to avoid.
I just need to change the parameters.
Of course you add it, do you understand what your code is doing ?
When you change the timeframe ChartIndicatorAdd() is executed again, but the indicator is never removed from the chart.
Of course you add it, do you understand what your code is doing ?
When you change the timeframe ChartIndicatorAdd() is executed again, but the indicator is never removed from the chart.
Ok I understand.
I just don't know where to enter the command to clear the indicator before reloading it.
If I put it in
void OnDeinit()
It doesn't delete it.
How can I fix it? Can you give me a tip?
Ok I understand.
I just don't know where to enter the command to clear the indicator before reloading it.
If I put it in
void OnDeinit()
It doesn't delete it.
How can I fix it? Can you give me a tip?
IndicatorRelease() is useless for your case.
You need to use ChartIndicatorDelete(). Or you can just add it once at the first start, all depends what you want to do.
I don't add it, it does it automatically when changing TF.
And that's what I'd like to avoid.
I just need to change the parameters.
In OnInit, get the handle with the parameters you need and add the indicator to the chart.
In OnDeinit, delete the indicator from the chart, then release the handle.
IndicatorRelease() is useless for your case.
You need to use ChartIndicatorDelete(). Or you can just add it once at the first start, all depends what you want to do.
I try to explain what I would like to achieve.
I load the indicator into the chart and on first start it takes the parameters from the EA.
When I change TF, the indicator is reloaded by duplicating itself always using the parameters passed by the EA.
I wish changing TF would not reload.
And that if I change the parameters from the EA, they are also taken from the indicator.
At the moment if I change the parameters in the EA the indicator keeps the first ones received.
and in OnInit() I put
ChartIndicatorDelete(0,0, MyHandle );
ChartIndicatorAdd(0, 0, MyHandle );
MyHandle = iCustom(_Symbol, TimeFrame, ".\MyIndicator", Periods, Multiplier);
This has to be in OnInit, otherwise when parameters change the indicator handle won't change.
I try to explain what I would like to achieve.
I load the indicator into the chart and on first start it takes the parameters from the EA.
When I change TF, the indicator is reloaded by duplicating itself always using the parameters passed by the EA.
I wish changing TF would not reload.
And that if I change the parameters from the EA, they are also taken from the indicator.
At the moment if I change the parameters in the EA the indicator keeps the first ones received.
and in OnInit() I put
ChartIndicatorDelete(0,0, MyHandle );
ChartIndicatorAdd(0, 0, MyHandle );
ChartIndicatorDelete() doesn't take a handle as parameter, check the documentation.
If you want the EA to be able to use the indicator which is on the chart (on the associated parameters) you need to use ChartIndicatorGet() instead of iCustom().
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone
In MQL5
I use the sequences above to load a custom indicator from EA to manage its results.
When I change the TF, the same indicator is reloaded with each change of TF, confusing the EA
How can I solve the problem?