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

Wish to display volume on chart

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

    Wish to display volume on chart

    Hello, I created an indicator that splits out the ask and bid volume. Works nice with one exception. If I stop the indicator and restart it for any reason, it resets the data to zero and starts displaying from the restart rather than displaying the data from the beginning of the range of data.
    Please help me understand what I am missing.
    Morris

    #2
    Hi morrnel, thanks for your question.

    It's happening because the method you are using to access the historical bid/ask volume is reliant on real time data. Please read this page on using Tick Replay to access historical bid/ask data. The buy/sell volume indicator also demonstrates how to do this. e.g.

    Code:
    protected override void OnMarketData(MarketDataEventArgs e)
            {
                if(e.MarketDataType == MarketDataType.Last)
                {
                    if(e.Price >= e.Ask)
                        buys += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume);
                    else if (e.Price <= e.Bid)
                        sells += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume);
                }
            }
    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the info. Please help me understand, as I watch the VOL indicator, the bar changes in height on each tick. How and why is that different?

      Comment


        #4
        Hi morrnel, thanks for your reply.

        The VOL indicator is accumulating the volume data. What are you seeing that is different?

        I look forward to hearing from you.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Each time a tick is processed, the bar is updated until the bar completes

          Comment


            #6
            Hi morrnel, thanks for your reply.

            Please forgive me but I am not sure of the question being asked. Could you explain further?
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              When I watch each bar, it changes each time a tick is processed. The tick counter changes. The volume bar goes up a bit. So how do I get my indicator to work in the very same way?

              Comment


                #8
                Hi morrnel, thanks for your reply.

                First the script must run OnEachTick or OnPriceChange. If it is, when you update Values[0][0] with some number, the plot will be changed to that value as well. Theres nothing else that would need to be added to make this happen.

                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Ok, thanks!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by merzo, 06-25-2023, 02:19 AM
                  10 responses
                  823 views
                  1 like
                  Last Post NinjaTrader_ChristopherJ  
                  Started by frankthearm, Today, 09:08 AM
                  5 responses
                  15 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by jeronymite, 04-12-2024, 04:26 PM
                  3 responses
                  43 views
                  0 likes
                  Last Post jeronymite  
                  Started by yertle, Today, 08:38 AM
                  5 responses
                  16 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by adeelshahzad, Today, 03:54 AM
                  3 responses
                  19 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Working...
                  X