Bollinger Band colours

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #200455 quote
    AlfyAlfy
    Participant
    Average
    Good afternoon guys, i wonder if anyone can help. I am trying to colour my upper and lower Bollinger bands Green when the middle moving average is rising and Red when the middle Moving average is falling. Can someone help please? Ive copied the basic code for the Bollinger Bands themselves. Thanks for any help you can share! Best regards
    a=average [21] (close)
    b=STD[21](close)
    Bollup= BollingerUp[21](close)
    Bolldn=BollingerDown[21](close)
    Return Bollup,Bolldn,a
    #200457 quote
    JSJS
    Participant
    Master
    LRS = LinearRegressionSlope[21](close)
     
    If LRS > 0 then
    Bullish = 1
    Bearish = 0
    R = 0
    G = 255
    B = 0
    ElsIf LRS < 0 then
    Bullish = 0
    Bearish = 1
    R = 255
    G = 0
    B = 0
    Else
    Bullish = 0
    Bearish = 0
    R = 0
    G = 0
    B = 255
    EndIf
    
    Avg = Average[21](close)
    
    Bollup= BollingerUp[21](close)
    
    Bolldn=BollingerDown[21](close)
    
    Return Bollup Coloured(R,G,B) as "BollingerUp" ,Bolldn Coloured(R,G,B) as "BollingerDown",Avg Coloured(R,G,B) Style(DottedLine)
    
    Hi @Alfy

    To determine the direction of the average, you can use the Linear Regression Slope.

    Alfy and Nicolas thanked this post
    Schermafbeelding-2022-09-09-om-21.21.12.png Schermafbeelding-2022-09-09-om-21.21.12.png
    #200462 quote
    AlfyAlfy
    Participant
    Average
    Thanks so much JS!
    JS thanked this post
    #200463 quote
    JSJS
    Participant
    Master

    You may be thinking, what does linear regression have to do with a moving average?

    Where the linear regression intersects with the moving average, that is the zero point of the linear regression slope…

    Schermafbeelding-2022-09-10-om-09.46.59.png Schermafbeelding-2022-09-10-om-09.46.59.png
Viewing 4 posts - 1 through 4 (of 4 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

Bollinger Band colours


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Alfy @alfy Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by JSJS
4 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/09/2022
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...