BollingerBandWidth Code

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #119328 quote
    MajorBasse
    Participant
    Average

    Is it possible to define what standard deviation the BollingerBandWidth should be based upon in ProBackTest?

    The code in ProBackTest is “BollingerBandWidth[x](close)” where X is the amount of periods used to calculate the bandwidth.

    But I would also like to define the standard deviation the bandwidth is calculated with, is this possible?

    For example: “BollingerBandWidth[20, 3](close) where 3 is the deviation.

    #119331 quote
    Vonasi
    Moderator
    Master

    There you go:

    p = 20
    m = 3
    
    bbmid = average[p](close)
    
    bbupper = bbmid + (std[p](close)*m)
    bblower = bbmid - (std[p](close)*m)
    
    bbwidth = bbupper - bblower
    
    return bbwidth
    #119333 quote
    Vonasi
    Moderator
    Master

    Something to consider is calculating the bollinger band width as a percentage of the mid line value.

    p = 20
    m = 2
    
    bbmid = average[p](close)
    
    bbupper = bbmid + (std[p](close)*m)
    bblower = bbmid - (std[p](close)*m)
    
    bbwidth = bbupper - bblower
    
    bbwidthperc = (bbwidth/bbmid)*100
    
    return bbwidthperc
    #119345 quote
    MajorBasse
    Participant
    Average

    Thank you very much for the quick help Vonasi!

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

BollingerBandWidth Code


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
MajorBasse @majorbasse Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/11/2020
Status: Active
Attachments: No files
Logo Logo
Loading...