Announcement

Collapse
No announcement yet.

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