I am after an SMA indicator which color changes depending on the slope. Would anyone have this indicator for NT8? thanks in advance
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
SMA Color change
Collapse
X
-
Hello borge,
Thank you for your note.
Actually, the example on this page does exactly that - it's an SMA that colors the plot depending on whether the line is rising or falling:
This is meant as an example, but I believe it does what you're looking for.
Please let us know if we may be of further assistance to you.
-
Hello borge,
Thank you for your reply.
My mistake there, I got that example mixed up with this one from our User App Share that is a similar existing script that demonstrates this using the EMA that can be adapted to your needs.
Below is a public link to the User App Share section of the NinjaTrader Ecosystem.
https://ninjatraderecosystem.com/use...emaslopecolor/
This script could be copied and then modified to call the SMA instead of the EMA.
I am happy to answer any questions you may have about NinjaScript if you decide to code this yourself.
This thread will remain open for any community members that may know of an existing script that already uses the SMA or would like to make the modifications on your behalf.
You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
Please let us know if we may be of further assistance to you.
The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
Comment
-
Hello borge,
Thank you for your reply.
It's likely it's just labeling the plot as EMA_Slope_Color unless you changed that to say SMA_Slope_Color.
Just make sure you're also changed any references to "EMA" in the script to SMA:
Make sure you remove the indicator from your chart and readd it once you've changed all the references to EMA to SMA for those changes to be applied.Code:namespace NinjaTrader.NinjaScript.Indicators { public class SMASlopeColor : Indicator { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"SMASlopeColor"; Name = "SMASlopeColor"; Calculate = Calculate.OnBarClose; IsOverlay = true; 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 = 14; UpColor = Brushes.LimeGreen; DnColor = Brushes.Red; ColorSlope = true; AddPlot(Brushes.Orange, "SMA_Slope_Color"); } } protected override void OnBarUpdate() { Value[0] = SMA(Period)[0]; if(IsRising(Value)) { if(ColorSlope) PlotBrushes[0][0] = UpColor; } if(IsFalling(Value)) { if(ColorSlope) PlotBrushes[0][0] = DnColor; } } #region Properties [NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="Period", Description="Number of bars to include in the calculation", Order=1, GroupName="Parameters")] public int Period { get; set; } [NinjaScriptProperty] [XmlIgnore] [Display(Name="Up Color", Description="Color for rising condition", Order=3, GroupName="Parameters")] public Brush UpColor { get; set; } [Browsable(false)] public string UpColorSerializable { get { return Serialize.BrushToString(UpColor); } set { UpColor = Serialize.StringToBrush(value); } } [NinjaScriptProperty] [XmlIgnore] [Display(Name="Down Color", Description="Color for falling condition", Order=4, GroupName="Parameters")] public Brush DnColor { get; set; } [Browsable(false)] public string DnColorSerializable { get { return Serialize.BrushToString(DnColor); } set { DnColor = Serialize.StringToBrush(value); } } [NinjaScriptProperty] [Display(Name="Enable Slope Color?", Description="Color the plot?", Order=2, GroupName="Parameters")] public bool ColorSlope { get; set; } [Browsable(false)] [XmlIgnore] public Series<double> SMA_Slope_Color { get { return Values[0]; } } #endregion } }
Please let us know if we may be of further assistance to you.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
573 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
575 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment