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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      160 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      307 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      244 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      348 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      178 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X