Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Bid/Ask During Backtest

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

    #16
    I can do a Playback while disconnected, using historical data and get Bid and Ask prices via Market Data. I can do a simulator connection and even get fake bid and ask prices via Market Data. Why is Strategy Analyser not consistent with the rest of the platform? I am on the verge of dumping Ninjatrader for good now. I believe that Ninjatrader is only good for the most simplistic one-file retailer strategies e.g. "If moving average cross above go long if cross below enter short" anything more complex that depends on multiple classes is useless.

    And any Technology Company where the recommended advice is "Have one implementation for LIVE and a completely different implementation for Testing" immediately causes Alarm bells for me.

    Kindly adhere to my earlier request and ask one of your Project Managers to intervene on this thread. I simply cannot believe the answers you are giving me; that the official Ninjatrader advice is to totally change the implementation in order to support the strategy analyzer; an implementation that works in every other part of Ninjatrader. It will take weeks; and I will need to maintain 2 versions which is high risk. Not to mention the fact that I won't actually be testing the same version of the strategy that is used in LIVE. It cannot be the official advice.

    I wasted weeks being your chief regression tester - someone's got to do it, huh? You guys clearly don't. And now I'm faced with a total rework of my system or I'm not able to backtests. Nah mate. I am done with this.
    Last edited by reach4thelasers; 06-16-2017, 06:33 AM.

    Comment


      #17
      Hello reach4thelasers,

      Thank you for your response.

      The information provided previously is correct. If you wish to use Bid and Ask historically you would either add the additional Bid and Ask bar series or your would use Tick Replay. If you want to backtest without changing implementation of your strategy consider running the Playback Connection to playback the market as if it was realtime data.

      For information on Playback please visit the following link: http://ninjatrader.com/support/helpG...connection.htm

      Please let me know if you have any questions.

      Comment


        #18
        Sorry are you a project manager?

        Comment


          #19
          Hello reach4thelasers,

          Thank you for your response.

          I discussed your case with Product Management and they have advised me to respond as follows.

          There are 3 concepts to understand:
          • OnBarUpdate, which occurs based on 'bar' data. Bar data being considered 'historical data'.
          • OnMarketData, which occurs as a realtime L1 market data update comes into the platform. With NinjaTrader 7 this only would be called as realtime data comes in and would be called for all ask/bid and last updated.

          Now we introduce Tick Replay with NinjaTrader 8:
          • Indicators in NinjaTrader 7 that were coded to work in OnMarketData would not work in historical and only could work in live due to the nature of OnMarketData. At the time when we developed NinjaTrader 7 providers typically would not support bid/ask historical data either.
          • At the time of this writing very few historical data vendors still do not store bid/ask historical data or store it in severely limited fashion. However what is now stored on some providers (Kinetick, IQFeed, Continuum, Rithmic) is a bid/ask 'stamp' on a last event for 1 tick historical data. This is not true bid/ask recording of data but instead simply a stamp of the current bid and current ask at the time of a trade.
          • We wanted to expose that data, to do that we needed to simulate the strategy like it was running live (Tick Replay) and call OnMarketData and expose on the 'last' event the 'bid' and 'ask' stamp stored on that last event on the server.

          This is what we now support with tick replay. Tick replay has a lot of 'gotchas' and things that need to be understood, not all indicators/strategies that are written for OnMarketData will work in TickReplay only certain types will. Hence this is why we require separate logic for accessing bid/ask in OnMarketData as part of TickReplay. Since you need to code specifically for it.

          To drive the point home even further:
          1. An indicator which counts the number of bid events vs number of ask events in OnMarketData. This indicator would work live since you get 3 streams of independent data in OnMarketData. Ask/Bid and Last. This indicator WOULD NOT work in Tick Replay, since Tick Replay only throws last events with the recorded bid/ask at the time of last.
          2. Indicator which counts the last events but counts last events at the bid as sell and last events at the ask as sells. This would work in Tick Replay since we have last historical 1 tick data which has the bid/ask stamped data at the time last occurred.

          Now that we have the understanding out of the way. I would advise you caution with Tick Replay strategies. There are a number of gotchas we detail in our help guide in the Tick Replay section I believe you have been linked earlier. Tick Replay wasn't designed for better strategy simulation, simply was designed to expose additional bid/ask data stamped 1 tick data to indicators which would do the type of analysis above.

          Please let me know if you have any questions.

          Comment


            #20
            Patrick,

            Appreciate the detailed response.

            I've attached a MarketDataProxy that I threw together in an hour that produces Historical Bid and Ask Updates. Just tell it the spread, and it takes the LAST price update generated via TickReplay and produces a corresponding Bid and Ask update.

            Why can't ninjatrader do this? Why do you all think that it is a better solution to provide nothing, and to completely break strategies that depend on BID & ASK data. Even if Ninjatrader just pushed out the Last price three times on the BID, ASK and LAST events it would be better than only triggering LAST. Things would keep working and we would be able to do backtests. I cannot understand why you are happy with the Status quo. The reason I wanted to discuss this with a PM is to let them know that the exact prices don't matter as long as the event triggers things would keep working, and its easy to simulate Bid and Ask prices. We are talking about a tiny price difference. But if you're placing Stop or Limit orders it is important that strategies consider the Bid and Ask.

            The decision of Ninjatrader's product development team to provide NOTHING for Bid and Ask events during back-tests is the wrong decision. It results in a totally unrealistic market simulation.

            But it seems like your playing gatekeeper today and I am not able to covey this.

            Anyway. Proof. historical Bid and Ask:


            Code:
            MarketDataProxy| State:Historical, MarketDataType:Last Price:140.287
            MarketDataProxy| State:Historical, MarketDataType:Ask Price:140.317
            MarketDataProxy| State:Historical, MarketDataType:Bid Price:140.287
            MarketDataProxy| State:Historical, MarketDataType:Last Price:140.287
            MarketDataProxy| State:Historical, MarketDataType:Ask Price:140.317
            MarketDataProxy| State:Historical, MarketDataType:Bid Price:140.287
            MarketDataProxy| State:Historical, MarketDataType:Last Price:140.287
            MarketDataProxy| State:Historical, MarketDataType:Ask Price:140.317
            MarketDataProxy| State:Historical, MarketDataType:Bid Price:140.287
            MarketDataProxy| State:Historical, MarketDataType:Last Price:140.287
            Enabling NinjaScript strategy 'HistoricalMarketDataTestStrategy/108359003' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
            MarketDataProxy| State:Realtime, MarketDataType:Ask Price:140.299
            MarketDataProxy| State:Realtime, MarketDataType:Last Price:140.287
            MarketDataProxy| State:Realtime, MarketDataType:Ask Price:140.3
            MarketDataProxy| State:Realtime, MarketDataType:Last Price:140.287
            MarketDataProxy| State:Realtime, MarketDataType:Ask Price:140.299
            MarketDataProxy| State:Realtime, MarketDataType:Last Price:140.287
            MarketDataProxy| State:Realtime, MarketDataType:Ask Price:140.3
            MarketDataProxy| State:Realtime, MarketDataType:Last Price:140.287
            MarketDataProxy| State:Realtime, MarketDataType:Last Price:140.287
            MarketDataProxy| State:Realtime, MarketDataType:Ask Price:140.299
            MarketDataProxy| State:Realtime, MarketDataType:Last Price:140.287
            MarketDataProxy| State:Realtime, MarketDataType:Ask Price:140.287
            Attached Files
            Last edited by reach4thelasers; 06-19-2017, 02:55 AM.

            Comment


              #21
              Made some changes to my Bid/Ask Historical Market Data Proxy.

              Note: The the OnMarketData events in ninjatrader don't fire at all during historical.

              therefore if you just need one Bid/Ask price per bar during historical. For OnBarClose Strategies, then call EnsureHistoricalBidAsk from OnBarUpdate.

              If you want Historical Bid/Ask for each tick. call EnsureHistoricalBidAsk(marketDataUpdate). This passes in the LAST price TickReplay event and will push out corresponding Bid/Ask prices during Historical.
              Attached Files
              Last edited by reach4thelasers; 06-19-2017, 11:52 AM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Mizzouman1, Today, 07:35 AM
              4 responses
              18 views
              0 likes
              Last Post Mizzouman1  
              Started by philmg, Today, 01:17 PM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Started by cre8able, Today, 01:01 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by manitshah915, Today, 12:59 PM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_Erick  
              Started by ursavent, Today, 12:54 PM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X