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

Indicator calling another Indicator with new DataSeries(this)

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

    Indicator calling another Indicator with new DataSeries(this)

    I am calling an existing custom indicator that has "new DataSeries(this)". I get an error "System.NullReferenceException: Object reference not set to an instance of an object" within OnBarUpdate()

    Using this custom indicator by itself plots the values correctly on the chart without causing the error to occur. Please help!


    private int period = 21;
    public DataSeries TmpDataSeries;

    protected override void Initialize()
    {
    Add(new Plot(Color.Green, "TmpAngle"));
    CalculateOnBarClose = true;
    Overlay = false;
    TmpDataSeries = new DataSeries(this);
    }

    protected override void OnBarUpdate()
    {

    TmpDataSeries.Set(ChartControl.GetYByValue(Bars,SM A(period)[0]));
    .
    .
    .

    }
    Last edited by ihercules; 05-27-2016, 01:31 AM.

    #2
    Originally posted by ihercules View Post
    I am calling an existing custom indicator that has "new DataSeries(this)". I get an error "System.NullReferenceException: Object reference not set to an instance of an object" within OnBarUpdate()

    Using this custom indicator by itself plots the values correctly on the chart without causing the error to occur. Please help!


    private int period = 21;
    public DataSeries TmpDataSeries;

    protected override void Initialize()
    {
    Add(new Plot(Color.Green, "TmpAngle"));
    CalculateOnBarClose = true;
    Overlay = false;
    TmpDataSeries = new DataSeries(this);
    }

    protected override void OnBarUpdate()
    {

    TmpDataSeries.Set(ChartControl.GetYByValue(Bars,SM A(period)[0]));
    .
    .
    .

    }
    You will have to think up some new logic if you want to be able to call that from any other class. When called from another class, a ChartControl does not exist, so if you are setting a DataSeries with a call to ChartControl, you are dead in the water.
    Last edited by koganam; 05-27-2016, 10:45 AM.

    Comment


      #3
      Thanks! I will code it with an alternate approach

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by PaulMohn, Today, 03:49 AM
      0 responses
      7 views
      0 likes
      Last Post PaulMohn  
      Started by inanazsocial, Today, 01:15 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by rocketman7, Today, 02:12 AM
      0 responses
      10 views
      0 likes
      Last Post rocketman7  
      Started by dustydbayer, Today, 01:59 AM
      0 responses
      4 views
      0 likes
      Last Post dustydbayer  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      5 responses
      23 views
      0 likes
      Last Post trilliantrader  
      Working...
      X