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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        133 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        75 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        117 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        113 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        90 views
        0 likes
        Last Post CarlTrading  
        Working...
        X