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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    157 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    91 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    143 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    130 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    107 views
    0 likes
    Last Post CarlTrading  
    Working...
    X