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 kinfxhk, 07-14-2026, 09:39 AM
    0 responses
    127 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    105 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    85 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    105 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    86 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X