Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How NT7 factor Ask/Bid in Backtesting?

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

    How NT7 factor Ask/Bid in Backtesting?

    Is there a definitive knowledge on how NT7 uses Bid/Ask data in Backtesting?

    I want to ensure that all my market orders executed correctly at best bid/ask (not at Close).

    What do I do ? What data do I need (prefferably description of text files structure for import) and how to ensure that NT7 is "executing" market orders at correct price if I have delivered the correct data?

    #2
    Backtesting is driven by the underlying data, aka bars data series, aka historical chart data. Unless you're explicitly backtesting a bid or ask series (supported by NT7), NT backtesting would NOT take into account historical bid/ask data.

    Comment


      #3
      Thank you. My question was how to do it in NT7 ? How do I supply ask/bid data ?

      Do I need to import 3 different files (Last, Ask, Bid) for the same symbol and NT7 will take care of the rest?

      Comment


        #4
        Originally posted by maxima View Post
        Thank you. My question was how to do it in NT7 ? How do I supply ask/bid data ?

        Do I need to import 3 different files (Last, Ask, Bid) for the same symbol and NT7 will take care of the rest?
        Several options -

        - If your historical market data provider supports historical bid/ask data then you can specify the "Price Type" when opening a chart or running a backtest and NT would request this data from the server

        or

        - You could import your own source of historical bid/ask data via Tools > Historical Data Manager > Import
        RayNinjaTrader Customer Service

        Comment


          #5
          Thanks Ray.

          1. I am not sure - there is a dropdown with 3 choices - last/bid/ask. I am not sure how do I use it... Should I run my system twice - for long trades only with Ask and then for shorts with Bid? But that doesnt make sense. Trade has to be closed in opposite direction and then I got the same problem again - I dont know the Bid/Ask for the closing trade as I am running using Ask/Bid (in opposite).

          2. On the Import tab I have option to import separately - again Last/Bid/Ask. Do I understand it right - the import is the only data supply for the option #1?

          So either way I get data - from import or data provider which has bid/ask - NT7 will separate Last/Bid/Ask always. Is that correct?

          Hence the use of these bits will be always separated including backtesting etc... Have I got it right?

          Comment


            #6
            Maybe we don't fully understand what you are after.

            - NT backtesting works against the OHLC values of a bar
            - In NT7, bars can be built off of either ASK, BID or LAST price
            - NT7 6.5 bars could only be built off of the LAST price

            Based on my statements above, what is that you want to do?
            RayNinjaTrader Customer Service

            Comment


              #7
              What I need is simple:

              I need the strategy to fill my buy orders at best ask and sell orders at best bid at the current tick.

              And here is the explanation:

              I have a test strategy (nothing fancy - close to classic MA crossover). It calculates on bar close.

              But I want to simulate a process of creation of a "proper" strategy from scratch. Proper - in terms that I can trust the backtesting results.

              The simplest thing what I am trying to achieve is to use market orders - that will remove many questions (not all but many).

              Say the strategy holds 1L position. Then it generates an exit signal. On the next bar it will simulate Fill of my Market order (placed on previous bar) at Close[0].

              However the Close price without knowing Bid/Ask at that moment doesnt make any sence for a Market order. A market order by definition will be executed at best available price (bid or ask) not the price set by the strategy.


              So probably I will need a custom Fill Type where I can actually emulate market order. Because if say the Close was Bid and I am trying to Fill Buy order - then it cant be possibly filled at that price.

              What I actually need is a little help on how to access Best Bid/Ask data within Custom Fill Type code. So I can find what was the correct price at the current bar.

              P.S. I actually use ticks to execute orders so Close = Last and the situation is not academic geeky stuff but very practically driven thoughtful development (or so I think )

              P.P.S. Is there a way to access fill type from strategy (to set its global properties to current bid/ask) or in contrary to from fill type to access strategy which called the fill to get the strategy's global properties (to read the current bid/ask) ?

              That might resolve the whole situation.

              I mean I can do some kind of global variables or even share data through text files but I really dont like solutions like that. I need a proper robust and reliable code!
              Last edited by maxima; 12-28-2009, 11:10 PM.

              Comment


                #8
                Thanks for the clear explanation...I thought we might be talking about two different things. What you wish to do is not possible unfortunately. Backtesting only works off of bar OHLC prices which in 6.5 is built off of last trade date and in NT7, can be optionally built from last, bid or ask.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Yeah I understand.

                  Is there a way to access Fill Type class from strategy code

                  or

                  from Fill Type to access strategy which called the fill?

                  Comment


                    #10
                    Originally posted by maxima View Post
                    Yeah I understand.

                    Is there a way to access Fill Type class from strategy code

                    or

                    from Fill Type to access strategy which called the fill?
                    This is not supported.
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      hi maxima

                      I have the same problem and I am trying something like this:

                      at initialize

                      // Time Frame Period for Long Trades => Only for Backtest
                      Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Ask);
                      // Time Frame Period for Short Trades => Only for Backtest
                      Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Bid);

                      at OnBarUpdate

                      if (BarsInProgress == 1) Variable0 = Close[0];
                      if (BarsInProgress == 2) Variable1 = Close[0];


                      if (BarsInProgress > 0) return;

                      I believe that "Variable0" to "Variable9" are like global user variables in the strategy.

                      at filltype

                      access user variables strategy like this

                      if (order.OrderType == OrderType.Market)
                      {
                      if (order.OrderAction == Cbi.OrderAction.Buy || order.OrderAction == Cbi.OrderAction.BuyToCover) // set fill price
                      FillPrice = Strategy.Variable0;

                      for long trades.

                      This is not very good programming, but I hope it works.
                      The main problem is that by using this process the backtest takes much more time to do the calculations, and I believe it could be easily solved by ninja trader team, avoiding us to make this kind of code.

                      Comment


                        #12
                        Aha! I was looking for something like that! Many thanks!

                        And I can tell - this is not bad programming at all. This is bad API design for Ninja and their devs should blush not you

                        BTW - How did you find thouse Variables? Hacked the code?

                        Now I need to find proper data with somewhat correct ask and bid and this should be solved!

                        Thanks again.

                        Comment


                          #13
                          Without these capabilities it's impossible to trust the back test results.
                          Even worst if your strategy is based on scalping a few tick(s)!

                          I'm curious why there aren't more people requesting this from Ninja...
                          They don't use back test ? They simply don't know that this problem exist ?
                          They trust the results blindly ?

                          A question to Ninja Trader staff :
                          Is there a way to interact with market replay data in the ninja scripts ?

                          It's kind of frustrating to know that back test historical data has the problems referenced in the previous posts, but that market replay has more or less all we need.
                          If there were a way to interact with the market replay data from the strategy that would be nice.
                          (Before you ask : It's not practical or quick enough to run a strategy on market replay for several months of data)

                          The idea from Nuno Renato could be the way to go, but I would like to read Ninja Trader comments on that coding suggestion.

                          Regards!

                          Comment


                            #14
                            It has very simple answer. 99% of people using tools like Ninja and Sierra are not traders. Most of them disappear very quick. They have no chance to realize what happened to them (ie all systems they test have no commercial value for reasons not obvious for newcomers etc).

                            P.S. I was always wondering if market replay has all we need - why is that NT development cannot simply give it to us?? Why should we wait years only to get marginal improvements.

                            This is why I am reading CQG and TT API at the moment - price on proper software after all makes sense.

                            Because if you pay £0 and get £0 in return then you performance is infinity Sounds good ? Not really as it could be either negative or positive infinity and they meet in ethernity...
                            Last edited by maxima; 01-11-2010, 04:06 AM.

                            Comment


                              #15
                              I found this variables using intellisense. I saw some guy accessing Strategy class inside FillType and I decide to see if there was something that I could use inside the class and I found this ones.
                              If ninja trader has already the bid and ask series, and functions like GetCurrentAsk(), I do not understand why they are not filled correctly during back test.
                              The backtest will be so much more realistic with correct fill prices.
                              Forget scalping keepitcool, not with this backtest

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              40 views
                              0 likes
                              Last Post alifarahani  
                              Started by Waxavi, Today, 02:10 AM
                              1 response
                              18 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by Kaledus, Today, 01:29 PM
                              5 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X