NexusFi: Find Your Edge


Home Menu

 





Converted NT8 code not working properly.


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 Joseph H 
Wilmington Delaware
 
Experience: Intermediate
Platform: NinjaTrader, TOS
Trading: Futures
Posts: 24 since May 2019
Thanks Given: 4
Thanks Received: 16

1st off, thanks to ThinkDecoded for converting my TOS code over to NinjaTrader 8. It works properly when I hard code the colors for up/down conditions.
Example:

// Cambiar colores según la tendencia
PlotBrushes[0][0] = emaSeries[0] > emaSeries[1] ? System.Windows.Media.Brushes.White : System.Windows.Media.Brushes.Black;
PlotBrushes[1][0] = smoothingLine1[0] > smoothingLine1[1] ? System.Windows.Media.Brushes.LightGreen : System.Windows.Media.Brushes.Red;
PlotBrushes[2][0] = smoothingLine2[0] > smoothingLine2[1] ? System.Windows.Media.Brushes.LightGreen : System.Windows.Media.Brushes.Red;
PlotBrushes[3][0] = smoothingLine3[0] > smoothingLine3[1] ? System.Windows.Media.Brushes.Blue : System.Windows.Media.Brushes.Purple;


However the color selection inside the setting dialog for each EMA does not work. I tried to message ThinkDecoded about it, but haven't received an answer.
Here is the code. Any help would be greatly appreciated, Thanks!

Code:
#region Using declarations
using System;
using NinjaTrader.Gui.Tools;
using NinjaTrader.NinjaScript;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
using System.Windows.Media; // Necesario para Brushes
#endregion

namespace NinjaTrader.NinjaScript.Indicators
{
public class MultiSmoothedEMA : Indicator
{
private EMA emaSeries;
private EMA smoothingLine1;
private EMA smoothingLine2;
private EMA smoothingLine3;

[NinjaScriptProperty]
public int Length { get; set; } = 50;

[NinjaScriptProperty]
public int SmoothingLength1 { get; set; } = 5;

[NinjaScriptProperty]
public int SmoothingLength2 { get; set; } = 10;

[NinjaScriptProperty]
public int SmoothingLength3 { get; set; } = 15;

protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "Indicator with EMA and multiple smoothed lines.";
Name = "MultiSmoothedEMA";
IsOverlay = true;

AddPlot(System.Windows.Media.Brushes.LawnGreen, "EMA Line");
AddPlot(System.Windows.Media.Brushes.Blue, "Smoothing Line 1");
AddPlot(System.Windows.Media.Brushes.Blue, "Smoothing Line 2");
AddPlot(System.Windows.Media.Brushes.Black, "Smoothing Line 3");
}
else if (State == State.DataLoaded)
{
emaSeries = EMA(Close, Length);
smoothingLine1 = EMA(emaSeries, SmoothingLength1);
smoothingLine2 = EMA(emaSeries, SmoothingLength2);
smoothingLine3 = EMA(emaSeries, SmoothingLength3);
}
}

protected override void OnBarUpdate()
{
if (CurrentBar < Math.Max(Length, Math.Max(SmoothingLength1, Math.Max(SmoothingLength2, SmoothingLength3))))
return;

// Asignar valores a los plots
Values[0][0] = emaSeries[0];
Values[1][0] = smoothingLine1[0];
Values[2][0] = smoothingLine2[0];
Values[3][0] = smoothingLine3[0];

// Cambiar colores según la tendencia
PlotBrushes[0][0] = emaSeries[0] > emaSeries[1] ? System.Windows.Media.Brushes.White : System.Windows.Media.Brushes.Black;
PlotBrushes[1][0] = smoothingLine1[0] > smoothingLine1[1] ? System.Windows.Media.Brushes.LightGreen : System.Windows.Media.Brushes.Red;
PlotBrushes[2][0] = smoothingLine2[0] > smoothingLine2[1] ? System.Windows.Media.Brushes.LightGreen : System.Windows.Media.Brushes.Red;
PlotBrushes[3][0] = smoothingLine3[0] > smoothingLine3[1] ? System.Windows.Media.Brushes.Blue : System.Windows.Media.Brushes.Purple;
}
}
}


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Asia Equities Crash Overnight -- Nikkei -5.2%, KOSPI -6. …
Traders Hideout
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
Hungary Called for Magyar at 97pct, Ending 16-Year Orban …
Prediction Markets & Event Contracts
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
23 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #2 (permalink)
 hedgeplay 
Austin Texas / US
 
Experience: Intermediate
Frequency: Several times daily
Duration: Seconds
Posts: 216 since Dec 2019
Thanks Given: 159
Thanks Received: 241


Joseph H View Post
\

However the color selection inside the setting dialog for each EMA does not work. I tried to message ThinkDecoded about it, but haven't received an answer.
Here is the code. Any help would be greatly appreciated, Thanks!

You need to Serialize the Brushes.. link and example attached.

https://ninjatrader.com/support/helpguides/nt8/NT%20HelpGuide%20English.html?user_definable_color_inputs.htm


Attached Files
Elite Membership required to download: SampleBrushInput.zip
Reply With Quote
Thanked by:




Last Updated on February 2, 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