Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

End of day trading with daily bars

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

    End of day trading with daily bars

    Hello,

    Back-testing using daily bars, my goal is to have the positions entered at the same day the signal is generated, at the Close price. I know that this is a general problem with bar-by-bar trading frameworks - is it possible with Ninjatrader?

    Thanks in advance,
    Ivan

    #2
    Hi Ivan,

    Thanks for writing in today.

    You are correct but there is a workaround.

    With backtests Calculate on bar close is always true. This means that the OnBarUpdate method is only run when a bar closes (which happens when the new bar opens or when the daily settlement information is received which comes as a tick and won't come during your backtest). This means that an order will be on the next bar as it will have a execution time of the start of the next bar because it is executed after the bar has closed.

    The workaround for this is to use intra bar data for your processing while using the primary data series as the data source for calcuations. This is called intra-bar granularity. If you want to check for things on a tick by tick basis you can add a second data series with a tick interval and process on that interval using the data from the primary daily series.

    If you want to reduce the amount of processing the script has to do and you are ok with OnBarUpdate being run in a minute interval you can add a second data series with a minute interval yet use the daily bar information for your calculations.

    Below is a link to an official reference sample that was put together to demonstrate how to use intrabar granularity.
    http://www.ninjatrader.com/support/f...ead.php?t=6652
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      For this to work, do I need a feed with intraday data or is there a way to "generate" the minute bars?

      Comment


        #4
        Hi Ivan,

        The data added to a strategy will always be needed to run your strategy.

        If you are backtesting you will need the intra-day historical data. If you are running live you will need both the intra-day historical data and a live data feed.

        You can generate minute bars from tick data. You can generate daily bars from tick or minute data; but you cannot generate tick data from minute data. You cannot generate tick or minute data from daily data.

        Below is a link to the help guide on Historical & Real-Time Data. Please see the chart in the section 'Understanding the data provided by your connectivity provider' to see which technologies offer intra-day historical data.
        http://www.ninjatrader.com/support/h...rical_data.htm
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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