Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Thank you Gaby

      Regards, Dan

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by giogio1, Today, 02:56 AM
      0 responses
      1 view
      0 likes
      Last Post giogio1
      by giogio1
       
      Started by Skifree, Today, 02:42 AM
      0 responses
      4 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by cathypriester, Today, 01:50 AM
      0 responses
      5 views
      0 likes
      Last Post cathypriester  
      Started by DJ888, 07-11-2024, 09:28 PM
      3 responses
      28 views
      0 likes
      Last Post CassieQuinn  
      Started by sunny168, 09-27-2023, 10:37 PM
      2 responses
      449 views
      0 likes
      Last Post AshleyBoost  
      Working...
      X