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 Waxavi, 04-19-2024, 02:10 AM
        2 responses
        36 views
        0 likes
        Last Post poeds
        by poeds
         
        Started by chbruno, Yesterday, 04:10 PM
        1 response
        44 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Max238, Today, 01:28 AM
        1 response
        23 views
        0 likes
        Last Post CactusMan  
        Started by giulyko00, Yesterday, 12:03 PM
        2 responses
        10 views
        0 likes
        Last Post giulyko00  
        Started by r68cervera, Today, 05:29 AM
        0 responses
        4 views
        0 likes
        Last Post r68cervera  
        Working...
        X