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

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 selu72, Today, 02:01 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by WHICKED, Today, 02:02 PM
        2 responses
        12 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by f.saeidi, Today, 12:14 PM
        8 responses
        21 views
        0 likes
        Last Post f.saeidi  
        Started by Mikey_, 03-23-2024, 05:59 PM
        3 responses
        51 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Started by Russ Moreland, Today, 12:54 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X