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

How to get tick data with a line tool

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

    How to get tick data with a line tool

    Hello,

    I am new to the ninja script. I am trying to get # of bids and ask data in a custom drawing tool. I understand I can use OnMarketData event in a custom strategy to get the tick level data, but I am not sure how to get the same data in a Drawing tool. I would appreciate any help. The basic idea is to draw a line and calculate how many Buys vs Sells from where the line starts and ends.


    Thanks!

    #2
    Hello utrivedi,

    Welcome to the NinjaTrader forums!

    Drawing tools don't have OnBarUpdate() or OnMarketData(). Instead of updating when the bar updates or when data is received, drawing tools update in OnRender() when the chart needs to re-render. These use the Bars object to get bar information supplied to OnRender in a non-data-driven method with the anchor points or with the Bars.GetClose(), .GetOpen(), etc.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the response. I went through other posts and figured out how to achieve what I want. One other issue I am facing is how to get historical tick data in my indicator.

      I have the tickreplay turned on and everything, but when I put print in the OnMarketData() I only see tick data starting the time I put indicator on the chart.

      I also have a condition if(!Bars.IsTickReplay) in OnStateChange() State.COnfigure conditions, but I don't see any errors printed out.

      Comment


        #4
        Hello utrivedi,

        Are you still coding a drawing tool script or is this a new inquiry for a different script?

        OnMarketData() would update historically with TickReplay enabled.


        Do you have historical tick data available from your connected data feed or provider?
        Can you open a 1 tick chart on that instrument?

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Apologies for being unclear. I am still using the Drawing tool to draw the custom line. I am using the new Indicator to read that line and the collect bid/ask from the start of the line to the end of the line. I am using the Demo Data that is provided by Ninja, and I checked, I do get the historical tick data when open a 1 tick chart. But, it doesn't print the historical tick on the output. I'have attached the indicator.


          Last edited by utrivedi; 09-08-2020, 12:22 PM.

          Comment


            #6
            Hello utrivedi,

            I can't test this because there are dependencies and it is not an export.
            Hello, I have an input parameter message box pop keeps up when I have removed all instances of the input parameter... This is new.. I'm always adding and removing input parameters when creating strategies and have never had any problems with this pop up message in the past.. The only way to get rid of this annoyance is to


            I have instead make a simple script to test. If you are trying to understand something, always start simple. Remove complexity.

            Below is a link to a video of the test.
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks for your quick response. I think I figured out the issue. The MarketDataType for historical data la always MarketDataType.Last, I am only printing on MarketDataType.Ask/Bid. So my next question would be how would I know if it is bid or ask? or I wouldn't?

              Comment


                #8
                nvm I think I can do this

                if (e.Price >= e.Ask)
                {
                myProfile.AddAskVolume
                }
                else if(e.Price <= e.Bid)
                {
                myProfile.AddBidVolume
                }

                Comment


                  #9
                  Hello utrivedi,

                  Historical tick data is last data, but may be ask bid stamped. If so, it has to be called a specific way,

                  See the help guide linked in post #4 'Accessing the current best bid and ask at the time of a trade'.
                  Last edited by NinjaTrader_ChelseaB; 09-09-2020, 08:26 AM.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10

                    Got it. Another issue I found. If you see the screenshot below, the price for the 1st tick shows 11429 on 9/6/2020 at 6 pm. But the price was not at that level at 6pm, lowest it was at 11501 for the 6:01 pm bar.

                    Any ideas?




                    Click image for larger version

Name:	data.png
Views:	441
Size:	190.0 KB
ID:	1117476


                    Comment


                      #11
                      Hello utrivedi,

                      In the script, print the marketDataUpdate.Time with milliseconds.
                      How can I get the current time of the broker (server) in the format &quot;HH:mm:ss&quot;. When I get Time[0].ToString(&quot;HH:mm:ss&quot;) even using Calculate.OnEachTick, I only get hours and minutes, without seconds.


                      On the chart open a 1 tick chart and show the data box. Then place the mouse over the tick that opens the session so we can see the values of that tick.

                      Then please post the updated screenshots with your reply.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Here you go.. Uploaded 2 charts first is 1 tick and second is 1 min

                        1 Tick Chart

                        Click image for larger version

Name:	tick1.png
Views:	446
Size:	215.7 KB
ID:	1117588








                        1 Minute Chart

                        Click image for larger version

Name:	min1.png
Views:	423
Size:	222.6 KB
ID:	1117589




                        Comment


                          #13
                          Hello utrivedi,

                          I am not able to reproduce this behavior.


                          The tick data chart is matching, which would indicate that historical tick data is correct.

                          If you close the chart, then follow the exact steps shown in this video, is the behavior different than what is shown in this video?

                          If so, I would like to schedule a call with you so that I may perform these steps on your end.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Hi Chelsea,

                            In the video at 0:27 where you select Days=1, keep it Days=4 instead and keep the End Date as 9/9/2020. I just did what you do in the video i.e. Days=1 and changed the End Date to 9/7/2020 and I see the correct data, it is only when I do Days=4 the data come in incorrectly. Let me know, Thanks!



                            Comment


                              #15
                              Hello utrivedi,

                              That is too much data for the output window. This is why i reduced to 1 day and set the date to the day after the day in question.
                              It would be necessary to start writing the data to file if you want to analyze a massive amount of data like this.
                              https://ninjatrader.com/support/foru...nce#post100192

                              This means that you are likely not looking at tickreplay information in the output window if you are loading 4 days of historical data from today's date and its not causing the maximum amount of lines the output window can show.

                              It's possible the output window wasn't cleared and you are looking at something that wasn't produced by this script instance.

                              However, I am not seeing any issue when looking at today's data as far back as can be shown in the output window.
                              https://drive.google.com/file/d/1_4u...w?usp=drivesdk
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jxs_xrj, 01-12-2020, 09:49 AM
                              6 responses
                              3,290 views
                              1 like
                              Last Post jgualdronc  
                              Started by Touch-Ups, Today, 10:36 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post Touch-Ups  
                              Started by geddyisodin, 04-25-2024, 05:20 AM
                              8 responses
                              61 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by Option Whisperer, Today, 09:55 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post Option Whisperer  
                              Started by halgo_boulder, 04-20-2024, 08:44 AM
                              2 responses
                              24 views
                              0 likes
                              Last Post halgo_boulder  
                              Working...
                              X