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 SalmaTrader, 07-07-2026, 10:26 PM
0 responses
82 views
0 likes
Last Post SalmaTrader  
Started by CarlTrading, 07-05-2026, 01:16 PM
0 responses
41 views
0 likes
Last Post CarlTrading  
Started by CaptainJack, 06-17-2026, 10:32 AM
0 responses
23 views
0 likes
Last Post CaptainJack  
Started by kinfxhk, 06-17-2026, 04:15 AM
0 responses
31 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 06-17-2026, 04:06 AM
0 responses
31 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Working...
X