calculating the etality of the Bollinger band

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #248901 quote
    juld63juld63
    Participant
    New

    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
    
    #248931 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    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.

    Iván González thanked this post
    #248932 quote
    juld63juld63
    Participant
    New

    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!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

calculating the etality of the Bollinger band


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
juld63 @juld63 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by juld63juld63
1 year, 2 months ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 07/16/2025
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...