Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing Volume/Time Data

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

    Accessing Volume/Time Data

    I'm curious to know how indicators such as BuySellVolume get access to how much volume is from sells and how much volume is from buys, and how I can access this information?

    I also need some clarification on how to set a variable to the start time of a bar?
    would be it something like
    Code:
    if (FirstTickOfBar)
    {
    barstart = Time[0];
    }
    Thanks!

    #2
    Hello MisterGee, and thank you for your question.

    This information comes in during the OnMarketData event. I will post an excerpt from BuySellVolume where this is demonstrated.

    Code:
    [FONT=Courier New]
            protected override void OnMarketData(MarketDataEventArgs e)
            {            
                if(e.MarketDataType == MarketDataType.Last)
                {                
                    if(e.Price >= e.Ask)
                    {
                        buys += e.Volume;
                    }
                    else if (e.Price <= e.Bid)
                    {
                        sells += e.Volume;
                    }
                }    
            }[/FONT]
    Note that you will have to turn on Tick Replay if you would like the e.MarketDataType == MarketDataType.Last section to be available for historical bars. This help guide section has instructions on turning on Tick Replay.



    The code you mentioned would work for setting a variable to the start time of a bar. Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      My variable barstart would have to be a DateTime series correct? How can I convert a DateTime series into a number I can do math with via an integer?

      Comment


        #4
        For this the convenience method ToTime was created. You can learn more about it here,



        The hundred thousands and ten thousands digits represent the hour on a 24 hour clock (e.g. 2 PM would be the number 14, midnight would be 0)

        The thousands and hundreds digits represent the minutes.

        The tens and ones digits represent the seconds.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        331 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
        549 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        549 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X