How do I change the input parameter in the custom indicator during trading and apply the changes?
Let's say I had ma 25, now I need ma 33.
As far as I understand the input parameters are only set during initialisation. But I need to change indicator during trading
Well, it seems that at changing of values in input parameters of the EA OnInit() is triggered, it means that the new values of parameters are applied. Or am I wrong?
If the values in the input parameters of the EA are changed, OnInit() is triggered, which means that the new values of the parameters are applied. Or am I wrong?
I've tried it this way.
It doesn't work
inputint InpMA_ma_period = 25; // Параметры МА inputint InpMA_ma_shift = 0; // MA PRICE_HIGH and PRICE_LOW: horizontal shift inputENUM_MA_METHOD InpMA_ma_method = MODE_SMA; // MA PRICE_HIGH: smoothing type double ExtInpMA_ma_period=InpMA_ma_period;
int handle_MA;
intOnInit()
{
handle_MA=iCustom(m_symbol.Name(),Period(),"MA",ExtInpMA_ma_period,InpMA_ma_shift,InpMA_ma_method,PRICE_CLOSE);
}
voidOnTick()
{
// Ставим новый параметр индикатора и делаем пересчет с новым параметром ???
ExtInpMA_ma_period = 33;
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
How do I change the input parameter in the custom indicator during trading and apply the changes?
Let's say I had ma 25, now I need ma 33.
As far as I understand the input parameters are only set during initialisation. But I need to change indicator during trading
How do I change the input parameter in the custom indicator during trading and apply the changes?
Let's say I had ma 25, now I need ma 33.
As far as I understand the input parameters are only set during initialisation. But I need to change indicator during trading
Create TWO indicators in advance.
Create TWO indicators in advance.
No, I don't need two indicators. I need to change this one during trading.
I want it to have dynamics, so to speak.
Can I download it and load it with new parameters?
No, I don't need two indicators. I need to change this one during trading.
The dynamics, so to speak.
Can it be unloaded somehow and loaded with new parameters?
Create three indicators :).
In general, you have to think first, create the environment and only then get the data.
Create three indicators :).
In general, you have to think first, create the environment and only then get the data.
Suppose -
At the start of the EA the MA = 25;
With every new tick I change the MA = +1.
I.e. MA = 26;
I won't create 500 handles for different conditions)
How do I change the input parameter in the custom indicator during trading and apply the changes?
Let's say I had ma 25, now I need ma 33.
As far as I understand the input parameters are only set during initialisation. But I need to change indicator during trading
Well, it seems that at changing of values in input parameters of the EA OnInit() is triggered, it means that the new values of parameters are applied. Or am I wrong?
If the values in the input parameters of the EA are changed, OnInit() is triggered, which means that the new values of the parameters are applied. Or am I wrong?
I've tried it this way.
It doesn't work
I tried it like this.
Doesn't work.
Well you can't, you need to callOnInit to re-initialize the indicator.
How often do you change parameters during operation?
Well you can't, you need to callOnInit to re-initialise the indicator.
How often do you change parameters during operation?
I am going to change them often.
So the code should look like this?
I'm going to change it a lot.
So the code should look like this?
You should put a flag to check if the value has changed, so you don't have to yankOnInit on every tick
Something like this: