Simple BOOLEAN FUNCTION HELP - page 2

R4tna C
380
R4tna C  

@William Roeder

Actually I was referring to this bit:

   for(int i=Bars-1;i>=1;i=10)
Not this:
High[i] > (iBands(NULL,0,21,2,0,PRICE_CLOSE,MODE_UPPER,i)))
Dominik Christian Egert
2606
Yes, but William is referring to Bars, because it's something different in MT4 compared to MT5.

In MT4 it's a system provided variable. In MT5 it's a function, but no variable is available.

And the usage of iBands is from MT4, therefore referring MT4-code.
R4tna C
380
R4tna C  
Dominik Christian Egert #:
Yes, but William is referring to Bars, because it's something different in MT4 compared to MT5.

In MT4 it's a system provided variable. In MT5 it's a function, but no variable is available.

And the usage of iBands is from MT4, therefore referring MT4-code.

I see, so it must be this I guess...

https://docs.mql4.com/predefined/bars

Ok I have nothing to add to this beyond the "return false" statement in my first comment

Bars - Predefined Variables - MQL4 Reference
Bars - Predefined Variables - MQL4 Reference
  • docs.mql4.com
Bars - Predefined Variables - MQL4 Reference
VikMorroHun
45
VikMorroHun  

As already mentioned by others your "for" cycle is wrong. You need something like this:

for ( int i = Bars - 1; i > 1; i-- )
        ;               //do something
Tobias Johannes Zimmer
1249

After you fixed that for loop you need logical OR:

bool flag=false;

for(...)
{
flag ||= (conditions);
}

That way if the conditions are true for minimum one bar, flag becomes true.

BOAFX Trading Signal Solutions
548
VikMorroHun #:

As already mentioned by others your "for" cycle is wrong. You need something like this:

Hi thanks for the reply. Is the loop not counting back across the bars i.e. starting at i and counting through i-- which is every bar on that chart. my thinking was i-- replaced with i=10 would count back until the 10th bar. but I guess its not that simple? then the logic is if the if statement is true across any on those bars then it would return true. if not false?

Thanks anyway it didn't help I posted it in the wrong thread at first it has just confused me further>

Tobias Johannes Zimmer
1249

Loops will work the same way in MQL4 and MQL5.

Dominik Christian Egert
2606
Tobias Johannes Zimmer #:

Loops will work the same way in MQL4 and MQL5.

... when using compiler directive "strict".
else it will declare a variable with scope beyond the for loop.