Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

plotting and understanding Values[0], Values[1]

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

    plotting and understanding Values[0], Values[1]

    I am inquiring what values[0], values[1] is. I can not see any initialization for Values

    All this is doing is painting red and green bars on volume. I am planning to do the same but I need 5 colors for different scenarios.
    How does the indicator know what is red and what is lime? I understand the add new plot but where is the array telling which color to use.

    dataseries IndicatorBase.Values.

    Lastly why is there a Values[1].Reset() ?




    protected override void Initialize()
    {
    Add(new Plot(new Pen(Color.Lime, 2), PlotStyle.Bar, "UpVolume"));
    Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Bar, "DownVolume"));
    Add(new Line(Color.DarkGray, 0, "Zero line"));
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (Close[0] >= Open[0])
    {
    Values[0].Set(Volume[0]);
    Values[1].Reset();

    }
    else
    {
    Values[1].Set(Volume[0]);
    Values[0].Reset();
    }
    }
    }
    }

    #2
    Hello ballboy11,

    If you are referring to Values (with a capital V) this is a special collection that is maintained by the NinjaTrader core.

    Each time you call AddPlot() this will automatically add an element to Values.

    Values is a collection of collections.

    Values[1] (Values[plotSeriesIndex]) would refer to the second plot.
    Values[1][1] (Values[plotSeriesIndex][barAgoValue]) would refer to the second to most recent bar of the second plot.



    Your plot style is bar and is not set to line. This means it will make a histogram. You have two plots on top of each other. Whichever is on top will be the one that shows.

    The .Reset() will remove a value from a bar if it was previously set and set this back to no value. This is used if you are checking bars have values with .ContainsValue().

    Last edited by NinjaTrader_ChelseaB; 04-19-2017, 03:41 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sjsj2732, 03-23-2026, 04:31 AM
    0 responses
    77 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    313 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    314 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    149 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    114 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X