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

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 cre8able, Today, 01:16 PM
          2 responses
          9 views
          0 likes
          Last Post cre8able  
          Started by chbruno, 04-24-2024, 04:10 PM
          3 responses
          48 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by samish18, Today, 01:01 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by WHICKED, Today, 12:56 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by WHICKED, Today, 12:45 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X