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 %

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

    Volume %

    Hi, this is my first indicator in separate panel, but when I compile the code NT give me error CS0103 on "Snipervol".

    Sure I'm in error but I can't find it.

    This is the code :

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Bar, "Snipervol"));
    Overlay = false;
    CalculateOnBarClose = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (CurrentBar < 100)
    return;

    double M = SMA(Volume,smaperiod)[0];
    Snipervol.Set((Volume[0]/M)*100);

    }
    Attached Files

    #2
    Hello sniper,
    Thanks for your note.

    You have not assigned the Snipervol DataSeries associated the the Plot.

    If you try the attached code then are you able to compile the indicator. I have added the codes in line 50-55.
    Attached Files
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Sorry but the .cs posted looks like egual mine. I can't find anything in line 50-55. Can you post again or post the code in this form ?


      Thanks

      Comment


        #4
        Hello sniper,
        Please find the code. The added code is highlighted in bold.

        Code:
        #region Using declarations
        using System;
        using System.ComponentModel;
        using System.Diagnostics;
        using System.Drawing;
        using System.Drawing.Drawing2D;
        using System.Xml.Serialization;
        using NinjaTrader.Cbi;
        using NinjaTrader.Data;
        using NinjaTrader.Gui.Chart;
        #endregion
        
        // This namespace holds all indicators and is required. Do not change it.
        namespace NinjaTrader.Indicator
        {
            /// <summary>
            /// Volume Percento
            /// </summary>
            [Description("Volume Percento")]
            public class SNIPERVolume : Indicator
            {
                #region Variables
                private int	smaperiod = 21;		
                #endregion
        
                /// <summary>
                /// This method is used to configure the indicator and is called once before any bar data is loaded.
                /// </summary>
                protected override void Initialize()
                {
                    Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Bar, "Snipervol"));
                    Overlay				= false;
        			CalculateOnBarClose = false; 
                }
        
                /// <summary>
                /// Called on each bar update event (incoming tick)
                /// </summary>
                protected override void OnBarUpdate()
                {
                    if (CurrentBar < 100) 
        				return;
        		
        			double M = SMA(Volume,smaperiod)[0];
                    Snipervol.Set((Volume[0]/M)*100);	
        			
                }
        
                #region Properties
        	[B]	[Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                public DataSeries Snipervol
                {
                    get { return Values[0]; }
                }[/B]
        		
        		[Description("Periodo della media mobile semplice")]
        		[Category("Parametri")]
        		public int Periodo_della_SMA
        		{
        			get { return smaperiod; }
        			set { smaperiod = Math.Max(1, value); }
        		}
                #endregion
            }
        }
        
        #region NinjaScript generated code. Neither change nor remove.
        // This namespace holds all indicators and is required. Do not change it.
        namespace NinjaTrader.Indicator
        {
            public partial class Indicator : IndicatorBase
            {
                private SNIPERVolume[] cacheSNIPERVolume = null;
        
                private static SNIPERVolume checkSNIPERVolume = new SNIPERVolume();
        
                /// <summary>
                /// Volume Percento
                /// </summary>
                /// <returns></returns>
                public SNIPERVolume SNIPERVolume()
                {
                    return SNIPERVolume(Input);
                }
        
                /// <summary>
                /// Volume Percento
                /// </summary>
                /// <returns></returns>
                public SNIPERVolume SNIPERVolume(Data.IDataSeries input)
                {
                    if (cacheSNIPERVolume != null)
                        for (int idx = 0; idx < cacheSNIPERVolume.Length; idx++)
                            if (cacheSNIPERVolume[idx].EqualsInput(input))
                                return cacheSNIPERVolume[idx];
        
                    lock (checkSNIPERVolume)
                    {
                        if (cacheSNIPERVolume != null)
                            for (int idx = 0; idx < cacheSNIPERVolume.Length; idx++)
                                if (cacheSNIPERVolume[idx].EqualsInput(input))
                                    return cacheSNIPERVolume[idx];
        
                        SNIPERVolume indicator = new SNIPERVolume();
                        indicator.BarsRequired = BarsRequired;
                        indicator.CalculateOnBarClose = CalculateOnBarClose;
        #if NT7
                        indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                        indicator.MaximumBarsLookBack = MaximumBarsLookBack;
        #endif
                        indicator.Input = input;
                        Indicators.Add(indicator);
                        indicator.SetUp();
        
                        SNIPERVolume[] tmp = new SNIPERVolume[cacheSNIPERVolume == null ? 1 : cacheSNIPERVolume.Length + 1];
                        if (cacheSNIPERVolume != null)
                            cacheSNIPERVolume.CopyTo(tmp, 0);
                        tmp[tmp.Length - 1] = indicator;
                        cacheSNIPERVolume = tmp;
                        return indicator;
                    }
                }
            }
        }
        
        // This namespace holds all market analyzer column definitions and is required. Do not change it.
        namespace NinjaTrader.MarketAnalyzer
        {
            public partial class Column : ColumnBase
            {
                /// <summary>
                /// Volume Percento
                /// </summary>
                /// <returns></returns>
                [Gui.Design.WizardCondition("Indicator")]
                public Indicator.SNIPERVolume SNIPERVolume()
                {
                    return _indicator.SNIPERVolume(Input);
                }
        
                /// <summary>
                /// Volume Percento
                /// </summary>
                /// <returns></returns>
                public Indicator.SNIPERVolume SNIPERVolume(Data.IDataSeries input)
                {
                    return _indicator.SNIPERVolume(input);
                }
            }
        }
        
        // This namespace holds all strategies and is required. Do not change it.
        namespace NinjaTrader.Strategy
        {
            public partial class Strategy : StrategyBase
            {
                /// <summary>
                /// Volume Percento
                /// </summary>
                /// <returns></returns>
                [Gui.Design.WizardCondition("Indicator")]
                public Indicator.SNIPERVolume SNIPERVolume()
                {
                    return _indicator.SNIPERVolume(Input);
                }
        
                /// <summary>
                /// Volume Percento
                /// </summary>
                /// <returns></returns>
                public Indicator.SNIPERVolume SNIPERVolume(Data.IDataSeries input)
                {
                    if (InInitialize && input == null)
                        throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
        
                    return _indicator.SNIPERVolume(input);
                }
            }
        }
        #endregion
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Perfect !!

          Thanks a lot, you are very kind person!

          Great !

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Irukandji, Today, 04:58 AM
          0 responses
          2 views
          0 likes
          Last Post Irukandji  
          Started by fitspressoburnfat, Today, 04:25 AM
          0 responses
          2 views
          0 likes
          Last Post fitspressoburnfat  
          Started by Skifree, Today, 03:41 AM
          1 response
          4 views
          0 likes
          Last Post Skifree
          by Skifree
           
          Started by usazencort, Today, 01:16 AM
          0 responses
          1 view
          0 likes
          Last Post usazencort  
          Started by kaywai, 09-01-2023, 08:44 PM
          5 responses
          604 views
          0 likes
          Last Post NinjaTrader_Jason  
          Working...
          X