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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      557 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