NexusFi: Find Your Edge


Home Menu

 





"Stacked" EMA Indicator for NT8?


Discussion in NinjaTrader

Updated
    1. trending_up 3,536 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 3 attachments




 
Search this Thread

"Stacked" EMA Indicator for NT8?

  #1 (permalink)
 milehightrader 
Tampa FL
 
Experience: Intermediate
Platform: NinjaTrader, Jigsaw
Broker: NinjaTrader Clearing, Rithmic
Trading: MNQ, MES
Posts: 39 since Mar 2020
Thanks Given: 13
Thanks Received: 18

Hi Traders,

I've searched around a bit for a "stacked" indicator for use with EMA's but unable to find anything so far. A similar Indicator would be irTFC, which displays multiple timeframes in an easy to see single indicator.

Is anyone aware of any equivalent for NinjaTrader 8 that can use EMA's? IE - 8, 21, 34, 55, 89 are all "stacked" on top of each other, so the indicator displays either green or red, depending on the direction, or even just displays "Stacked" in a corner.

John Carter's TTM Squeeze Pro has a similar setup I believe.

Thank you,
MHT

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
Strategy stop orders partially filled
EasyLanguage Programming
Quantum physics & Trading dynamics
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Funded Trader platforms
43 thanks
Just another trading journal: PA, Wyckoff & Trends
22 thanks
Trading with Intuition
18 thanks
Self sabotage reframed
14 thanks
GFIs1 1 DAX trade per day journal
9 thanks
  #2 (permalink)
 SamirOfSalem   is a Vendor
 
Posts: 74 since Jan 2020
Thanks Given: 23
Thanks Received: 44

Here's a quick mod of NinjaTrader's built-in Moving Average Ribbon indicator. See if it's close enough to what you're looking for.

MovingAverageRibbonStacked.cs




 
Code
#region Using declarations
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Gui;
#endregion
using NinjaTrader.NinjaScript.DrawingTools;

//This namespace holds Indicators in this folder and is required. Do not change it. 
namespace NinjaTrader.NinjaScript.Indicators
{
	/// <summary>
	/// The Moving Average Ribbon is a series of incrementing moving averages.
	/// </summary>
	public class MovingAverageRibbonStacked : Indicator
	{
        private bool stackedUp, stackedDown;
        protected override void OnStateChange()
		{
			if (State == State.SetDefaults)
			{
				Description					= NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionMovingAverageRibbon;
				Name						= "MovingAverageRibbon STACKED";
				Calculate					= Calculate.OnBarClose;
				IsOverlay					= true;
				DrawOnPricePanel			= true;
				IsSuspendedWhileInactive	= true;
				MovingAverage 				= RibbonMAType.Exponential;
				BasePeriod 					= 10;
				IncrementalPeriod 			= 10;
				
				AddPlot(new Stroke(Brushes.Yellow, 		DashStyleHelper.Solid, 1), PlotStyle.Line, NinjaTrader.Custom.Resource.MovingAverageRibbonPlot1);
				AddPlot(new Stroke(Brushes.Gold, 		DashStyleHelper.Solid, 1), PlotStyle.Line, NinjaTrader.Custom.Resource.MovingAverageRibbonPlot2);
				AddPlot(new Stroke(Brushes.Goldenrod, 	DashStyleHelper.Solid, 1), PlotStyle.Line, NinjaTrader.Custom.Resource.MovingAverageRibbonPlot3);
				AddPlot(new Stroke(Brushes.Orange, 		DashStyleHelper.Solid, 1), PlotStyle.Line, NinjaTrader.Custom.Resource.MovingAverageRibbonPlot4);
				AddPlot(new Stroke(Brushes.DarkOrange, 	DashStyleHelper.Solid, 1), PlotStyle.Line, NinjaTrader.Custom.Resource.MovingAverageRibbonPlot5);
				AddPlot(new Stroke(Brushes.Chocolate, 	DashStyleHelper.Solid, 1), PlotStyle.Line, NinjaTrader.Custom.Resource.MovingAverageRibbonPlot6);
				AddPlot(new Stroke(Brushes.OrangeRed, 	DashStyleHelper.Solid, 1), PlotStyle.Line, NinjaTrader.Custom.Resource.MovingAverageRibbonPlot7);
				AddPlot(new Stroke(Brushes.Red, 		DashStyleHelper.Solid, 1), PlotStyle.Line, NinjaTrader.Custom.Resource.MovingAverageRibbonPlot8);
			}
		}

