indiTraders - Forum for the Active Indian Trader  

Go Back   indiTraders - Forum for the Active Indian Trader > Tools > Software > NinjaTrader

Composite Edge
Reply
 
Bookmark and Share LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 30-12-2016, 08:04 PM
nTP's Avatar
nTP nTP is offline
Flash Crash
 
Join Date: Dec 2013
Location: kolkata
Posts: 2,130
Thanks: 7,967
Thanked 2,395 Times in 1,421 Posts
nTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud of
red V*PMOC

hi

all credit goes to the original poster. i just re coded it for tp in new year nt7 version. and nt8

nt8
Code:
#region 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 VolumePriceMomentumOccilator : Indicator
	{
		
		private Series<double>	VPMOi;
		private double vToday;
		private double cPToday;
		private double cpYday;
		private double vPMOvar1;
		private double vPMOEma;
		
		protected override void OnStateChange()
		{
			if (State == State.SetDefaults)
			{
				Description									= @"Enter the description for your new custom Indicator here.";
				Name										= "VolumePriceMomentumOccilator";
				Calculate									= Calculate.OnBarClose;
				IsOverlay									= false;
				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;
				Period					= 1;
				PeriodEma					= 3;
				
				AddPlot(new Stroke(Brushes.SeaShell, 2), PlotStyle.Bar, "VPMO");
			}
			else if (State == State.Configure)
					VPMOi = new Series<double>(this);
		}

		protected override void OnBarUpdate()
		{
			//Add your custom indicator logic here.
			
				if (CurrentBar - Period >0)
			{
				double vToday = Volume[0];
			double cPToday = Close[0];
			double cpYday = Close[Period];
			double vPMOvar1=vToday * (cPToday - cpYday); 
			VPMOi[0]=vPMOvar1;
			Value[0] = EMA(VPMOi,PeriodEma)[0];
					}
			else
				Print ("waiting for next tick");
			
			
			
			
		}

		#region Properties
		[NinjaScriptProperty]
		[Range(1, int.MaxValue)]
		[Display(Name="Period", Description="colose_period_lookback", Order=1, GroupName="Parameters")]
		public int Period
		{ get; set; }

		[NinjaScriptProperty]
		[Range(1, int.MaxValue)]
		[Display(Name="PeriodEma", Description="ema period", Order=2, GroupName="Parameters")]
		public int PeriodEma
		{ get; set; }

		[Browsable(false)]
		[XmlIgnore]
		public Series<double> VPMO
		{
			get { return Values[0]; }
		}
		#endregion

	}
}

#region NinjaScript generated code. Neither change nor remove.

namespace NinjaTrader.NinjaScript.Indicators
{
	public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
	{
		private VolumePriceMomentumOccilator[] cacheVolumePriceMomentumOccilator;
		public VolumePriceMomentumOccilator VolumePriceMomentumOccilator(int period, int periodEma)
		{
			return VolumePriceMomentumOccilator(Input, period, periodEma);
		}

		public VolumePriceMomentumOccilator VolumePriceMomentumOccilator(ISeries<double> input, int period, int periodEma)
		{
			if (cacheVolumePriceMomentumOccilator != null)
				for (int idx = 0; idx < cacheVolumePriceMomentumOccilator.Length; idx++)
					if (cacheVolumePriceMomentumOccilator[idx] != null && cacheVolumePriceMomentumOccilator[idx].Period == period && cacheVolumePriceMomentumOccilator[idx].PeriodEma == periodEma && cacheVolumePriceMomentumOccilator[idx].EqualsInput(input))
						return cacheVolumePriceMomentumOccilator[idx];
			return CacheIndicator<VolumePriceMomentumOccilator>(new VolumePriceMomentumOccilator(){ Period = period, PeriodEma = periodEma }, input, ref cacheVolumePriceMomentumOccilator);
		}
	}
}

namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
	public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
	{
		public Indicators.VolumePriceMomentumOccilator VolumePriceMomentumOccilator(int period, int periodEma)
		{
			return indicator.VolumePriceMomentumOccilator(Input, period, periodEma);
		}

		public Indicators.VolumePriceMomentumOccilator VolumePriceMomentumOccilator(ISeries<double> input , int period, int periodEma)
		{
			return indicator.VolumePriceMomentumOccilator(input, period, periodEma);
		}
	}
}

namespace NinjaTrader.NinjaScript.Strategies
{
	public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
	{
		public Indicators.VolumePriceMomentumOccilator VolumePriceMomentumOccilator(int period, int periodEma)
		{
			return indicator.VolumePriceMomentumOccilator(Input, period, periodEma);
		}

		public Indicators.VolumePriceMomentumOccilator VolumePriceMomentumOccilator(ISeries<double> input , int period, int periodEma)
		{
			return indicator.VolumePriceMomentumOccilator(input, period, periodEma);
		}
	}
}

#endregion
nt7
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>
    ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
    /// </summary>
    [Description("  http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); ")]
    public class VolPriceMomentumOccilator : Indicator
    {
        #region Variables
        // Wizard generated variables
            private double vToday = 1; // Default setting for VToday
            private double cPToday = 1; // Default setting for CPToday
            private double vPMO = 1; // Default setting for VPMO
            private double vPMOEma = 1; 
			private double cpYday= 1;
			private DataSeries VPMOi;
		      
		// Default setting for VPMOEma
        // User defined variables (add any user defined variables below)
        #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()
        {
			VPMOi= new DataSeries(this, MaximumBarsLookBack.Infinite);
		
			
            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "PlotVPMO"));
            Overlay				= false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
				
			
			if (CurrentBar >0)
			{
				vToday = Volume[0];
			cPToday = Close[0];
			cpYday = Close[-1];
			VPMO=VToday * (CPToday - cpYday); 
			VPMOi.Set(VPMO);
			vPMOEma = EMA(VPMOi,3)[0];
			PlotVPMO.Set(vPMOEma);
			}
			else
				Print ("waiting for next tick");
			//vPMOEma = EMA(VPMO,3)[0];
			
			
			
            
        }

        #region Properties
        [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 PlotVPMO
        {
            get { return Values[0]; }
        }

        [Description("")]
        [GridCategory("Parameters")]
        public double VToday
        {
            get { return vToday; }
            set { vToday = Math.Max(1, value); }
        }

        [Description("")]
        [GridCategory("Parameters")]
        public double CPToday
        {
            get { return cPToday; }
            set { cPToday = Math.Max(1, value); }
        }

        [Description("")]
        [GridCategory("Parameters")]
        public double VPMO
        {
            get { return vPMO; }
            set { vPMO = Math.Max(1, value); }
        }

        [Description("")]
        [GridCategory("Parameters")]
        public double VPMOEma
        {
            get { return vPMOEma; }
            set { vPMOEma = 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 VolPriceMomentumOccilator[] cacheVolPriceMomentumOccilator = null;

        private static VolPriceMomentumOccilator checkVolPriceMomentumOccilator = new VolPriceMomentumOccilator();

        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        public VolPriceMomentumOccilator VolPriceMomentumOccilator(double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            return VolPriceMomentumOccilator(Input, cPToday, vPMO, vPMOEma, vToday);
        }

        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        public VolPriceMomentumOccilator VolPriceMomentumOccilator(Data.IDataSeries input, double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            if (cacheVolPriceMomentumOccilator != null)
                for (int idx = 0; idx < cacheVolPriceMomentumOccilator.Length; idx++)
                    if (Math.Abs(cacheVolPriceMomentumOccilator[idx].CPToday - cPToday) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VPMO - vPMO) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VPMOEma - vPMOEma) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VToday - vToday) <= double.Epsilon && cacheVolPriceMomentumOccilator[idx].EqualsInput(input))
                        return cacheVolPriceMomentumOccilator[idx];

            lock (checkVolPriceMomentumOccilator)
            {
                checkVolPriceMomentumOccilator.CPToday = cPToday;
                cPToday = checkVolPriceMomentumOccilator.CPToday;
                checkVolPriceMomentumOccilator.VPMO = vPMO;
                vPMO = checkVolPriceMomentumOccilator.VPMO;
                checkVolPriceMomentumOccilator.VPMOEma = vPMOEma;
                vPMOEma = checkVolPriceMomentumOccilator.VPMOEma;
                checkVolPriceMomentumOccilator.VToday = vToday;
                vToday = checkVolPriceMomentumOccilator.VToday;

                if (cacheVolPriceMomentumOccilator != null)
                    for (int idx = 0; idx < cacheVolPriceMomentumOccilator.Length; idx++)
                        if (Math.Abs(cacheVolPriceMomentumOccilator[idx].CPToday - cPToday) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VPMO - vPMO) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VPMOEma - vPMOEma) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VToday - vToday) <= double.Epsilon && cacheVolPriceMomentumOccilator[idx].EqualsInput(input))
                            return cacheVolPriceMomentumOccilator[idx];

                VolPriceMomentumOccilator indicator = new VolPriceMomentumOccilator();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.CPToday = cPToday;
                indicator.VPMO = vPMO;
                indicator.VPMOEma = vPMOEma;
                indicator.VToday = vToday;
                Indicators.Add(indicator);
                indicator.SetUp();

                VolPriceMomentumOccilator[] tmp = new VolPriceMomentumOccilator[cacheVolPriceMomentumOccilator == null ? 1 : cacheVolPriceMomentumOccilator.Length + 1];
                if (cacheVolPriceMomentumOccilator != null)
                    cacheVolPriceMomentumOccilator.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheVolPriceMomentumOccilator = 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>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.VolPriceMomentumOccilator VolPriceMomentumOccilator(double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            return _indicator.VolPriceMomentumOccilator(Input, cPToday, vPMO, vPMOEma, vToday);
        }

        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        public Indicator.VolPriceMomentumOccilator VolPriceMomentumOccilator(Data.IDataSeries input, double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            return _indicator.VolPriceMomentumOccilator(input, cPToday, vPMO, vPMOEma, vToday);
        }
    }
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    public partial class Strategy : StrategyBase
    {
        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.VolPriceMomentumOccilator VolPriceMomentumOccilator(double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            return _indicator.VolPriceMomentumOccilator(Input, cPToday, vPMO, vPMOEma, vToday);
        }

        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        public Indicator.VolPriceMomentumOccilator VolPriceMomentumOccilator(Data.IDataSeries input, double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            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.VolPriceMomentumOccilator(input, cPToday, vPMO, vPMOEma, vToday);
        }
    }
}
#endregion
Attached Files
File Type: zip XyteProd.zip (14.1 KB, 1 views)
File Type: zip xytevolpricemooccilator.zip (3.2 KB, 2 views)
__________________
thx
nTuple

