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 fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,404 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        95 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        7 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        159 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        8 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X