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

Net volume for past xxx seconds

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

    Net volume for past xxx seconds

    I am trying to figure out how I could use the OnMarketData() to extract the net volume : volume on ask - volume on bid for the past xxx seconds ?

    I was thinking about using a timer but I am sure there is an easier and better way to do it?

    Any idea ?



    Thanks

    #2
    Hello,

    Thank you for the question.

    I wanted to check, are you trying to store a collection of data received from OnMarketData and then access that collection to find specific rows for Ask or Bid within X seconds from the current time? Can you confirm if I have understood this correctly?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Yes Jesse

      This is exactly what I am trying to do

      Comment


        #4
        Hello,

        Thank you for confirming that.

        There are two ways you could potentially do this, the first would be storing all the incoming realtime events in a list or collection which you could later reference and search for a specific time range. The second would be to use the Level 2 book, I am unsure which you would need specifically so I will post about both.

        For OnMarketData, you could accomplish this by using a List to store the MarketDataEventArgs, when you need to find the specific rows you would just loop through the list and create a condition that checks the Time of the MarketDataEventArgs and filters based on that.

        For OnMarketDepth, you could potentially re purpose this sample: http://ninjatrader.com/support/forum...ead.php?t=3478
        The same concept applies, you would get the rows of data and then loop through them and filter by time.

        The first approach is likely the more simple as you would just need to worry about each tick received instead of the entire existing orderbook.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thank you for your guidance Jesse

          Well appreciated

          Comment


            #6
            Jesse

            As I am coding this I realized that I needed to back test on historical data but OnMarketData
            is only good for real time data I think. Is there a way to make this works on historical data ?


            Thank you

            Comment


              #7
              Hello,

              Thank you for the question.

              Yes OnMarketData only works in realtime, for historical ask or bid values you would need to utilize Ask or Bid series by Adding them to the script and making it a multi time frame script. You can add a 1 tick series for backtesting in general to gain intrabar granularity or to access other series historically.

              You could view the sample here to get more information on this topic: http://ninjatrader.com/support/forum...ead.php?t=6652

              Additionally if you have not worked with multibar scripts, this may be of use: http://ninjatrader.com/support/helpG...nstruments.htm

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              436 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              5 views
              0 likes
              Last Post FAQtrader  
              Started by rocketman7, Today, 09:41 AM
              5 responses
              18 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by frslvr, 04-11-2024, 07:26 AM
              9 responses
              127 views
              1 like
              Last Post caryc123  
              Started by selu72, Today, 02:01 PM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Working...
              X