Disclaimer: I am not a Research Analyst and not registered with any regulating authority. All posts are for educational purpose only.

Consider us a dumb -dumble guy in this analysis, any type of real time example will be quick-learn approach.

Last edited by nTP; 31-12-2016 at 12:30 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 5 Users Say Thank You to nTP For This Useful Post:
  #2 (permalink)  
Old 24-06-2017, 04:43 PM
vikkas's Avatar
vikkas vikkas is offline
Regulars
 
Join Date: Mar 2009
Posts: 730
Thanks: 1,902
Thanked 1,467 Times in 604 Posts
vikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to behold
Default

Originally Posted by nTP View Post
hi

all credit goes to the original poster. i just re coded it for tp in new year nt7 version. and nt8

nt8
Code:
#region 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 VolumePriceMomentumOccilator : Indicator
	{
		
		private Series<double>	VPMOi;
		private double vToday;
		private double cPToday;
		private double cpYday;
		private double vPMOvar1;
		private double vPMOEma;
		
		protected override void OnStateChange()
		{
			if (State == State.SetDefaults)
			{
				Description									= @"Enter the description for your new custom Indicator here.";
				Name										= "VolumePriceMomentumOccilator";
				Calculate									= Calculate.OnBarClose;
				IsOverlay									= false;
				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;
				Period					= 1;
				PeriodEma					= 3;
				
				AddPlot(new Stroke(Brushes.SeaShell, 2), PlotStyle.Bar, "VPMO");
			}
			else if (State == State.Configure)
					VPMOi = new Series<double>(this);
		}

		protected override void OnBarUpdate()
		{
			//Add your custom indicator logic here.
			
				if (CurrentBar - Period >0)
			{
				double vToday = Volume[0];
			double cPToday = Close[0];
			double cpYday = Close[Period];
			double vPMOvar1=vToday * (cPToday - cpYday); 
			VPMOi[0]=vPMOvar1;
			Value[0] = EMA(VPMOi,PeriodEma)[0];
					}
			else
				Print ("waiting for next tick");
			
			
			
			
		}

		#region Properties
		[NinjaScriptProperty]
		[Range(1, int.MaxValue)]
		[Display(Name="Period", Description="colose_period_lookback", Order=1, GroupName="Parameters")]
		public int Period
		{ get; set; }

		[NinjaScriptProperty]
		[Range(1, int.MaxValue)]
		[Display(Name="PeriodEma", Description="ema period", Order=2, GroupName="Parameters")]
		public int PeriodEma
		{ get; set; }

		[Browsable(false)]
		[XmlIgnore]
		public Series<double> VPMO
		{
			get { return Values[0]; }
		}
		#endregion

	}
}

#region NinjaScript generated code. Neither change nor remove.

namespace NinjaTrader.NinjaScript.Indicators
{
	public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
	{
		private VolumePriceMomentumOccilator[] cacheVolumePriceMomentumOccilator;
		public VolumePriceMomentumOccilator VolumePriceMomentumOccilator(int period, int periodEma)
		{
			return VolumePriceMomentumOccilator(Input, period, periodEma);
		}

		public VolumePriceMomentumOccilator VolumePriceMomentumOccilator(ISeries<double> input, int period, int periodEma)
		{
			if (cacheVolumePriceMomentumOccilator != null)
				for (int idx = 0; idx < cacheVolumePriceMomentumOccilator.Length; idx++)
					if (cacheVolumePriceMomentumOccilator[idx] != null && cacheVolumePriceMomentumOccilator[idx].Period == period && cacheVolumePriceMomentumOccilator[idx].PeriodEma == periodEma && cacheVolumePriceMomentumOccilator[idx].EqualsInput(input))
						return cacheVolumePriceMomentumOccilator[idx];
			return CacheIndicator<VolumePriceMomentumOccilator>(new VolumePriceMomentumOccilator(){ Period = period, PeriodEma = periodEma }, input, ref cacheVolumePriceMomentumOccilator);
		}
	}
}

namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
	public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
	{
		public Indicators.VolumePriceMomentumOccilator VolumePriceMomentumOccilator(int period, int periodEma)
		{
			return indicator.VolumePriceMomentumOccilator(Input, period, periodEma);
		}

		public Indicators.VolumePriceMomentumOccilator VolumePriceMomentumOccilator(ISeries<double> input , int period, int periodEma)
		{
			return indicator.VolumePriceMomentumOccilator(input, period, periodEma);
		}
	}
}

