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 XXtrader, Yesterday, 11:30 PM
        2 responses
        11 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        6 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        11 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        4 views
        0 likes
        Last Post elirion
        by elirion
         
        Working...
        X