Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

When in Replay Connection, why is historical data being loaded and displayed?

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

    When in Replay Connection, why is historical data being loaded and displayed?

    Hello NT8 Support,

    I have downloaded the Replay MES (Micro ES) data for the week of Feb 27 (Sunday night) through March 4 (Friday night). Further, I removed (deleted) all MES Historical Data.
    Click image for larger version

Name:	NT8-MarketReplayData.PNG
Views:	236
Size:	40.0 KB
ID:	1193836

    Why is it then, when I start the Replay Connection that Historical Data is downloaded and displayed on my replay chart?
    Click image for larger version

Name:	NT8-HisotricalData.PNG
Views:	122
Size:	7.0 KB
ID:	1193837
    So, okay... whatever, it's loaded. In the Playback control window, I use Go To.. to set the date/time I want to start from. In this case, it's Feb 27, 7:39:59 PM, just before another candle is rendered. I then load and enable my strategy.

    WHY DOES NT8 APPLY THE STRATEGY TO ALL THE HISTORICAL DATA THAT WAS LOADED & DISPLAYED? It shows all the "potential" trades that MIGHT have happened. Note that these trades are bogus because they are done on the 5-minute candle, not per price change which my strategy uses. Please explain the logic in doing this - makes no sense.

    This is causing an error in the OnExecutionUpdate upon session close:

    protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity,
    Cbi.MarketPosition marketPosition, string orderId, DateTime time) {

    if (execution.Order != null) {
    Order order = execution.Order;
    Print("*** EXECUTION Order Name: " + order.Name + " | State: " + order.OrderState + " | Entry Signal: " + (order.FromEntrySignal == null ? "" : order.FromEntrySignal));


    Error from Output window:
    *** EXECUTION Order Name: Exit on session close | State: Filled | Entry Signal:
    Strategy 'MyStrategyName/182715530': Error on calling 'OnExecutionUpdate' method on bar 551: Object reference not set to an instance of an object.

    As you can see, the error is occurring in the FromEntrySignal property. Even with the null check added the code (already there as shown), still get the error.

    Here's the chart at Bar 551. It isn't the first session close of the historical data that NT8 decided to load.
    Click image for larger version

Name:	NT8-Chart.PNG
Views:	120
Size:	6.0 KB
ID:	1193838

    The full Output window text is attached. TraceOrders is set to true.

    Please help!
    Thanks,
    Matt

    #2
    Hi Matt, thanks for posting. The backtest is used to calculate the strategy's most current position. It could have made a trade on the historical data that has yet to close. The default "Startup Behavior" setting for strategies is WaitUntilFlat. You can change this to ImmediatelySubmit, Synchronize account to start trading immediately. Documentation

    Or you can add this to the top of OnBarUpdate to simply ignore all the historical data:

    if(State == State.Historical)
    return;

    The platform will run strategies OnBarClose in the historical data by default, you need to turn "Order Fill Resolution" to High, 1 tick to fill the orders on a 1 tick series for better historical accuracy. Documentation

    For the null object, it might not be the execution.Order object that is null (it most likely is not since you are checking for it in the code). You can use Visual Studio debugging the find the exact line that is causing the exception:


    Kind regards,
    -ChrisL

    Comment


      #3
      Hello Chris,

      Thank you for the response. (Sorry for my tone.) Thank you for the documentation links. They explain well the different scenarios that are possible and how to handle them. Also, thank you for the if (State == State.Historical) return; code snippet. I'll most likely use that.

      As for the null error, I don't think that is in my code based on the Output text. However, I'll make the above adjustments first. I think that error will go away as a result.

      Thank you, again!
      Matt

      Comment


        #4
        Quick follow up...

        Thank you, Chris. Adding this bit of code, if (State == State.Historical) return;
        made all the difference. It addressed my issues - no erroneous trades, the null error went away, and setting up replay is much faster!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        52 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X