namespace NinjaTrader.NinjaScript.Strategies
{
	public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
	{
		public Indicators.VolumePriceMomentumOccilator VolumePriceMomentumOccilator(int period, int periodEma)
		{
			return indicator.VolumePriceMomentumOccilator(Input, period, periodEma);
		}

		public Indicators.VolumePriceMomentumOccilator VolumePriceMomentumOccilator(ISeries<double> input , int period, int periodEma)
		{
			return indicator.VolumePriceMomentumOccilator(input, period, periodEma);
		}
	}
}

#endregion
nt7
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>
    ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
    /// </summary>
    [Description("  http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); ")]
    public class VolPriceMomentumOccilator : Indicator
    {
        #region Variables
        // Wizard generated variables
            private double vToday = 1; // Default setting for VToday
            private double cPToday = 1; // Default setting for CPToday
            private double vPMO = 1; // Default setting for VPMO
            private double vPMOEma = 1; 
			private double cpYday= 1;
			private DataSeries VPMOi;
		      
		// Default setting for VPMOEma
        // User defined variables (add any user defined variables below)
        #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()
        {
			VPMOi= new DataSeries(this, MaximumBarsLookBack.Infinite);
		
			
            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "PlotVPMO"));
            Overlay				= false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
				
			
			if (CurrentBar >0)
			{
				vToday = Volume[0];
			cPToday = Close[0];
			cpYday = Close[-1];
			VPMO=VToday * (CPToday - cpYday); 
			VPMOi.Set(VPMO);
			vPMOEma = EMA(VPMOi,3)[0];
			PlotVPMO.Set(vPMOEma);
			}
			else
				Print ("waiting for next tick");
			//vPMOEma = EMA(VPMO,3)[0];
			
			
			
            
        }

        #region Properties
        [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 PlotVPMO
        {
            get { return Values[0]; }
        }

        [Description("")]
        [GridCategory("Parameters")]
        public double VToday
        {
            get { return vToday; }
            set { vToday = Math.Max(1, value); }
        }

        [Description("")]
        [GridCategory("Parameters")]
        public double CPToday
        {
            get { return cPToday; }
            set { cPToday = Math.Max(1, value); }
        }

        [Description("")]
        [GridCategory("Parameters")]
        public double VPMO
        {
            get { return vPMO; }
            set { vPMO = Math.Max(1, value); }
        }

        [Description("")]
        [GridCategory("Parameters")]
        public double VPMOEma
        {
            get { return vPMOEma; }
            set { vPMOEma = 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 VolPriceMomentumOccilator[] cacheVolPriceMomentumOccilator = null;

        private static VolPriceMomentumOccilator checkVolPriceMomentumOccilator = new VolPriceMomentumOccilator();

        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        public VolPriceMomentumOccilator VolPriceMomentumOccilator(double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            return VolPriceMomentumOccilator(Input, cPToday, vPMO, vPMOEma, vToday);
        }

        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        public VolPriceMomentumOccilator VolPriceMomentumOccilator(Data.IDataSeries input, double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            if (cacheVolPriceMomentumOccilator != null)
                for (int idx = 0; idx < cacheVolPriceMomentumOccilator.Length; idx++)
                    if (Math.Abs(cacheVolPriceMomentumOccilator[idx].CPToday - cPToday) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VPMO - vPMO) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VPMOEma - vPMOEma) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VToday - vToday) <= double.Epsilon && cacheVolPriceMomentumOccilator[idx].EqualsInput(input))
                        return cacheVolPriceMomentumOccilator[idx];

            lock (checkVolPriceMomentumOccilator)
            {
                checkVolPriceMomentumOccilator.CPToday = cPToday;
                cPToday = checkVolPriceMomentumOccilator.CPToday;
                checkVolPriceMomentumOccilator.VPMO = vPMO;
                vPMO = checkVolPriceMomentumOccilator.VPMO;
                checkVolPriceMomentumOccilator.VPMOEma = vPMOEma;
                vPMOEma = checkVolPriceMomentumOccilator.VPMOEma;
                checkVolPriceMomentumOccilator.VToday = vToday;
                vToday = checkVolPriceMomentumOccilator.VToday;

                if (cacheVolPriceMomentumOccilator != null)
                    for (int idx = 0; idx < cacheVolPriceMomentumOccilator.Length; idx++)
                        if (Math.Abs(cacheVolPriceMomentumOccilator[idx].CPToday - cPToday) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VPMO - vPMO) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VPMOEma - vPMOEma) <= double.Epsilon && Math.Abs(cacheVolPriceMomentumOccilator[idx].VToday - vToday) <= double.Epsilon && cacheVolPriceMomentumOccilator[idx].EqualsInput(input))
                            return cacheVolPriceMomentumOccilator[idx];

                VolPriceMomentumOccilator indicator = new VolPriceMomentumOccilator();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.CPToday = cPToday;
                indicator.VPMO = vPMO;
                indicator.VPMOEma = vPMOEma;
                indicator.VToday = vToday;
                Indicators.Add(indicator);
                indicator.SetUp();

                VolPriceMomentumOccilator[] tmp = new VolPriceMomentumOccilator[cacheVolPriceMomentumOccilator == null ? 1 : cacheVolPriceMomentumOccilator.Length + 1];
                if (cacheVolPriceMomentumOccilator != null)
                    cacheVolPriceMomentumOccilator.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheVolPriceMomentumOccilator = 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>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.VolPriceMomentumOccilator VolPriceMomentumOccilator(double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            return _indicator.VolPriceMomentumOccilator(Input, cPToday, vPMO, vPMOEma, vToday);
        }

        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        public Indicator.VolPriceMomentumOccilator VolPriceMomentumOccilator(Data.IDataSeries input, double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            return _indicator.VolPriceMomentumOccilator(input, cPToday, vPMO, vPMOEma, vToday);
        }
    }
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    public partial class Strategy : StrategyBase
    {
        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.VolPriceMomentumOccilator VolPriceMomentumOccilator(double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            return _indicator.VolPriceMomentumOccilator(Input, cPToday, vPMO, vPMOEma, vToday);
        }

        /// <summary>
        ///   http://www.positiveterritory.com/do/tw/vpmo11.htm  First, calculate today’s V*PMO input value:   VTODAY * (CPTODAY – CPTODAY-1) where  VTODAY = today’s Volume  CPTODAY = today’s closing price  CPTODAY-1 = yesterday’s closing price  Then smooth the values using a 3-Day exponential moving average (EMA):   V*PMO = EMA(3)(VTODAY,VTODAY-1,VTODAY-2)    version 0.2. (c) 19th Sept 2011, 12:10pm -  xytise@gmail.com  VToday=V; CPToday=C; CPYest=Ref (C,-1); VPMO=VToday * (CPToday - CPYest); VPMOEma=EMA(VPMO,3); Plot(VPMOEma, VPMO,colorRed,styleLine); Plot(0, Zero,colorWhite,styleLine); 
        /// </summary>
        /// <returns></returns>
        public Indicator.VolPriceMomentumOccilator VolPriceMomentumOccilator(Data.IDataSeries input, double cPToday, double vPMO, double vPMOEma, double vToday)
        {
            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.VolPriceMomentumOccilator(input, cPToday, vPMO, vPMOEma, vToday);
        }
    }
}
#endregion

Dear Nt,

Instead of showing in histogram format can we have this in Heiken Ashi candles format. Just like GomCDHA.

Best Regards,
__________________
First they ignore you, then they ridicule you, then they fight you, then you win -
Mahatma Gandhi
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to vikkas For This Useful Post:
Reply

indiTraders - Forum for the Active Indian Trader > Tools > Software > NinjaTrader


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Composite Edge

All times are GMT +5.5. The time now is 01:04 AM.


vBulletin Copyright by vBulletin

Content Relevant URLs by vBSEO 3.3.2