Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on calling 'OnStateChange' when adding a data series

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

    Error on calling 'OnStateChange' when adding a data series

    Hello,

    I'm trying to add a secondary data series using this code:

    Code:
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    //Some Code
    }
    else if (State == State.Configure)
    {
    AddDataSeries(Instrument.FullName, new BarsPeriod { BarsPeriodType.Minute, Value = 5 }, "US Equities RTH");
    }
    else if (State == State.DataLoaded)
    {
    // Some Code
    }
    }​​
    My problem is that I get the following error when trying to optimize my strategy:
    Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    I know for sure the problematic line is the AddDataSeries as I do not get that error when I comment it out.
    Any ideas what am I doing wrong?
    TIA!

Latest Posts

Collapse

Topics Statistics Last Post
Started by Hwop38, 05-04-2026, 07:02 PM
0 responses
161 views
0 likes
Last Post Hwop38
by Hwop38
 
Started by CaptainJack, 04-24-2026, 11:07 PM
0 responses
308 views
0 likes
Last Post CaptainJack  
Started by Mindset, 04-21-2026, 06:46 AM
0 responses
245 views
0 likes
Last Post Mindset
by Mindset
 
Started by M4ndoo, 04-20-2026, 05:21 PM
0 responses
349 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by M4ndoo, 04-19-2026, 05:54 PM
0 responses
179 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Working...
X