Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

plotting with Second Series

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

    plotting with Second Series

    I have an indicator with 2 dataseries. The indicator determines whether the bar is Up, Down, or Flat and assigns a value of +1,-1 or 0 respectively.

    Problem is: I can’t get it to work correctly and think the problem is with BARTypeSignal.

    Anyone got any ideas? This code works with 1 dataseries but not 2 dataseries.

    thanks



    #region Variables
    private DataSeries barType;
    #endregion


    protectedoverridevoid Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Bar, "BARTypeSignal")); // Plot 0

    barType = new DataSeries(this); // Relates to whether bar is up/down/flat
    }

    protectedoverridevoid OnBarUpdate()
    {

    ////-------------SETS THE 2nd SERIES BARS TO +1 FOR UP, -1 FOR DOWN, 0 FOR FLAT----------------------------
    if(Closes[1][0] > Opens[1][0])
    {barType.Set(1);}
    else
    if(Closes[1][0] < Opens[1][0])
    {barType.Set(-1);}
    else
    {barType.Set(0);}
    ////--------------------------------------------------------------------------------------------------------

    BARTypeSignal.Set(barType[0]);

    }


    #region Properties

    //--------Plots +1 for Up, -1 for Down, and 0 for Flat---------------------------------\
    [Description("Plots the up/down/flat Signal")]
    [Category("mySignal")]
    public DataSeries BARTypeSignal
    {
    get { return Values[0]; }
    }

    #endregion


    or is there a better way to approach this with two dataseries?

    #2
    Hi Velocity,

    You're accessing bar objects for a secondary series but have not added the series to the Initialize method.

    Please see the sample multi instrument strategy through Tools > Edit NinjaScript > Strategy > SampleMultiInstrument

    http://www.ninjatrader-support.com/HelpGuideV6/MultiTimeFrameInstruments.html
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X