• 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

How to calculate total [email protected] in a given period?

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

    How to calculate total [email protected] in a given period?

    Hi everyone.

    I'd like to know how I can calculate the correct [email protected] for a given period.
    So for instance, I'd like to calculate the total volume for each price that was traded during 9.30-16.15.

    I've tried the following for each bar:

    Dictionary<string, double> d_prices = new Dictionary<string, double>();
    private bool get_all_price_volume_pairs_for_current_bar()
    {

    double ticksize = Bars.Instrument.MasterInstrument.TickSize;
    double high = Bars.GetHigh(CurrentBar);
    double low = Bars.GetLow(CurrentBar);
    double theprice = 0;

    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[2].BarsType as//Bars.BarsSeries.BarsType as
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;


    for(double price = high;price >= low; price -= ticksize)
    {

    double volume = barsType.Volumes[CurrentBar].GetTotalVolumeForPrice(price);

    if (volume == 0)
    continue;

    if(d_prices.ContainsKey(price.ToString()))
    {
    d_prices[price.ToString()] += volume;

    } else {
    d_prices.Add(price.ToString(),volume);
    }

    }
    return true;
    }


    However, this doesn't seem to get me exactly the correct volume for say 200 bars if I measure with other indicators.

    Anyone who can help me please?

    Thanks!

    Bo

    #2
    Hello bohenriksen,

    Welcome to the NinjaTrader support forums.

    From what is provided I am not sure what difference you are seeing to really suggest anything. Have you tried a very short period to output values and see where it specifically deviates? Is this different on every bar or is this happening in a specific area?

    How are you currently doing the comparison? it looks like you are adding the volumetric data as a secondary series, are you comparing that against another volumetric chart? Have you also tried to use the volumetric the primary series and apply this directly to the volumetric chart as shown in the help guide sample? Does that make a different in accumulation?

    Another thought that goes along with the secondary series would be that you have no filtering shown in the sample, are you using BarsInProgress and calling this during a specific BarsInProgress or just all the time?

    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 12-10-2019, 07:03 AM. Reason: spelling edits
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,
      thanks so much for your answer.

      I found out that I was doing it correct, but had wrong session info loaded :-).

      Thank you

      Best,
      Bo

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by fx.practic, Today, 12:35 PM
      0 responses
      2 views
      0 likes
      Last Post fx.practic  
      Started by martyn73, Today, 12:03 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by Bullit35054, Today, 10:45 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Melissa  
      Started by iq200, Today, 10:27 AM
      4 responses
      17 views
      0 likes
      Last Post iq200
      by iq200
       
      Started by cdalrym100, Today, 11:03 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Working...
      X