Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Average Bollinger band width

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Average Bollinger band width

    This is my first attempt to code an indicator.

    I want to save the SMA of the Bollinger band width of an instrument over 50 periods to a double.

    double BBWAverage = SMA((Bollinger(2,20).Upper - Bollinger(2,20).Lower), 50)

    gives me error.

    Help please !
    Thanks in advance.

    murthymsr

    #2
    Hello murthymsr,

    The SMA is expecting a data series input. You will have to convert the difference between the Bollingers into a data series. There is a tutorial available on data series available here:



    Setup the data series according to that example. It needs to be declared in Variable Region and Instantiated in Initialize(). The data series is then set in OnBarUpdate()

    myDataSeries.Set(Bollinger(2,20).Upper[0] - Bollinger(2,20).Lower[0]);
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    34 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    185 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    344 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    266 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X