Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting Strategies with an intrabar granularity

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

    Backtesting Strategies with an intrabar granularity

    Hi,
    I'm trying to submit order on different bars, but I'm facing an obstacle right from the get go.
    My strategy runs on 5 minutes bar and I'm testing my strategy on a certain date.

    So here's my code:

    Code:
            protected override void Initialize()
            {
                CalculateOnBarClose = false;
                Add(PeriodType.Second, 10);
            }
            
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                if (BarsInProgress != 0) return;
    
                if (Times[0][0].Date != _datetest){
                    return;
                }
    
                Print(BarsArray[0].BarsSinceSession);
    
                /* REST OF THE CODE */
            }
    Right here I'm having a problem: in the output window the numbers starts from 10 up till 129. So the first 9 bars are skipped.

    What is the reason for that?

    Thanks.

    #2
    Hello benharper,

    This is either going to be due to the "BarsRequired" that you have your Strategy set to or it is going to be due to you condition that you have.

    Are you making sure that "if (Times[0][0].Date != _datetest)" is not being true as well for the first 9 bars?
    JCNinjaTrader Customer Service

    Comment


      #3
      Okay, I think I got the reason. I think it might be because Kinetick doesn't provide 10 seconds bar. When I changed it to 1 minute, it is fine. So that brings up another question: Assuming I have this data already recorded and stored in the db (because on that day the stock was on a real time chart all day), can I backtest on that data? It looks like I get only few days worth of intra-day data, but I have more than that in the db. Any way to utilize it?

      Comment


        #4
        Hello benharper,

        If you have a real-time Kinetick Account they do support Tick data which is what second or 10 Second Data Series will be based off.

        What is your "BarsRequired" set to inside of your Strategy Parameters?

        As long as you have Historical Data you may run a Backtest on your strategy yes. Note that the Historical Data that is saved on your local PC can be viewed by going to Tools -> Historical Data Manager -> Edit tab.
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        3 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        7 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X