Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trading hours

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

    Trading hours

    Hi,
    I am building strategy for stock trading and doing back testing.
    I realized that the back testing result is differ when I use different trading hour. for example the result is totally off when I use cryptocurrency, default instrument & Default 24 x 5.
    any advise why this happening ?

    #2
    Hello Haryh007,

    Thanks for your post.

    If you run backtests using different trading hours then I would expect that you would see different results since different trading hours are being used.

    As a general rule for backtesting: Same Input data + Same strategy code and parameters = Same results.

    Please review the help guide document on the differences on real-time vs backtest (historical).
    http://ninjatrader.com/support/helpG...ime_vs_bac.htm

    A strategy running real-time (live brokerage account, live market simulation, Playback connection etc...) will produce different results than the performance results generated during a backtest.

    When in historical data, only the Open, High, Low, and Close will be available and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

    Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.

    Below is a link to the help guide on Calculate.
    https://ninjatrader.com/support/help.../calculate.htm

    To improve the accuracy of a backtest, you may use Tick Replay along with an added 1-tick series to have logic processed intra-bar and have orders filled intrabar.

    Tick Replay would be used to have the logic process OnEachTick or OnPriceChange with historical data, but this does not allow for intra-bar order fills. You would need to add a single tick data series and submit orders to that single tick data series for a strategy that uses Tick Replay.

    High Order Fill Resolution allows for intra-bar order fills with historical processing, but is not compatible with Tick Replay.

    Please reference the SampleIntrabarBacktest example and the following Help Guide links for more information.

    SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/helpGuides/nt8/backtesting_ninjascript_strate.htm

    TickReplay — https://ninjatrader.com/support/help...ick_replay.htm

    Developing for Tick Replay -
    https://ninjatrader.com/support/helpGuides/nt8/developing_for__tick_replay.htm?zoom_highlightsub= developing+for+tick+replay

    Additional information may be found in this NinjaTrader Forum post —
    https://ninjatrader.com/support/foru...mance?t=102504

    Please let us know if we may be of further assistance to you.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks Brandon,
      perhaps I wasn't clear when I mentioned trading hours.
      the strategy I made is limit the trading during intraday only, from 9.30 to 4pm. all shares have to be clear at the end of the day.
      theoretically the back test should be the same/similar result what ever trading hour I choose, however it is not the same.
      I fully understand that backtest would not be the same as real-time trading.
      this what I mean by trading hours, see the snapshot

      Click image for larger version

Name:	TradingHours.JPG
Views:	125
Size:	345.6 KB
ID:	1200705
      Click image for larger version

Name:	IntraDay.JPG
Views:	105
Size:	41.7 KB
ID:	1200707
      Attached Files

      Comment


        #4
        Hello Harryh007,

        Thanks for your post.

        I understand that you have a strategy that places orders at certain times and exits those orders before the close of a session with the Exit On Session Close setting checked.

        Using different Trading Hours templates between backtests would cause you to see a difference in backtesting results. The Trading Hours templates would have different session close times. This means that the Exit On Session Close orders would occur at a different time and the backtesting results would be different.

        This could be seen in the attached screenshots. In the first screenshot, we use a strategy that places orders between 8:00AM and 2:00PM with the default Trading Hours template, and run a backtest. Note that the Exit On Session Close orders occur at 3:00PM to exit an order that was placed at 1:55PM.

        In the second screenshot, we use the same strategy and settings but change the Trading Hours template to 'Default 24 x 5' and run a backtest. You can see that the same order was placed at 1:55PM, however, the Exit Time of the order is 10:00PM, not 3:00PM as seen in screenshot 1. This is because the session close times of the Trading Hours templates are different, so the Exit On Session Close order's exit times are different, causing the backtest results to differ.

        As a general rule for backtesting: Same Input data + Same strategy code and parameters = Same results.

        Let us know if we may assist further.
        Attached Files
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Hi Brandon,
          My scripts is only allowing order from 9.30 to 4 pm
          at 4 pm all order is push to be flat ( exit long or exit short)
          so there should not be discrepancy of out activity.
          That's confuse me, the result using default 34 x 5 and others (cryptocurrency for example) is differ.

          Comment


            #6
            Hello Harryh007,

            Thanks for your note.

            You would need to compare the Trades that occur in the Trades display screen and the Executions in the Executions display screen to see where the discrepancies are between backtests that use different Trading Hours templates.

            Also, prints should be added to the strategy that prints out all of the variables used to place orders as well as the time that the orders are being placed . Then you would compare those prints to understand when and how orders are being placed.

            Below is a link to a forum post that demonstrates how to use prints to understand behavior.
            https://ninjatrader.com/support/foru...121#post791121

            Let us know if we may assist further.
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7
              Thanks. I will do manual comparation later.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by chrischongpdx, Today, 09:39 PM
              0 responses
              7 views
              0 likes
              Last Post chrischongpdx  
              Started by Mountain_cast, Today, 12:41 PM
              2 responses
              9 views
              0 likes
              Last Post Mountain_cast  
              Started by dontpanic, 04-07-2015, 04:42 AM
              4 responses
              1,322 views
              0 likes
              Last Post BeachTrader11807  
              Started by algospoke, Today, 07:54 PM
              0 responses
              5 views
              0 likes
              Last Post algospoke  
              Started by Rxxar, Today, 06:26 PM
              0 responses
              10 views
              0 likes
              Last Post Rxxar
              by Rxxar
               
              Working...
              X