Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Results different real time vs historical

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

    Results different real time vs historical

    I'm using a simple script check to determine engulfing bars. Onpricechange.

    I check if the current bar is higher & lower than the previous and I also check which time the bar ticked higher and ticked lower using a DateTime Variable:

    Time_TickLower = (Time[0]);
    Time_TickHigher = (Time[0]);

    In realtime it works perfectly, I get this result:

    ENGULFER: Bar 7399
    TickHigher = 09/08/2024 16:25:30 <---
    TickLower = 09/08/2024 16:25:46 <---
    Time 16:25:46.6320000

    But when loaded historically, the exact same bar shows as this:

    ENGULFER: Bar 7399
    TickHigher = 09/08/2024 16:25:46 <---
    TickLower = 09/08/2024 16:25:46. <---
    Time 16:25:46.6320000​

    Note how the TickHigher & TickLower time in realtime is 16 seconds apart, but hostircally it's the same time. How can I fix this?

    I need to know which occurred first, the tick higher or tick lower in order to be a draw the correct object.
    Last edited by several; 08-28-2024, 03:21 AM.

    #2
    Hello several,

    When using a backtest the script is always run OnBarClose, as you use OnPriceChange in realtime that will cause differences if you are doing anything intrabar. You can try using tick replay to see if that brings the results closer, you would otherwise need to use the playback connection to simulate OnPriceChange.

    Comment


      #3
      Hey, I'm testing via Market Replay, these are the results from the output there.

      If I put the playhead before these bars and play, it works.

      If I move the playhead just after the bars, and they are loaded historically, it doesn't work.
      Last edited by several; 08-28-2024, 10:38 AM.

      Comment


        #4
        Hello several,

        Right, that is the same situation. Historical bars are calculated OnBarClose. To simulate OnPriceChange you need to run the script in realtime so putting it before the time and playing through it would be correct.

        Comment


          #5
          ah ok understood thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          650 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          577 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X