• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

VOL Indicator and Volumes dataseries have different data for Bid and Ask

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

    VOL Indicator and Volumes dataseries have different data for Bid and Ask

    I am in my wits end in trying to figure out why my indicator is not showing accurate Bid Ask Volumes.

    I am comparing the data from the indicator coming out from the VOL indicator and my indicator and it seems that my indicator will occasionally come out with false bid/ask volume. If we hit F5, we will get back the accurate volume according to the VOL indicator.

    My initialize code:


    Add(Instrument.FullName, BarsPeriod.Id, BarsPeriod.Value,MarketDataType.Bid);
    Add(Instrument.FullName, BarsPeriod.Id, BarsPeriod.Value,MarketDataType.Ask);

    These are the codes I have tried:
    Values[1].Set(Volumes[1][0]);
    Values[0].Set(Volumes[2][0]);
    Values[1].Set(VOL(BarsArray[1])[0]);
    Values[0].Set(VOL(BarsArray[2])[0]);
    PlotBid.Set(GetCurrentBidVolume());
    PlotAsk.Set(GetCurrentAskVolume());


    GetCurrentAskVolume and GetCurrentBidVolume seems to throw some bogus value that does not fit the VOL data plotted on the Ask Prices. Would this be a Time and Sales data instead?
    As you can see from the screenshot, both VOL and Volumes throw the same figure and do not correspond to the VOL indicator, however, the non-refreshed data are all correct. I'm using Zenfire btw.
    Attached Files

    #2
    Hello,

    Can you please clarify where you are using the Plot code?

    Are you checking for the correct BarsInProgress event for the added data series? If you're not familiar with that, please review the information on the following link:

    http://www.ninjatrader.com/support/h...nstruments.htm

    If this does not help, can you please provide me with more of the code you are using in OnBarUpdate?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Heres my code. I'm using OnBarUpdate to set values for all the plots. The rest of the stuff is just drawing triangles etc which does not affect the main dataseries code...

      #region Variables
      private int maperiod = 3;
      private bool filterabovema = true;
      private int whichbar = 0;
      #endregion

      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.PaleGreen), PlotStyle.Dot, "PlotAsk"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Pink), PlotStyle.Dot, "PlotBid"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "MAAsk"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "MABid"));
      Add(Instrument.FullName, BarsPeriod.Id, BarsPeriod.Value,MarketDataType.Bid);
      Add(Instrument.FullName, BarsPeriod.Id, BarsPeriod.Value,MarketDataType.Ask);

      CalculateOnBarClose = false;
      //Overlay = true;
      PriceTypeSupported = false;

      protected override void OnBarUpdate()
      {

      Values[1].Set(Volumes[1][0]);
      Values[0].Set(Volumes[2][0]);
      //PlotBid.Set(GetCurrentBidVolume());
      //PlotAsk.Set(GetCurrentAskVolume());
      Values[3].Set(EMA(Volumes[1],maperiod)[0]);
      Values[2].Set(EMA(Volumes[2],maperiod)[0]);


      if(CurrentBar < maperiod )
      {
      return;
      }
      // draw stuff
      }

      Your help is much appreciated.
      I have attached a pic with less intensive indicators... BTW I've discovered that the values is correct as each tick comes in but when the bar is closing the bar created becomes the wrong value. I do not have any additional calculations. I have tried to use the Values[0].Set(1,value). For some reason it always returns an empty plot.

      My latest code with BarsInProgress is not helping


      if(BarsInProgress == 1)
      {
      Values[1].Set(Volumes[1][0]);
      }
      if(BarsInProgress == 2)
      {
      Values[0].Set(Volumes[2][0]);
      }

      PSPS: I've tested the indicator with CalculateOnBarClose, When the CalculateOnBarClose is true, it will produce the correct value, CalculateOnBarClose false will give the wrong value. CORRECTION: It is quite random. Sometimes the true setting matches the VOL indicator and sometimes it doesn't. "true" could match and "false" could not match and sometimes "false" will match and "true" will not match.
      Attached Files
      Last edited by wwteo; 05-17-2012, 12:11 PM.

      Comment


        #4
        I'm happy to help and welcome to our forums by the way.

        What you're likely seeing here is the difference in timing between OnBarUpdate and the actual market data at that time. OnBarUpdate will only be called when a tick has been received, and may not be updating fast enough to see the accurate bid/ask volume at that time.

        I would suggest working in OnMarketData() which is called every time there is a change to the level I data you are looking for.

        Please see our Help Guide article on OnMarketData() for more information:

        http://www.ninjatrader.com/support/h...marketdata.htm
        MatthewNinjaTrader Product Management

        Comment


          #5
          I have already tried OnMarketData. It doesn't work as well... Same problem with erroneous data after closing. My Time and Sales based volume counting orders seems to do better but does not have history.
          It seems to mostly affect the Ask volume. My guess is the Volume data seems to reset more quickly than the painting of the plot. Would it be better to delay painting the plot or create another dataseries? How do I set values into a plot that are 1 bar ago?
          PS: The volume bar seems to be correct WHILE the bar is forming. The bogus data only comes AFTER the bar is formed. It first forms the correct bid/ask volume data then reforms it into bogus data.
          Last edited by wwteo; 05-17-2012, 08:51 PM.

          Comment


            #6
            Ah looks like I've solved it with a ((FirstTickOfBar) && (BarsInProgress == 0)) code to reset the bars and stopping the bars from overzealously updating the volumes.

            Can I ask is the FirstTickOfBar only apply to the main bar or can I use FirstTickOfBar on other dataseries besides the main one? Is there a FirstTickOfBar for BarsArray[1]?

            Comment


              #7
              wwteo, while there's FirstTickOfBar array accessible, you can check it in context to each BarsInProgress.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by w0lverine, Today, 08:22 PM
              0 responses
              1 view
              0 likes
              Last Post w0lverine  
              Started by dkbyond, Today, 04:11 PM
              0 responses
              5 views
              0 likes
              Last Post dkbyond
              by dkbyond
               
              Started by markus3500, Today, 03:29 PM
              1 response
              18 views
              0 likes
              Last Post NinjaTrader_EricB  
              Started by bohenriksen, Today, 04:00 AM
              1 response
              21 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by brett0, Today, 12:33 PM
              3 responses
              17 views
              0 likes
              Last Post marcus2300  
              Working...
              X