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 sjsj2732, Yesterday, 04:31 AM
      0 responses
      24 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      282 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      280 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      131 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      90 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X