BollingerBandWidth Code

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #119328 quote
    MajorBasseMajorBasse
    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
    VonasiVonasi
    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
    VonasiVonasi
    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
    MajorBasseMajorBasse
    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.
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

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 MajorBasseMajorBasse
6 years, 7 months ago.

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