Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time&Sales last trade

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

    Time&Sales last trade

    Hello!
    Want to write some script which will use T&S data.
    Which command I need to use if I want to know:
    - the size (volume) of last trade
    - was last trade on ask or on bid price
    - time of last trade

    Thanks!

    #2
    Hello YevhenShynkarenko,


    You could use MarketDataEventArgs to access those values.


    Here is the MarketDataEventArgs Help Guide to assist you further.



    Here is an example that prints the Last, Ask and Bid prices to the output window. The times and the volume for each are printed as well.


    Code:
    protected override void OnBarUpdate()    [COLOR=#000000][FONT=Tahoma][LEFT]              {}[LEFT][/LEFT][LEFT][/LEFT]
    [COLOR=#000000][FONT=Tahoma][LEFT]             [/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
    [COLOR=#000000][FONT=Tahoma][LEFT]protected override void OnMarketData(MarketDataEventArgs e)[/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
    [COLOR=#000000][FONT=Tahoma][LEFT]             {
         if (e.MarketDataType == MarketDataType.Last)          
              Print("Last = " + e.Price + " " + e.Time + " " + e.Volume);
         else if (e.MarketDataType == MarketDataType.Ask)
             Print("Ask = " + e.Price  + e.Time + " " + e.Price + " " + e.Volume);
        else if (e.MarketDataType == MarketDataType.Bid)
             Print("Bid = "  + e.Price + " " + e.Time + " " + e.Volume);
                   }
    [/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
    [/LEFT][/FONT][/COLOR]

    Comment


      #3
      Originally posted by NinjaTrader_ShawnB View Post
      Hello YevhenShynkarenko,


      You could use MarketDataEventArgs to access those values.


      Here is the MarketDataEventArgs Help Guide to assist you further.



      Here is an example that prints the Last, Ask and Bid prices to the output window. The times and the volume for each are printed as well.


      Code:
      protected override void OnBarUpdate()    [COLOR=#000000][FONT=Tahoma][LEFT]              {}[LEFT][/LEFT][LEFT][/LEFT]
      [COLOR=#000000][FONT=Tahoma][LEFT]             [/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
      [COLOR=#000000][FONT=Tahoma][LEFT]protected override void OnMarketData(MarketDataEventArgs e)[/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
      [COLOR=#000000][FONT=Tahoma][LEFT]             {
           if (e.MarketDataType == MarketDataType.Last)          
                Print("Last = " + e.Price + " " + e.Time + " " + e.Volume);
           else if (e.MarketDataType == MarketDataType.Ask)
               Print("Ask = " + e.Price  + e.Time + " " + e.Price + " " + e.Volume);
          else if (e.MarketDataType == MarketDataType.Bid)
               Print("Bid = "  + e.Price + " " + e.Time + " " + e.Volume);
                     }
      [/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
      [/LEFT][/FONT][/COLOR]
      Thanks for reply!
      And is MarketDataType.Bid is the last trade on bid price? Or it will show how many orders are standing on current bid price?
      Thanks!

      Comment


        #4
        Hello YevhenShynkarenko,


        Yes, MarketDataType.Bid will represent the current bid price. Using e.Volume will return the volume of the current bid price.


        I have included the sample Level II Data Book indicator to assist you further.
        Indicator Creating your own Level II data book - NinjaTrader Support Forum

        Comment


          #5
          Originally posted by NinjaTrader_ShawnB View Post
          Hello YevhenShynkarenko,


          Yes, MarketDataType.Bid will represent the current bid price. Using e.Volume will return the volume of the current bid price.


          I have included the sample Level II Data Book indicator to assist you further.
          Indicator Creating your own Level II data book - NinjaTrader Support Forum
          Okay. But how can I wrote to Output was the Last trade on Bid or on Ask? Can I do it? Thanks!
          Want to create something like Time & Sales but in Output Window.
          For example if last trade was on Bid size i want to see that last trade was at Time X and with Volume Y.

          Comment


            #6
            Hello YevhenShynkarenko,

            Please use MarketDataEventArgs to access those values.
            Here is the MarketDataEventArgs Help Guide to assist you further.



            I have included the sample Level II Data Book indicator to assist you further.
            Indicator Creating your own Level II data book - NinjaTrader Support Forum


            Here is an example that prints the Last, Ask and Bid prices to the output window. The times and the volume for each are printed as well.


            Code:
            [LEFT][FONT=Consolas][SIZE=1][COLOR=#0000FF]protected[/COLOR][/SIZE][/FONT] [FONT=Consolas][SIZE=1][COLOR=#0000FF]override[/COLOR][/SIZE][/FONT] [FONT=Consolas][SIZE=1][COLOR=#0000FF]void[/COLOR][/SIZE][/FONT] [FONT=Consolas][SIZE=1]OnBarUpdate()    [/SIZE][/FONT]
            [FONT=Consolas][SIZE=1]              {}[/SIZE][/FONT]
            [FONT=Consolas][SIZE=1]             [/SIZE][/FONT]
            protected override void OnMarketData(MarketDataEventArgs e)
                         {
                 if (e.MarketDataType == MarketDataType.Last)          
                      Print("Last = " + e.Price + " " + [FONT=Consolas]e.Time[/FONT] + " " + e.Volume);
                 else if (e.MarketDataType == MarketDataType.Ask)
                     Print("Ask = " + e.Price  + [FONT=Consolas]e.Time[/FONT] + " " + e.Price + " " + e.Volume);
                else if (e.MarketDataType == MarketDataType.Bid)
                     Print("Bid = "  + e.Price + " " + [FONT=Consolas]e.Time[/FONT] + " " + e.Volume);
                           }
            [/LEFT]

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            561 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            325 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            547 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X