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

TickReplay BID ASK

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

    TickReplay BID ASK

    Hello,

    I'm trying to get a better understanding of using BID ASK prices within an indicator to backtest. So I understand that without TickReplay I can AddDataSeries type.Ask and then just refer to the BarsArray[1] to access the ASK price at any time. This is fine because I can import historic ASK and BID prices through the historical data import function so that's straightforward. However, I want to use TickReplay and I understand that I cannot access the secondary ask series during tick replay (https://ninjatrader.com/support/help...nstruments.htm) however live LAST data from certain providers can include the BID and ASK prices so the tick replay can work off that. I have a couple of questions on getting ASK data while using Tick Replay:
    1. Without tick replay I would code BarsArray.Closes[1][0] to access the ASK price. What is the method for retrieving BID and ASK data from the LAST data when using TIckReplay?
    2. I want to import historic data as my data provide only provides limited number of historic Tick data. As far as I can see, the LAST data containing BID and ASK data can only be taken from live data, is this correct? I want to upload years of historic LAST data that also references BID and ASK data, how can I go about this? I thought it would be as simpe as importing NAME.LAST.txt in the format YYYYMMDD HHmmss sssssss LAST;BID;ASK? However when i try to import LAST data manually it only imports the first price in the data i.e the LAST price and ignores the BID and ASK prices. How can I ensure that historical LAST data includes BID and ASK prices via manual import?
    Thanks




    #2
    Hello b16_aln,

    Thank you for your post.

    To obtain bid/ask data from Tick Replay you would need to get the Bid/Ask prices from the Bid/Ask stamped Last ticks. This could be accomplished using the OnMarketData() method. Please see the BuySellVolume indicator that comes with NinjaTrader for an example of using OnMarketData() to get Bid/Ask information from Bid/Ask stamped Last ticks.

    Viewing the BuySellVolume indicator would be done by opening a New > NinjaScript Editor window, double-clicking the Indicator folder, and selecting the BuySellVolume script to see its code.

    If you are using the same data, this could be fetched historically by adding a single tick data series to your script and checking BarsArray[1].GetBid() or BarsArray[1]GetAsk() where BarsArray[1] is a single tick Last data series.

    Importing data to follow bid/ask stamped format can be referenced below.

    https://ninjatrader.com/support/help...?importing.htm

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thanks, what about my question about how to import LAST data with bid ask stamps? How can I import that data so that I can run backtests.

      Edit: From the link it shows that I CAN import using the LAST.txt? Can you confirm this is correct, when I have previosuly attempted to import Last data with bid ask stamp the bid ask stamps seem have been ignored.
      Last edited by b16_aln; 04-01-2021, 08:16 AM.

      Comment


        #4
        Hello b16_aln,

        Thank you for your note.

        You would be able to import historical data from a .txt file as stated in the help guide documentation. However, if the text file is Last then it would only contain Last ticks. You would need to import specific files for Bid.txt and Ask.txt. For example, ES 12-09.Bid.txt or EURUSD.Ask.txt.

        Let us know if we may assist further.
        Last edited by NinjaTrader_BrandonH; 04-01-2021, 08:47 AM.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Well done for posting the same link twice and ignoring my question, are being deliberately unhelpful?

          You see the part where I reference that i've already looked at link and asked a further question on it? What part of that made you think it would be helpful to repost the link?

          Comment


            #6
            Hello b16_aln,

            Thank you for your note.

            I had not seen the edit you made to your post before replying. I have edited my previous post regarding your question.

            'You would be able to import historical data from a .txt file as stated in the help guide documentation. However, if the text file is Last then it would only contain Last ticks. You would need to import specific files for Bid.txt and Ask.txt. For example, ES 12-09.Bid.txt or EURUSD.Ask.txt.'

            Please let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Your post is confusing, you say I can import as stated in the help guide. The help guide states that;

              Tick Replay Format (Sub Second Granularity)


              Each tick must be on its own line and fields must be separated by semicolon (.



              The format is:

              yyyyMMdd HHmmss fffffff;last price; bid price; ask price;volume



              Sample data: (Note: If you wanted to import in millisecond granularity data then each line must have the remaining "0"'s behind it to import correctly.)

              20061107 000431 1000000;1383.00;1383.00;1383.25;1

              20061107 000456 1000000;1383.25;1382.50;1382.25;25

              20061107 000456 2000000;1383.25;1383.25;1383.50;36

              20061107 000537 7000000;1383.25;1383.25;1383.50;14

              So according to the help guide I can import a Last.txt file that will contain the last price, bid price and ask price. According to your latest post if I import a Last.txt file then I need to seperately import a Bid.txt file and then also an Ask.txt file. Which one is correct please, the guide or your post?

              Comment


                #8
                Hello b16_aln,

                Thank you for your note.

                After further testing, the help guide documentation is correct. You would be able to import Last, Bid, and Ask prices by importing Last.txt if it uses the format below.

                yyyyMMdd HHmmss fffffff;last price; bid price; ask price;volume

                Let us know if we may assist further.
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  Ok, thank you for clarifying.

                  In regard to getting the BID and ASK information from LAST data set, what is the most efficient way of doing this for historical data when using TickReplay and when TickReplay is off.

                  You previosuly stated that when using TickReplay I would need to AddNewSeries before I could retrieve the bid and ask info however would I not just be able to use the GetBid() and GetAsk() methods on the primary series if the primary data set is LAST.txt which was imported with the bid ask stamps included and this would save me having to add a second data series and free up resource?

                  In the same manner when TickReplay is off, instead of adding 2 extra data series of bid and ask seperately would I not be able to use the GetBid() and GetAsk() on the primary data set if it is Last.txt which was imported with the bid ask stamps included?

                  Thanks

                  Comment


                    #10
                    Hello b16_aln,

                    Thank you for your inquiry,

                    If you import Last.txt, the Ask/Bid information is not imported as an Ask/Bid series. This means that you would be importing the Last data with associated Ask/Bid prices from when that data point was recorded. To import the Ask/Bid series, you would need to import Ask.txt and Bid.txt.

                    If you decide to use Tick Replay, you could enable Tick Replay for the primary data series and get the Ask/Bid information from OnMarketData(). See the first code example in the help guide documentation below for an example of how to access historical Ask and Bid prices with Tick Replay using OnMarketData().

                    If you decide not to use Tick Replay, you could get the Ask/Bid data historically by adding a single tick data series to your script and checking BarsArray[1].GetBid() or BarsArray[1]GetAsk() where BarsArray[1] is a single tick Last data series.

                    See the help guide documentation below for more information about developing for Tick Replay.
                    Developing for Tick Replay - https://ninjatrader.com/support/help...ick_replay.htm

                    Let us know if we may assist further.
                    Brandon H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by algospoke, Yesterday, 06:40 PM
                    2 responses
                    19 views
                    0 likes
                    Last Post algospoke  
                    Started by ghoul, Today, 06:02 PM
                    3 responses
                    14 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    3 responses
                    45 views
                    0 likes
                    Last Post jeronymite  
                    Started by Barry Milan, Yesterday, 10:35 PM
                    7 responses
                    21 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by AttiM, 02-14-2024, 05:20 PM
                    10 responses
                    181 views
                    0 likes
                    Last Post jeronymite  
                    Working...
                    X