Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Array Index Errors in Help Guide

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

    Array Index Errors in Help Guide

    There are several typos in the help relating to needed array indices...

    Code:
    [B][SIZE=5][COLOR=Blue]Plots[/COLOR][/SIZE][/B]
    
    [B][SIZE=3][COLOR=Sienna]Definition[/COLOR][/SIZE][/B]
    
    A collection holding all of the Plot objects that define the visualization characteristics of the indicator.
    
    [B][COLOR=Sienna]Property Value[/COLOR][/B]
    
    A collection of [COLOR=Blue]Plot [/COLOR]objects.
    
    [B][COLOR=Sienna]Syntax[/COLOR][/B]
    
    Plots[[COLOR=Blue]int [/COLOR]index]
    
    [B][COLOR=Sienna]Examples[/COLOR][/B]
    
    [COLOR=SeaGreen]// Initialize method of a custom indicator[/COLOR]
    [COLOR=Blue]protected override void[/COLOR] Initialize()
    {
    [COLOR=SeaGreen]    // Plots are added to the Plots collection in order[/COLOR]
        Add([COLOR=Blue]new[/COLOR] Plot(Color.Orange, "Plot1")); // Stored in Plots[0]
        Add([COLOR=Blue]new [/COLOR]Plot(Color.Blue, "Plot2"));   // Stored in Plots[1]
    }
    
    [COLOR=SeaGreen]// Dynamically change the primary plot's color based on the indicator value[/COLOR]
    [COLOR=Blue]protected override void[/COLOR] OnBarUpdate()
    {
        [COLOR=Blue]if [/COLOR](Values[0] > 100)
            Plots[0].Pen = [COLOR=Blue]new [/COLOR]Pen(Color.Blue);
        [COLOR=Blue]else[/COLOR]
            Plots[0].Pen = [COLOR=Blue]new [/COLOR]Pen(Color.Red);
    }
    Since "Values" is defined as an array of Dataseries, the correct reference should be either "Value[0]" or "Values[0][0]".

    Similar errors occur in the help guide example for "Value"...

    Code:
    [SIZE=5][B][COLOR=Blue]Value[/COLOR][/B][/SIZE]
    
    [B][COLOR=Sienna]Definition[/COLOR][/B]
    
    Value references the 1st DataSeries object Values[0] in the indicator. This is the primary indicator value.
    [B][COLOR=Sienna]
    Property Value[/COLOR][/B]
    
    A DataSeries object.
    
    [B][COLOR=Sienna]Syntax[/COLOR][/B]
    
    Value
    
    [B][COLOR=Sienna]Examples[/COLOR][/B]
    
    // OnBarUpdate method of a custom indicator
    protected override void OnBarUpdate()
    {
       [COLOR=SeaGreen] // Checks the indicator primary value 1 bar aga and sets the value of the indicator
        // for the current bar being evaluated[/COLOR]
        [COLOR=Blue]if [/COLOR](Values[1] < High - Low)
            Value.Set(High - Low);
        [COLOR=Blue]else[/COLOR]
            Value.Set(High - Close);
    }
    ...the references "Values[1]" and "High" and "Low" all need an[other] array index (e.g., Values[0][1], High[0], Low[0]).

    #2
    Thanks for pointing this out. Will take care of it.
    RayNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by The_Sec, Today, 02:29 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by jeronymite, 04-12-2024, 04:26 PM
    2 responses
    30 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by Mindset, 05-06-2023, 09:03 PM
    10 responses
    265 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by michi08, 10-05-2018, 09:31 AM
    5 responses
    743 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by tsantospinto, 04-12-2024, 07:04 PM
    4 responses
    63 views
    0 likes
    Last Post aligator  
    Working...
    X