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 Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,769 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    30 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    943 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    10 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    7 views
    0 likes
    Last Post rocketman7  
    Working...
    X