Hi Coders,
I am struggling with this simple function.. All I want it to do is look back over the past 10 candles and return true if any of the candles where higher than the upper bollinger band.my error '}' Not all control paths return a value. I just can't see where I am going wrong here.
thanks in advance
At first glance it looks like you need another return statement
bool HasBollingerCrossed() { for(int i=Bars-1;i>=1;i=10) { if(High[i] > (iBands(NULL,0,21,2,0,PRICE_CLOSE,MODE_UPPER,i))) return true; } return false; //<< Try this }
for(int i=Bars-1;i>=1;i=10)
Hi Coders,
I am struggling with this simple function.. All I want it to do is look back over the past 10 candles and return true if any of the candles where higher than the upper bollinger band.my error '}' Not all control paths return a value. I just can't see where I am going wrong here.
thanks in advance
Maybe, I was thinking that if i starts at >= 1, and is then set to 10 on every iteration, as the exit condition is i>=1, it could run forever... but now I see it would exit when i >= 1
Maybe, I was thinking that if starts at >= 1, and is then set to 10 on every iteration, as the exit condition is i>=1, it could run forever...
Ah yes, confusion reigns (especially for me on Friday afternoons LOL)
I was intrigued so had to test it - it is infinite, and as you say will only exit if the inner if becomes true. Have a good weekend!
PS - @Adam Woods - please see the usage of Bars() in this image - yours did not seem right
- R4tna C #: PS - @Adam Woods - please see the usage of Bars() in this image - yours did not seem right
Because the code is MT4 High[i] > (iBands(NULL,0,21,2,0,PRICE_CLOSE,MODE_UPPER,i)))
- Adam Woods: I am struggling
Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon.
- 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 Coders,
I am struggling with this simple function.. All I want it to do is look back over the past 10 candles and return true if any of the candles where higher than the upper bollinger band.my error '}' Not all control paths return a value. I just can't see where I am going wrong here.
thanks in advance