Bollinger Band colours

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #200455 quote
    Alfy
    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
    JS
    Participant
    Senior
    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
    #200462 quote
    Alfy
    Participant
    Average
    Thanks so much JS!
    JS thanked this post
    #200463 quote
    JS
    Participant
    Senior

    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…

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

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 JS
3 years, 5 months ago.

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