Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 ZenCortexCLICK, Today, 04:58 AM
    0 responses
    2 views
    0 likes
    Last Post ZenCortexCLICK  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    172 responses
    2,280 views
    0 likes
    Last Post sidlercom80  
    Started by Irukandji, Yesterday, 02:53 AM
    2 responses
    17 views
    0 likes
    Last Post Irukandji  
    Started by adeelshahzad, Today, 03:54 AM
    0 responses
    4 views
    0 likes
    Last Post adeelshahzad  
    Started by Barry Milan, Yesterday, 10:35 PM
    3 responses
    13 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X