Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Are all ticks used when backtesting in NT8?

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

    Are all ticks used when backtesting in NT8?

    Are all ticks used when backtesting in NT8?
    (This goes for backtesting automated trading algorithms via the Strategy Analyzer, Simulator, Market Replay and/or any other backtesting tools NT8 offers.)

    For example:

    1. Does NT8 use Bid ticks and Ask ticks when backtesting? Or does it just use Last ticks?
    2. Does NT8 create fake ticks within a bar to fill in the gaps between the bar's Open, High Low and Close (like Metatrader) when backtesting? Or does it only use the real Ticks that happened within the bar?
    3. Does NT8 show a trade closed at the actual Tick's price within a bar that activated a Stoploss or Takeprofit when backtesting? Or will NT8 just show the trade closed at the Open, High, Low or Close of a bar if a stoploss or takeprofit was activated within a bar (like in NT7)?

    Thanks!

    #2
    Hello Matheyas5,

    Thanks for your post.

    For market replay yes, all of the ticks are processed, same as NT7.

    For the strategy analyzer, it is the same as NT7 except that in NT8 historical fill processing has the added option of setting the order fill resolution. Please see: http://ninjatrader.com/support/helpG...ical_fill_.htm Also, you can select Tick Replay (provided your data provider provides historical tick data)

    For the stoploss and profit target, if limit orders are used, they will show at the price level, same as NT7, if market orders are used they would show at the next bar.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      When using the Strategy Analyzer to backtest and optimize a strategy, is it possible to have my strategy monitor every change in Bid/Ask Price and Volume (including such changes that happened in between Last prices)?

      I read over the link you sent and it was not 100% clear if this is possible, though it seems it might be.

      I ask, because I have strategies that take all changes in Bid/Ask price and volume into account, and would like to be able to Optimize these strategies with Ninjatrader's Optimization tools.

      Thanks.
      Last edited by Matheyas5; 02-12-2016, 11:58 PM.

      Comment


        #4
        Hello Matheyas5,

        Thanks for your reply.

        From the Helpguide: "NinjaTrader has the ability to use historical bid and ask price series in your NinjaScript instead of only being able to use a last price series. The following outlines the intricacies of this capability:

        • You can have multiple bid/ask/last series in your NinjaScript indicator/strategy. Please use the AddDataSeries() method to add these series to your script.
        • The historical bid/ask series holds all bid/ask events sent out by the exchange. This would not be equivalent to the bid/ask at a specific time a trade went off.
        • When processing your NinjaScript, the historical bid/ask series would have the historical portion triggered in the OnBarUpdate() method only. OnMarketData() method events for the historical bid/ask series would only be triggered in real-time."


        Please see: http://ninjatrader.com/support/helpG..._ask_serie.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Paul View Post
          Hello Matheyas5,
          • When processing your NinjaScript, the historical bid/ask series would have the historical portion triggered in the OnBarUpdate() method only. OnMarketData() method events for the historical bid/ask series would only be triggered in real-time."[/I]
          using_historical_bid_ask_serie.htm[/url]

          What if during the backtests/optimization i want certain things (like a MACD) to be calculated only once the bar has closed (not during) and other things to be calculated whenever new bid/ask data comes in (which can happen during a bar)?

          Thanks Paul

          Comment


            #6
            Hello Matheyas5,

            Thanks for your reply.

            When you add the bid/ask dataseries to your strategy you will now be processing as a multi series script and for that you will have BarsInProgress pointers so that you can code based on the value of BarsInProgress. You will need to become very familiar with: http://ninjatrader.com/support/helpG...nstruments.htm

            In a nutshell if your chart bars were 5 minute bars and you added 1 tick Bid, 1 tick ask and 1 tick last these would be known as BarsInProgress 0, 1, 2, 3. So in the case of BarsInProgress 0 (5 minute bars) this is when you would calculate your MACD:

            if (BarsInProgress == 0)
            {
            // calculate end of 5 minute bar stuff here
            }
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Great!

              Do you happen have a link to a full NT8 strategy example that uses multiple different bars (with each bar having a different timeframe)?

              The closer the strategy is to the one you described here the better

              In a nutshell if your chart bars were 5 minute bars and you added 1 tick Bid, 1 tick ask and 1 tick last these would be known as BarsInProgress 0, 1, 2, 3. So in the case of BarsInProgress 0 (5 minute bars) this is when you would calculate your MACD

              Comment


                #8
                Hello Matheyas5,

                Thanks for your reply.

                Ninjatrader provides in your Ninjatrader the strategy: SampleMultiTimeframe as a standard example of using more than one time frame.

                In addition from the reference files on the forum,"Backtesting NinjaScript Strategies with an intrabar granularity" : http://ninjatrader.com/support/forum...ead.php?t=6652
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Paul View Post
                  Hello Matheyas5,

                  Thanks for your reply.

                  When you add the bid/ask dataseries to your strategy you will now be processing as a multi series script and for that you will have BarsInProgress pointers so that you can code based on the value of BarsInProgress. You will need to become very familiar with: http://ninjatrader.com/support/helpG...nstruments.htm

                  In a nutshell if your chart bars were 5 minute bars and you added 1 tick Bid, 1 tick ask and 1 tick last these would be known as BarsInProgress 0, 1, 2, 3. So in the case of BarsInProgress 0 (5 minute bars) this is when you would calculate your MACD:

                  if (BarsInProgress == 0)
                  {
                  // calculate end of 5 minute bar stuff here
                  }
                  Thanks Paul. Once I have coded the strategy you mentioned in post 6 of this thread (quoted above), what would I select in the two areas circled in Red in attached 1.jpg when backtesting (or optimizing) it in the Strategy Analyzer?

                  The goal would be to get the Backtest (and Optimization) results to be as accurate as possible (especially getting Takeprofits and Stoplosses to fill at the actual Bid or Ask prices that caused them, even if the Bid or Ask price happened in between a Last price.
                  Attached Files
                  Last edited by Matheyas5; 02-17-2016, 01:13 AM.

                  Comment


                    #10
                    Hello Matheyas5,

                    Thanks for your reply.

                    In the examples I referenced 5 minute bars when you were asking about calculating at the end of the bar. You have not specified what your main data series is but that is what you would select for the 1 red area.

                    For the order fill resolution as you have added already a 1 tick data series I am not sure what value this would be but you could set it to High, tick, value 1.
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Paul. Would the setting you mentioned below allow Takesprofits and Stoplosses to fill at Bid or Ask prices that happened in between Last prices?

                      Originally posted by NinjaTrader_Paul View Post
                      Hello Matheyas5,
                      For the order fill resolution as you have added already a 1 tick data series I am not sure what value this would be but you could set it to High, tick, value 1.

                      Comment


                        #12
                        Hello Matheyas5,

                        Thanks for your reply.

                        I need to back-up here and make a correction.

                        You would not need to add the bid/ask/last dataseries to your strategy if you use the "Tick Replay" option in the strategy analyzer. (To "enable" the tick replay option, if you do not see it, go to tools>Options and enable it in the market data section, "show Tick Replay").

                        If you enable Tick replay and then set the Order fill resolution to High/Tick/1 you can then get fills at the bid or ask prices that happened between.
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          Cool.

                          I just tried it with the "tick replay" setting you mentioned. It worked, but it did not plot each Bid and Ask tick on the strategy analyzer's chart. Two questions with this in mind:

                          1. To get each 1 tick Bid bar and 1 tick Ask bar to plot in the Strategy Analyzer's Chart, would I simply have to code the plots into the strategy?

                          2. Once I have accomplished item 1 above, will Stoplosses and Takeprofits in the Strategy Analyzer's chart plot on the actual 1 tick Bid bar or 1 tick Ask bar (that could have happened on or in between a Last tick) that caused the Stoploss or Takeprofit?
                          Or would they just plot on the main data series (such as a 5 minute bar, if I was using a 5 minute bar as the main data series). In NT7 I was only able to get the mentioned Stoploss and Takeprofits to plot on the main data series bars.

                          Comment


                            #14
                            Hello Matheyas5,

                            Thanks for your reply.

                            Before you code that up, you may want to create this in a simple chart to see what it looks like with the tick series and the main bars and see if that will work for you.

                            The entries and exits will be on whatever bar series you are applying the trades to.
                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              The entries and exits will be on whatever bar series you are applying the trades to.
                              Are you saying my trades could to sent to (and plotted) on multiple different bar series on the same chart? If so, is there a link to a code example of how to do this that you can send me?

                              Thanks!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by guillembm, Yesterday, 11:25 AM
                              2 responses
                              9 views
                              0 likes
                              Last Post guillembm  
                              Started by junkone, 04-21-2024, 07:17 AM
                              9 responses
                              68 views
                              0 likes
                              Last Post jeronymite  
                              Started by trilliantrader, 04-18-2024, 08:16 AM
                              4 responses
                              20 views
                              0 likes
                              Last Post trilliantrader  
                              Started by mgco4you, Yesterday, 09:46 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by wzgy0920, Yesterday, 09:53 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post wzgy0920  
                              Working...
                              X