Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Volume per range

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

    Volume per range

    Hello and good day,

    I'm trying to develop a indicator that divides the VOL by the range of the bar Open/Close.

    It shows no error on compiling but on the log it shows
    Default Error on setting indicator plot for indicator 'VolOpenClose'. Value outside of valid range.


    The RangeOpenClose is the indicator that calculates the range of Open/Close and works ok.

    Could You help me?

    Thank You


    Code:
    namespace NinjaTrader.Indicator
    {
        [Description("Calculates the volume per range open/close.")]
    	public class VolOpenClose : Indicator
        {
            protected override void Initialize()
            {
                Add(new Plot(Color.White, PlotStyle.Bar, "VOpenClose"));
            }
    
            protected override void OnBarUpdate()
            {
    			if ( CurrentBar < 2)
    				{
    				return;
    				}
    
    			
    			
                VOpenClose.Set(VOL()[0]/(RangeOpenClose().RangeOC[0]*10000));
    			
    	    }
    		
    		[Browsable(false)]
    		[XmlIgnore()]
    		public DataSeries VOpenClose
    		{
    			get { return Values[0]; }
    		}
    		
    		
        }
    }

    #2
    Hello hliboi,

    Thank you for your post.

    Are you overriding the plot in either of these indicators?

    Comment


      #3
      Hello PatrickH,

      What do you mean by overriding the plot?

      Here is the other indicator

      Code:
      namespace NinjaTrader.Indicator
      {
      
          [Description("Calculates  ranges of a bar Open/Close.")]
      	public class RangeOpenClose : Indicator
          {
             
              protected override void Initialize()
              {
      			Add(new Plot(Color.White, PlotStyle.Bar, "RangeOC"));
                  Add(new Plot(Color.Red, PlotStyle.Bar, "RangeWickdown"));
      			Add(new Plot(Color.Green, PlotStyle.Bar, "RangeWickup"));
      			
      			
      			
      //			RangeOC = new DataSeries(this);
      //			RangeWickdown = new DataSeries(this);
      //			RangeWickup = new DataSeries(this);
              }
             
              protected override void OnBarUpdate()
              {
                  RangeOC.Set(Open[0] - Close[0]);
      			RangeWickdown.Set(Open[0] - High[0]);
      			RangeWickup.Set(Open[0] - Low[0]);
      			
      			if (RangeOC[0]<0)
      			{
      			RangeOC.Set (RangeOC[0]*-1);
      			}
      			
      			
      			if (RangeWickdown[0]<0)
      			{
      			RangeWickdown.Set (RangeWickdown[0]*-1);
      			}
      			
              }
      		
      		[Browsable(false)]
      		[XmlIgnore()]
      		public DataSeries RangeOC
      		{
      			get { return Values[0]; }
      		}
      		
      		[Browsable(false)]
      		[XmlIgnore()]
      		public DataSeries RangeWickdown
      		{
      			get { return Values[1]; }
      		}
      		[Browsable(false)]
      		[XmlIgnore()]
      		public DataSeries RangeWickup
      		{
      			get { return Values[2]; }
      		}
      		
          }
      }

      Comment


        #4
        Originally posted by hliboi View Post
        Hello and good day,

        I'm trying to develop a indicator that divides the VOL by the range of the bar Open/Close.

        It shows no error on compiling but on the log it shows
        Default Error on setting indicator plot for indicator 'VolOpenClose'. Value outside of valid range.


        The RangeOpenClose is the indicator that calculates the range of Open/Close and works ok.

        Could You help me?

        Thank You


        Code:
        namespace NinjaTrader.Indicator
        {
            [Description("Calculates the volume per range open/close.")]
        	public class VolOpenClose : Indicator
            {
                protected override void Initialize()
                {
                    Add(new Plot(Color.White, PlotStyle.Bar, "VOpenClose"));
                }
        
                protected override void OnBarUpdate()
                {
        			if ( CurrentBar < 2)
        				{
        				return;
        				}
        
        			
        			
                    VOpenClose.Set(VOL()[0]/(RangeOpenClose().RangeOC[0]*10000));
        			
        	    }
        		
        		[Browsable(false)]
        		[XmlIgnore()]
        		public DataSeries VOpenClose
        		{
        			get { return Values[0]; }
        		}
        		
        		
            }
        }
        You have not taken care of a possible division by zero, which will occur on the first strict doji bar. Take care of that, and your issue should be resolved.

        Comment


          #5
          Thank You very much koganam.

          That solved the zero divide issue. Thank You again.

          Comment

          Latest Posts

          Collapse

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