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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        47 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        15 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        21 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X