Adjust standard deviation of bollinger bands

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #188715 quote
    josward1
    Participant
    New

    Hello, I’m trying to add Bollinger bands into my code, I have used the “insert function” tab to add the upper and lower band into my code. It gives the option to select the period in brackets. How can I adjust the standard deviation?

     

    if mastrategy then //moving average trade entry
    macrossbuy = open crosses over BollingerUp[20](close)
    macrosssell = open crosses under BollingerDown[20](close)

     

    I want the bot to take a buy trade when the price crosses over the upper bollinger, and a sell trade when the price crosses under the the lower bollinger.

    I need to be able to adjust both the the bollinger band period and standard deviation.

     

    thanks

    #188719 quote
    robertogozzi
    Moderator
    Master

    You can’t change the built-in standard deviation. To do this, you need to code the BB yourself. This the code to be used in your strategy:

    BB     = 20                                 //20   periods
    BBdev  = 2.0                                //2.0  standard deviation
    BBavg  = average[BB,0](close)               //BB mean (middle line)
    UPboll = BBavg + ((std[BB](close)) * BBdev) //BB Upper Band
    LOboll = BBavg - ((std[BB](close)) * BBdev) //BB Lower Band
    #188767 quote
    robertogozzi
    Moderator
    Master

    Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.

    Below you can read the basic rules (highlighted in yellow).

    Thank you 🙂

    You’ve already been given an answer (above).

    #188781 quote
    josward1
    Participant
    New

    The double post was accidental i havent used this platform much at all and couldn’t see that my first post successfully got submitted.

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

Adjust standard deviation of bollinger bands


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
josward1 @josward1 Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by josward1
3 years, 11 months ago.

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