Download MetaTrader 5

Acquiring indicator handle inside an indicator

To add comments, please log in or register
Add our Facebook page to friends. Follow the latest news!
balintba
18
balintba 2014.07.02 18:17 

Hello,

 I would like to ask a question about an issue with which I struggle for some time.

I have written an indicator(no.1), which I would like to use in another indicator(no.2). If I place the iCustom function

of this indicator(no.1) in the OnInit function of the other indicator(no.2), there is no problem. The indicator works, loads

properly and I can access all of its buffers at my convinience.

However, I would like to be able to change the parameters of indicator (no.1) during programm running according to

some analysis I make in ind. no.2. - I try to create an adaptive indicator.

If I would like to get an indicator handle(no.1) inside the OnCalculate function of ind. no.2., I allways get an error (4806).

Please note, that at the beginning of the OnCalculate function I try to create the indicator and release it at the end of the

codeblock. The indicator_handle variable should be allways empty before I use the iCustom function.

 

Do you maybe have any idea, why I am able to create the indicator in the OnInit function, but unable in the OnCalculate function?

 Thank you so much in advance!

Alain Verleyen
Moderator
30739
Alain Verleyen 2014.07.03 16:31  
balintba:

Hello,

 I would like to ask a question about an issue with which I struggle for some time.

I have written an indicator(no.1), which I would like to use in another indicator(no.2). If I place the iCustom function

of this indicator(no.1) in the OnInit function of the other indicator(no.2), there is no problem. The indicator works, loads

properly and I can access all of its buffers at my convinience.

However, I would like to be able to change the parameters of indicator (no.1) during programm running according to

some analysis I make in ind. no.2. - I try to create an adaptive indicator.

If I would like to get an indicator handle(no.1) inside the OnCalculate function of ind. no.2., I allways get an error (4806).

Please note, that at the beginning of the OnCalculate function I try to create the indicator and release it at the end of the

codeblock. The indicator_handle variable should be allways empty before I use the iCustom function.

 

Do you maybe have any idea, why I am able to create the indicator in the OnInit function, but unable in the OnCalculate function?

 Thank you so much in advance!

The indicator #1 needs time to be calculated. Don't set/release the handle on each tick.
To add comments, please log in or register