Hi everyone, I want to be able to determine whether the lower BB at [0] is either:
- going up from lower than close/10000 and reaching a local max at [0];
- going down from a local max (itself defined by having come up from a preceding low lower than close/10000 relative to that local max) but not too much (less than close/500);
- going down from a local max by more than close/500.
I’ve tried to write it that way bbut it always gives 0 as a result. Even if I pu in the FOR loop a condition that is always verified e.g. b=b it still gives me 0. Any idea what is missing ? Thanks !
PN= close/10000
//bollinger
a = Average[200](Close)
// On définit l'écart-type
StdDeviation = STD[200](Close)
Bsup2 = a + 2 * StdDeviation
Binf2 = a - 2 * StdDeviation
Bsup15 = a + 1.5 * StdDeviation
Binf15 = a - 1.5 * StdDeviation
etalite=0
FOR b=1 to b=500 DO
IF (Highest[b](Binf15)-Binf15[0]>=PN AND Highest[b](Binf15)-Binf15[b]<PN) OR (Highest[b](Binf15)-Binf15[0]<PN AND Binf15[0]-Binf15[b]<PN) THEN
continue
ELSIF (Highest[b](Binf15)-Binf15[b]>=PN AND Highest[b](Binf15)-Binf15[0]<20*PN) OR (Highest[b](Binf15)=Binf15[0] AND Binf15[0]-Binf15[b]>=PN) THEN
etalite=1
break
ELSIF Highest[b](Binf15)-Binf15[b]>=PN AND Highest[b](Binf15)-Binf15[0]>=20*PN THEN
etalite=0
break
ENDIF
NEXT
RETURN etalite
Line 12 should read:
FOR b=1 to 500 DO
as it is now, its meaning is a boolean comparison, because it will check if b=500, which is always false because it starts from 1 which is different from 500, unless it’s the very last iteration to which it seems to never arrive as it always breaks earlier.
As to the rest of the code I can’t exactly understand what you want to do.
Thanks, I realized just 10 minutes ago that this was the mistake! I new it had to be something super basic because nothing worked. Good catch!