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 suroot, 04-10-2017, 02:18 AM
          5 responses
          3,021 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by Stanfillirenfro, Today, 07:23 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cmtjoancolmenero, Yesterday, 03:58 PM
          2 responses
          22 views
          0 likes
          Last Post cmtjoancolmenero  
          Started by olisav57, Yesterday, 07:39 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by cocoescala, 10-12-2018, 11:02 PM
          7 responses
          944 views
          0 likes
          Last Post Jquiroz1975  
          Working...
          X