Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Volumetric Bars - GetMaximumVolume

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

    Volumetric Bars - GetMaximumVolume

    Hi,

    I would like to find the maximum total volume in a bar at what price that occured and draw a line at that price. I'm using Volumetric Bars and found GetMaximumVolume:



    Print("Maximum Combined: " + barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price) + " at price: " + price);

    When I use this and compile, I get an error for price.

    1. What would be the best way to find the maximum volume at price
    2. How could I resolve the price error?

    Thanks

    #2
    Hello AgriTrdr,

    If you would like assistance with an error message, please provide the full error message.

    May I confirm you have declared a double variable named price?
    The help guide page you have linked shows this in the sample code.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Please see the error message below:
      Operator '>=' cannot be applied to operands of type 'string' and 'int' CS0019 85 8
      ​​

      Comment


        #4
        Hello AgriTrdr,

        Are you certain line 85 is this print with the call to GetMaximumVolume()?

        May I have a screenshot of the error and line 85 showing in the NinjaScript Editor?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Absolutely. Please see the attached screenshot.
          Attached Files

          Comment


            #6
            Hello AgriTrdr,

            Your screenshot is not showing the error message as requested.

            The print you have suggested is not on line 85.

            The code on line 85 is:
            if (POC >= UserDefinedVolume/3).

            This is not related to the print you suggested in post # 1.

            Also you are using var instead of defining objects as the actual type.

            Either POC or UserDefinedVolume is not a number.

            I see you are assigning POC to the string. A string cannot be compared to a number.

            Were you trying to use if (price >= UserDefinedVolume/3)?

            Were you trying to assign POC to the price variable?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi,

              Here's the same example coded a different way from the sample codes, but I'm still receiving an error message CS0029.

              Code:
              egion Using declarations
              
              using System;
              
              using System.Collections.Generic;
              
              using System.ComponentModel;
              
              using System.ComponentModel.DataAnnotations;
              
              using System.Linq;
              
              using System.Text;
              
              using System.Threading.Tasks;
              
              using System.Windows;
              
              using System.Windows.Input;
              
              using System.Windows.Media;
              
              using System.Xml.Serialization;
              
              using NinjaTrader.Cbi;
              
              using NinjaTrader.Gui;
              
              using NinjaTrader.Gui.Chart;
              
              using NinjaTrader.Gui.SuperDom;
              
              using NinjaTrader.Gui.Tools;
              
              using NinjaTrader.Data;
              
              using NinjaTrader.NinjaScript;
              
              using NinjaTrader.Core.FloatingPoint;
              
              using NinjaTrader.NinjaScript.DrawingTools;
              
              #endregion
              
              
              
              
              //This namespace holds Indicators in this folder and is required. Do not change it.
              
              namespace NinjaTrader.NinjaScript.Indicators
              
              {
              
              public class USAbsorption3 : Indicator
              
              {
              
              private long POC;
              
              
              
              protected override void OnStateChange()
              
              {
              
              if (State == State.SetDefaults)
              
              {
              
              Description = @"Plots the difference between DeltaSinceHigh and DeltaSinceLow.";
              
              Name = "USAbsorption3";
              
              Calculate = Calculate.OnBarClose;
              
              IsOverlay = true;
              
              DisplayInDataBox = true;
              
              DrawOnPricePanel = true;
              
              DrawHorizontalGridLines = true;
              
              DrawVerticalGridLines = true;
              
              PaintPriceMarkers = true;
              
              ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
              
              //Disable this property if your indicator requires custom values that cumulate with each new market data event.
              
              //See Help Guide for additional information.
              
              IsSuspendedWhileInactive = true;
              
              UserDefinedVolume = 2000;
              
              POC = 0;
              
              AddPlot(new Stroke(Brushes.SaddleBrown, 5), PlotStyle.Line, "DD");
              
              }
              
              else if (State == State.Configure)
              
              {
              
              AddVolumetric(Instrument.FullName, BarsPeriodType.Tick, UserDefinedVolume, VolumetricDeltaType.BidAsk, 1);
              
              }
              
              }
              
              
              
              
              protected override void OnBarUpdate()
              
              {
              
              
              
              if (Bars == null)
              
              return;
              
               
              
              NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = Bars.BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
              
                    
              
              if (barsType == null)
              
              return;
              
              
              
              
                      try
              
              {
              
                        double price;
              
              POC =  barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price) + " at price: " + price;
              
              
              
              if (POC > UserDefinedVolume/3)
              
              {
              
              DD[0] = Close[0];
              
              }
              
                      }
              
                      catch{}
              
              }
              
              
              
              
              #region Properties
              
              [NinjaScriptProperty]
              
              [Range(0, int.MaxValue)]
              
              [Display(Name="UserDefinedVolume", Order=1, GroupName="Parameters")]
              
              public int UserDefinedVolume
              
              { get; set; }
              
              
              
              
              [Browsable(false)]
              
              [XmlIgnore]
              
              public Series<double> DD
              
              {
              
              get { return Values[0]; }
              
              }
              
              
              
              
              #endregion
              
              
              
              
              }
              
              }
              ​
              Attached Files

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello AgriTrdr,

                Your screenshot is not showing the error message as requested.

                The print you have suggested is not on line 85.

                The code on line 85 is:
                if (POC >= UserDefinedVolume/3).

                This is not related to the print you suggested in post # 1.

                Also you are using var instead of defining objects as the actual type.

                Either POC or UserDefinedVolume is not a number.

                I see you are assigning POC to the string. A string cannot be compared to a number.

                Were you trying to use if (price >= UserDefinedVolume/3)?

                Were you trying to assign POC to the price variable?

                Would the "price" give me the actual price or the volume at price? A little confused on what it would provide. I'm trying to get the max volume within a bar, but also would like at what price that's occuring.

                Thanks

                Comment


                  #9
                  Hello AgriTrdr,

                  The price variable is an out parameter. You are not assigning POC to the output parameter you are assigning POC to a string where price is converted to a string and concatenated with "at price:".

                  A string cannot be compared to a number. This is the same issue.

                  You can compare price to a number, because it is declared as a double, which is a number with a decimal.

                  If you want to assign POC to the value of price it would be:

                  barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price);

                  double POC = price;


                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Thank you that worked.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    597 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    343 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    103 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    556 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    555 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X