Using iCustom for a custom indicator create massive duplicate windows

 

Hello everyone,


I stumble on a very weird behaviour when trying to get my EA to implement a custom indicator. As said in title, when hitting play, I get a new indicator window every time iCustom is called. Is this the expected result? iMA, iATR, iEnvelopes, etc don't have this behaviour. 

iCustom implementation:

int def = iCustom(_Symbol, _Period, "Test", 10);


How can I prevent this?


I don't think it has anything to do with my indicator implementation since it works exactly the same way when copy/pasting the RVI indicator code inside a new file for example.


Thanks for your help!

 
Solail:

Hello everyone,


I stumble on a very weird behaviour when trying to get my EA to implement a custom indicator. As said in title, when hitting play, I get a new indicator window every time iCustom is called. Is this the expected result? iMA, iATR, iEnvelopes, etc don't have this behaviour. 

iCustom implementation:


How can I prevent this?


I don't think it has anything to do with my indicator implementation since it works exactly the same way when copy/pasting the RVI indicator code inside a new file for example.


Thanks for your help!


Totally has to do with this: https://www.mql5.com/en/forum/296230/page3#comment_15320996


So basically, it is a better practice to declare your handler in the OnInit method, and then call iGetArray (that you can find here: https://www.mql5.com/en/forum/296230#comment_10034372 )


Thanks to @Vladimir Karputov for his work.

How to start with MQL5
How to start with MQL5
  • 2020.03.05
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 
Solail:

Hello everyone,


I stumble on a very weird behaviour when trying to get my EA to implement a custom indicator. As said in title, when hitting play, I get a new indicator window every time iCustom is called. Is this the expected result? iMA, iATR, iEnvelopes, etc don't have this behaviour. 

iCustom implementation:


How can I prevent this?


I don't think it has anything to do with my indicator implementation since it works exactly the same way when copy/pasting the RVI indicator code inside a new file for example.


Thanks for your help!

are you sure that you are correctly using iCustom in OnInit() to get the handle of the indicator that you want to use?

 
Paul Anscombe:

are you sure that you are correctly using iCustom in OnInit() to get the handle of the indicator that you want to use?

Hi Paul, thanks for your answer. No I wasn't. I was using it directly on OnTick method, and that was the issue (as specified in my own answer)


Thanks for your help!

 
Paul Anscombe :

are you sure that you are correctly using iCustom in OnInit() to get the handle of the indicator that you want to use?

To create the indicator handle ONCE in OnInit is ABSOLUTELY CORRECT!

Please READ CAREFULLY: You will find on the MQL5 forum!

Reason: