Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't use closing price during market replay

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

    Can't use closing price during market replay

    I'm currently developing a strategy and I'm trying to use the 1 tick time frame to reconstruct candles. Whenever I try to get the closing price with Close[1], I get the error "Error on calling 'OnBarUpdate' method on bar ____: Object reference not set to an instance of an object." But it's fine when I use Close[0] except for the fact that it returns the opening price of the next candle instead of the closing price of the candle that just closed (wouldn't be a problem except for the fact that they aren't the same prices). Is there a reason as to why Close[1] doesn't work for market replay?

    #2
    Hello,

    Thank you for your post.

    Most likely this is coming from somewhere else in your script. In my testing, I can access Close[1] in Market Replay. Please see the attached test script. Are you still seeing the same error when using the test script?

    Object reference not set to an instance of an object indicates that there is a null value in a variable being used in your script.

    I recommend you debug the script to narrow now exactly which line your code is hitting this error at.

    You can use prints, place a print every few lines with a new number: Print("1"); etc. That will help you see where the script gets in execution when you hit the error. Once you know what line throws the error its much easier to debug. After you have confirmed which line is throwing the error, you can add another print to then check which variable or object is null.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    55 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    37 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    17 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    17 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    49 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X