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

Execution above ask// time and sale

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

    Execution above ask// time and sale

    Hi

    How can I access time and sale data? I'd like to be able to chart when the orders are being executed above ask.. And what the volume was associated to them.

    Thanks.

    #2
    Hello calhawk01,

    This would be done with OnMarketData().

    Please see: http://ninjatrader.com/support/helpG...b=onmarketdata
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello calhawk01,

      This would be done with OnMarketData().

      Please see: http://ninjatrader.com/support/helpG...b=onmarketdata

      Code:
      if (MarketDataType.Last > MarketDataType.Ask)
               Print("Execution > Ask");
      In the documentation I see a mention of, "e.Price." What is that? Is that the code for execution price?

      Comment


        #4
        Hello calhawk01,

        Thanks for your reply.

        e.Price is the price value returned from OnMarketData(MarketDataEventArgs e). You would have to match it up with the MarketDatatype list here: http://ninjatrader.com/support/helpG...aeventargs.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Paul View Post
          Hello calhawk01,

          Thanks for your reply.

          e.Price is the price value returned from OnMarketData(MarketDataEventArgs e). You would have to match it up with the MarketDatatype list here: http://ninjatrader.com/support/helpG...aeventargs.htm
          confused :/

          so would the above code i posted print when last > ask price?

          Comment


            #6
            Hello calhawk01,

            Sorry I missed the code and wanted to make sure I got you the info on e.Price.

            Yes your code should work.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Code:
                      protected override void OnBarUpdate()
                      {
                              if (MarketDataType.Last > MarketDataType.Ask)
                                  
                              {
                                  AboveAsk.Set(above);
                              }
                              
                      }
              Code:
                      protected override void OnMarketData(MarketDataEventArgs e)
                          {
                          if (e.MarketDataType == MarketDataType.Last )
                          {
                              last = e.Price;
                          }
                          
                          if (e.MarketDataType == MarketDataType.Ask )
                          {
                              ask = e.Price;
                          }
                              if (last > ask )
                              
                              {
                                  above = (e.Volume);
                              }
                          }
              I tried. And failed. Some help would be great. The goal is to try to plot the volume that was traded above ask. If Last[0] > Ask[0] then print the volume that was traded above ask. The above seems to give me a huge number.. i think it's printing the total volume. And i'm not even sure if i'm using the e.price values correctly

              Comment


                #8
                Hello calhawk01,

                Thanks for your post.

                I think you may want to either use the indicator BuySellVolume or perhaps use the coding for your indicator as I think it will provide what you are looking for. Here is the description, "...Plots a histogram splitting volume between trades at the ask or higher and trades at the bid and lower."

                Here is a part of that indicators code that determines the buy/sell volume based on the current close price against the bid/ask.

                Code:
                			double tradeVol = previousVol == 0 ? Volume[0] : Volume[0] - previousVol;
                				if (Close[0] >= GetCurrentAsk())
                					buys += tradeVol;
                				else if (Close[0] <= GetCurrentBid())
                					sells += tradeVol;
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Paul View Post
                  Hello calhawk01,

                  Thanks for your post.

                  I think you may want to either use the indicator BuySellVolume or perhaps use the coding for your indicator as I think it will provide what you are looking for. Here is the description, "...Plots a histogram splitting volume between trades at the ask or higher and trades at the bid and lower."

                  Here is a part of that indicators code that determines the buy/sell volume based on the current close price against the bid/ask.

                  Code:
                  			double tradeVol = previousVol == 0 ? Volume[0] : Volume[0] - previousVol;
                  				if (Close[0] >= GetCurrentAsk())
                  					buys += tradeVol;
                  				else if (Close[0] <= GetCurrentBid())
                  					sells += tradeVol;
                  Thanks Paul. Can you pls add comments on each line. Trying to understand the code. I have no idea why and how ? Is used lol

                  Comment


                    #10
                    Hello calhawk01,

                    Thanks for your post.

                    The line of code: double tradeVol = previousVol == 0 ? Volume[0] : Volume[0] - previousVol;

                    The use of "?" and ":" is referred to as a Ternary operation and is just a short way to write:

                    if (previousVol == 0)
                    {
                    tradeVol = Volume[0];
                    }
                    else
                    {
                    tradeVol = Volume[0] - previousVol;
                    }

                    previousVol == 0 is the logic being tested by the "?". The first thing that follows the "?" would be used if the condition previousVol == 0 is true. If the condition is false then Volume[0] - previousVol; is used. The two values, Volume[0] : Volume[0] - previousVol, are separated by ":".

                    Here is a reference to Ternary operator: http://www.dotnetperls.com/ternary
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      whats the benefit of getcurrentask vs marketdatatype.ask? if my purpose is to simply count the # of occurrences that happen during a given time when close > ask? I build a simple counter indicator that counts and resets when the bar closes. but i'm using getcurrentask. but researching through NT; most people seem to use marketdatatype.ask for such calculations. why?

                      if (e.MarketDataType == MarketDataType.Ask )

                      vs

                      if(GetCurrentAsk())

                      Comment


                        #12
                        Hello calhawk01,

                        Thank you for your response.

                        Are looking for this over the entire data set in the chart? Historical and Real-Time?

                        I ask as GetCurrentAsk() would only pull in real-time and OnMarketData() would only work on real-time data as well.

                        You can add a historical series for ask or bid: http://ninjatrader.com/support/helpGuides/nt7/add3.htm

                        Comment


                          #13
                          Originally posted by NinjaTrader_PatrickH View Post
                          Hello calhawk01,

                          Thank you for your response.

                          Are looking for this over the entire data set in the chart? Historical and Real-Time?

                          I ask as GetCurrentAsk() would only pull in real-time and OnMarketData() would only work on real-time data as well.

                          You can add a historical series for ask or bid: http://ninjatrader.com/support/helpGuides/nt7/add3.htm
                          I'm using this in real-time charting. Thanks for sharing the link. I would LIKE to be able to pull historical bid/ask/tick data but unfortunately mostly all data providers either don't support that data or the data is bad. Any thoughts on that? Does NT save bid/ask data when realtime data is turned on.. and then allow the user to pull it using historical series for ask?

                          I still don't understand the difference between GetCurrentAsk() and OnMarketData() Ask values.

                          Comment


                            #14
                            Hi calhawk01,

                            NinjaTrader will only save data for active feeds when Tools -> Options... -> Data -> Save chart data as historical.

                            This means that if you want real-time ask and bid recorded, then you would need to open a chart with the Ask data selected for 'Price based on' in the Data Series window.

                            The only real difference between GetCurrentAsk() and e.Price when e.MarketDataType == MarketDataType.Ask is how you plan to use it.

                            GetCurrentAsk() is meant to give you a snapshot value of the ask price and can be called from OnBarUpdate(). This is great when you need to make sure that your new stop or limit order is at an acceptable price before placing the order (to avoid the order being rejected due to being placed at an unacceptable price).

                            OnMarketData is meant to be driven by market data events. This is preferred to use if you plan on storing the ask or bid prices and or volume to arrays. This would be similar to how our and most volume profile indicators work.
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by andrewtrades, Today, 04:57 PM
                            1 response
                            9 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by chbruno, Today, 04:10 PM
                            0 responses
                            6 views
                            0 likes
                            Last Post chbruno
                            by chbruno
                             
                            Started by josh18955, 03-25-2023, 11:16 AM
                            6 responses
                            436 views
                            0 likes
                            Last Post Delerium  
                            Started by FAQtrader, Today, 03:35 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post FAQtrader  
                            Started by rocketman7, Today, 09:41 AM
                            5 responses
                            19 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Working...
                            X