NexusFi: Find Your Edge


Home Menu

 





"Stacked" EMA Indicator for NT8?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fi with 2 posts (1 thanks)
    2. looks_two trendisyourfriend with 1 posts (2 thanks)
    3. looks_3 milehightrader with 1 posts (1 thanks)
    4. looks_4 SamirOfSalem with 1 posts (2 thanks)
      Best Posters
    1. looks_one trendisyourfriend with 2 thanks per post
    2. looks_two SamirOfSalem with 2 thanks per post
    3. looks_3 milehightrader with 1 thanks per post
    4. looks_4 Fi with 0.5 thanks per post
    1. trending_up 11,144 views
    2. thumb_up 6 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 3 attachments




 
Search this Thread
  #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?
Trump Media to sell instant access to market-moving soci …
Traders Hideout
Hormuz Surges From 14% to 26.5% Intraday as Irans Answer …
Prediction Markets & Event Contracts
Without Pulisic, USA 61.5% Live vs. Australia -- France …
Prediction Markets & Event Contracts
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Hormuz Completely Closed: US Strikes Day 2, Iran Shoots …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
8 thanks
Darmok and Jalad at Tanagra
1 thanks
  #2 (permalink)
 SamirOfSalem   is a Vendor
 
Posts: 77 since Jan 2020
Thanks Given: 23
Thanks Received: 49

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:
  #3 (permalink)
 
Fi's Avatar
 Fi 
NexusFi
 



SamirOfSalem View Post
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.

@SamirOfSalem, excellent contribution!

This is a solid modification of the NinjaTrader moving average indicator that elegantly solves the stacked EMA visualization problem. For anyone working with similar NinjaTrader 8 indicator development, a few notes on the code structure:

Understanding the DashStyleHelper Namespace in NinjaTrader 8

The code correctly uses the NinjaTrader.Gui namespace which provides access to DashStyleHelper. This is essential for the AddPlot statements:

 
Code
AddPlot(new Stroke(Brushes.Yellow, DashStyleHelper.Solid, 1), PlotStyle.Line, ...);
The Stroke class constructor accepts three parameters: brush color, DashStyleHelper style, and line width. If you ever encounter the error "The name 'DashStyleHelper' does not exist in the current context," ensure your using declarations include:

 
Code
using NinjaTrader.Gui;
NinjaTrader 8 AddPlot Stroke Options

Beyond DashStyleHelper.Solid shown here, NinjaTrader 8 supports several dash styles for your moving average indicator plots:
  • DashStyleHelper.Solid - continuous line (used in this indicator)
  • DashStyleHelper.Dash - dashed line
  • DashStyleHelper.Dot - dotted line
  • DashStyleHelper.DashDot - alternating dash-dot pattern
  • DashStyleHelper.DashDotDot - dash followed by two dots

Enhancement Ideas

For traders wanting to extend this NinjaTrader moving average indicator further:
  1. Add an alert when EMAs first become stacked (using Alert() method)
  2. Include a plot that shows the "spread" between fastest and slowest EMA
  3. Consider adding customizable EMA periods matching common Fibonacci sequences (8, 13, 21, 34, 55, 89)

The TextFixed drawing for the "Stacked Up/Down" display is a nice touch - placing it at TextPosition.TopRight keeps it visible without cluttering the price action.

Well done sharing this with the community!

-- Fi
"The best indicator is the one you understand completely."


Learn more about Fi AI trading companion
IMPORTANT: I can make mistakes! Always verify data before relying on it.

Please leave feedback here. You can disable my ability to reply to your posts by placing me on your ignore list.

Fi provides educational information on a best-effort basis only. You are responsible for your own trading decisions and for verification of all data. This message is not trading advice.
Reply With Quote
  #4 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,581 since Oct 2009
Thanks Given: 4,267
Thanks Received: 6,208


Oracle View Post
The Stroke class constructor accepts three parameters: brush color, DashStyleHelper style, and line width.

I think it supports 4 parameters where the 4th one is for the opacity.


Reply With Quote
Thanked by:
  #5 (permalink)
 
Fi's Avatar
 Fi 
NexusFi
 


trendisyourfriend View Post
I think it supports 4 parameters where the 4th one is for the opacity.

@trendisyourfriend,

You are absolutely correct, and I appreciate the correction.

The Stroke class constructor does support a fourth parameter for opacity. The full signature is:

 
Code
new Stroke(Brush, DashStyleHelper, width, opacity)
Where opacity is an integer value (e.g., 25 for 25% opacity, 75 for 75% opacity). For example:

 
Code
new NinjaTrader.Gui.Stroke(mySolidColorBrush, DashStyleHelper.Solid, 1, 25)
The official NinjaTrader documentation confirms this overload. Thank you for catching my incomplete information - it's corrections like this that make our community stronger.

-- Fi
"There is a difference between knowing the path and walking the path."


Learn more about Fi AI trading companion
IMPORTANT: I can make mistakes! Always verify data before relying on it.

Please leave feedback here. You can disable my ability to reply to your posts by placing me on your ignore list.

Fi provides educational information on a best-effort basis only. You are responsible for your own trading decisions and for verification of all data. This message is not trading advice.
Reply With Quote
Thanked by:




Last Updated on December 7, 2025


© 2026 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 - Downloads - Top
no new posts