Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error with DataSeries

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

    Error with DataSeries

    Hi,

    I am trying to use Bollinger Bands for my custom made MA. However, I get an error saying the 'Values[0]' does not exist in the current context. I have defined them in properties as per the Indicator code of Bollinger Bands :

    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Lower
    {
    get { return Values[0]; }
    }

    /// <summary>
    /// Get the upper value.
    /// </summary>
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Upper
    {
    get { return Values[0]; }
    }


    Can you please tell me why I am getting this error for Values[0] ?

    Thanks,

    Neo

    #2
    Hello Neo_trader,

    One issue with the snippet you posted is the Values index[ ] needs to be incremented by one for each series defined.

    Code:
    /// Get the upper value.
    /// </summary>
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Upper
    {
    get { return Values[[COLOR=red][B]1[/B][/COLOR]]; }
    }

    However you shouldn't need to code in properties for Bollinger Band in a strategy. The indicator and all associated properties are called automatically.

    Let us know what you're trying to do with Bollinger and we can assist further. If you wanted a moving average of bollinger bands for example, you could write:
    SMA(Bollinger(2, 14).Upper, 14)[0]
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      What I am trying to do is use Bollinger on a Spread Value (between two instruments). So I want to create an entry based on the Spread value crossing the Bollinger Upper, Lower and Middle values. How can I use these three values in my strategy using the Bollinger (Spread,Period) function. Please assume the Spread here is a DataSeries.

      Neo

      Comment


        #4
        Neotrader,

        Bollinger can take a dataseries as input. Below snippet will plot based on the three elements of Bollinger, accepting spread as data series input:

        Plot0.Set(Bollinger(spread, 2, 14)[0]);
        Plot1.Set(Bollinger(spread, 2, 14).Upper[0]);
        Plot2.Set(Bollinger(spread, 2, 14).Lower[0]);


        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        626 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        359 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        562 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        567 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X