Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Finding Prior Close For First Day of Backtest

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

    Finding Prior Close For First Day of Backtest

    Hi

    I've created a simple strategy which just retrieves and prints the prior close value for each day. This seems to be working fine, except for the first day of the date range selected in Strategy Analyzer, where the previous close is returned as 0.

    I've tried adding in the same instrument as an additional data series, using a type of 'day' and a value of 5, thinking that this might load that previous session data, but this doesn't appear to have worked. Is there any way to obtain this, or do I just have to exclude any calculations on the first day of the test range?

    Thanks

    #2
    Hello Dan_TUK,

    Welcome to the forum!

    This would be expected since the analyzer is only loading data from your selected date range. For example, if you select 6/11/24 as the start date then it will not be able to retrieve data from 6/10/24.

    You will need to set the start date to 1 day before you want the strategy to start processing.

    Additionally, use a CurrentBar check to make sure at least 1 daily bar was processed, if not return.



    After 1 daily bar has been processed, the CurrentBar check will allow the strategy to start working and process the rest of the strategy's logic. At that point you can access the previous day's data on the actual start date you intended.

    This way you can make sure your added day series has enough bars loaded in order for you to access the index you are looking for.

    Please let us know if you have any further questions.

    Comment


      #3
      Thank you Gaby

      Regards, Dan

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      51 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      128 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X