		protected override void OnBarUpdate()
		{
			for (int i = 0; i < 8; i++)
			{
				switch (MovingAverage)
				{
					case RibbonMAType.Exponential:
						Values[i][0] = EMA(Input, BasePeriod + IncrementalPeriod * i)[0];
						break;
					case RibbonMAType.Hull:
						Values[i][0] = HMA(Input, BasePeriod + IncrementalPeriod * i)[0];
						break;
					case RibbonMAType.Simple:
						Values[i][0] = SMA(Input, BasePeriod + IncrementalPeriod * i)[0];
						break;
					case RibbonMAType.Weighted:
						Values[i][0] = WMA(Input, BasePeriod + IncrementalPeriod * i)[0];
						break;
				}
			}

            stackedDown = true;
            for (int i = 0; i < 8-1; i++)
            {
                stackedDown = stackedDown & (Values[i][0] < Values[i + 1][0]);
            }
            if (stackedDown) 
            {
                var tf = Draw.TextFixed(this, "stacked", "Stacked Down", TextPosition.TopRight);
                tf.AreaBrush = Brushes.Red;
            }
                
            stackedUp = true;
            for (int i = 0; i < 8-1; i++)
            {
                stackedUp = stackedUp & (Values[i][0] > Values[i + 1][0]);
            }
            if (stackedUp) 
            {
                var tf = Draw.TextFixed(this, "stacked", "Stacked Up", TextPosition.TopRight);
                tf.AreaBrush = Brushes.Green;
            }

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

		[XmlIgnore]
		[Browsable(false)]
		public Series<double> MovingAverage2 {  get { return Values[1]; } }

		[XmlIgnore]
		[Browsable(false)]
		public Series<double> MovingAverage3 {  get { return Values[2]; } }

		[XmlIgnore]
		[Browsable(false)]
		public Series<double> MovingAverage4 {  get { return Values[3]; } }

		[XmlIgnore]
		[Browsable(false)]
		public Series<double> MovingAverage5 {  get { return Values[4]; } }

		[XmlIgnore]
		[Browsable(false)]
		public Series<double> MovingAverage6 {  get { return Values[5]; } }

		[XmlIgnore]
		[Browsable(false)]
		public Series<double> MovingAverage7 {  get { return Values[6]; } }

		[XmlIgnore]
		[Browsable(false)]
		public Series<double> MovingAverage8 {  get { return Values[7]; } }

		[NinjaScriptProperty]
		[Display(ResourceType = typeof(Custom.Resource), Name = "MovingAverage", GroupName = "NinjaScriptParameters", Order = 0)]
		public RibbonMAType MovingAverage { get; set; }
		
		[Range(1, int.MaxValue), NinjaScriptProperty]
		[Display(ResourceType = typeof(Custom.Resource), Name = "BasePeriod", GroupName = "NinjaScriptParameters", Order = 1)]
		public int BasePeriod { get; set; }
		
		[Range(1, int.MaxValue), NinjaScriptProperty]
		[Display(ResourceType = typeof(Custom.Resource), Name = "IncrementalPeriod", GroupName = "NinjaScriptParameters", Order = 2)]
		public int IncrementalPeriod { get; set; }
		#endregion

	}
}

Reply With Quote
Thanked by:




Last Updated on December 11, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts