Not sure I'm better at this, but WindowFind - MQL4 Documentation
does tell you that -1 is what you get in the init() function....
Perhaps you should make a second init() function, to be called once from the start() function, and that second init() function (init2() maybe?) would include all the sl(..) calls.
I've figured out that the indicator is working fine until a new bar is formed, then the indicator is stopping. Can someone look at the code in the first post and see if they can fix this? It doesn't seem to be continuing when a new bar is formed.
Thank you to anyone that can help!
Not sure I'm better at this, but WindowFind - MQL4 Documentation
does tell you that -1 is what you get in the init() function....
Perhaps you should make a second init() function, to be called once from the start() function, and that second init() function (init2() maybe?) would include all the sl(..) calls.Thanks for the reply. I'm not exactly sure how to fix the problem, but I will try your suggestion.
I was thinking a design like the following outline....
int init()
{
.... // As before but all sl(..) calls moved to init2()
inited = false;
}
void init2()
{
if ( inited ) return;
... // All the sl(..) calls
inited = true;
}
int start()
{
init2();
...
}
In that way, the WindowFind() function would not be called from the init() function but from the start() function, at which time it actually works.
I've figured out that the indicator is working fine until a new bar is formed, then the indicator is stopping. Can someone look at the code in the first post and see if they can fix this? It doesn't seem to be continuing when a new bar is formed.

Check the logic for "limit"...
As it currently stands: apart from at the first start() call, the counted_bars value will always be in the vicinity of Bars, while All_Bars by the looks of it remains 10, and therefore limit becomes a large negative number.
Maybe you wanted
or something similar?
Check the logic for "limit"...
As it currently stands: apart from at the first start() call, the counted_bars value will always be in the vicinity of Bars, while All_Bars by the looks of it remains 10, and therefore limit becomes a large negative number.
Maybe you wanted
Thank you for your suggestions, I am going to change All_Bars to 0 and try your limit logic in place of what is currently there. I hope this will solve the problem. Thank you for taking your time to try and help me.
Ralph,
Your suggestions seem to have done the trick! Thank you for spending your time to help another. The indicator is now staying current with the current bar. I hope someday to be able to repay the favor. I've posted the working indicator for all who are interested.
Thanks again!
How do you read it?
Ralph,
Your suggestions seem to have done the trick! Thank you for spending your time to help another. The indicator is now staying current with the current bar. I hope someday to be able to repay the favor. I've posted the working indicator for all who are interested.
How do you read it?
Still experimenting with it. I want to incorporate it into an EA. Info about how it works can be found here.
Theoretical Basis of Building Cluster Indicators for FOREX - MQL4 Articles

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm trying to call the custom indicator CC_1. (attached)
Here's my code:
CC_USD=iCustom(NULL,0,"CC_1",0,0);
Print(" CC_USD =",CC_USD);
CC_EUR=iCustom(NULL,0,"CC_1",1,0);
Print(" CC_EUR =",CC_EUR);
CC_GBP=iCustom(NULL,0,"CC_1",2,0);
Print(" CC_GBP =",CC_GBP);
CC_CHF=iCustom(NULL,0,"CC_1",3,0);
Print(" CC_CHF =",CC_CHF);
CC_JPY=iCustom(NULL,0,"CC_1",4,0);
Print(" CC_JPY =",CC_JPY);
CC_AUD=iCustom(NULL,0,"CC_1",5,0);
Print(" CC_AUD =",CC_AUD);
CC_CAD=iCustom(NULL,0,"CC_1",6,0);
Print(" CC_CAD =",CC_CAD);
CC_NZD=iCustom(NULL,0,"CC_1",7,0);
Print(" CC_NZD =",CC_NZD);
In the experts file I keep getting this error:
CC_1 EURUSD,H1: unknown subwindow number -1 for ObjectCreate function
I'm not sure what's wrong.
My other problem is that it sometimes returns the proper info:
CC_EUR =0.0016
But a lot of the time the info returned is:
CC_EUR =2147483647
I can't figure out why it's returning this number. Could anyone who is better at this than me have a look and try to help? Thanks!