Ninjatrader Code Fix: Plot Brush Color Access
Budget: $25 – $50 USD
I'm having issues with my Ninjatrader code. The calculations seem to be off, and I can't access the color values from the plot brushes. I need someone who can fix this for me. Attached is the indicator I was using to test with, also, sample code from another indicator that is trying to scrap the colors from debuttesting_2....
Ideal Skills:
- Proficient in C# (Ninjatrader's primary coding language).
- Experience with Ninjatrader.
- Ability to troubleshoot coding issues.
- Understanding of trading software.
- Skills in debugging and testing code.
This function just needs to loop over all indicators, and get all the plots, and then get all the distinct Brushes/colors from them, but for some reason, i can't get this to work. The follow function needs to be able to run from another indicator or strategy(for testing reasons I am adding a debug test indicator that should illustrate the issue:
public static string PlotInfo(ChartControl ChartControl, Bars Bars)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("=== Plot Information from Chart Objects (Indicators) ===");
for (int i = 0; i < ChartControl.ChartObjects.Count; i++)
{
if (ChartControl.ChartObjects[i] is IndicatorBase indicator)
{
if (indicator.Plots != null)
{
sb.AppendLine($"--- Indicator: {indicator.Name} ---");
for (int p = 0; p < indicator.Plots.Length; p++)
{
var plot = indicator.Plots[p];
if (plot != null)
{
sb.AppendLine($" ---> {plot.Name} {plot.PlotStyle} {plot.Brush} <---");
if (indicator.PlotBrushes[p] != null)
{
sb.AppendLine(" Plot Brushes:");
for (int j = 0; j < indicator.PlotBrushes.Length; j++)
{
Brush barColor = indicator.PlotBrushes[p][j];
if (barColor != null)
{
sb.AppendLine($" Bar {j}: {barColor}");
if (barColor is SolidColorBrush solidColorBrush)
{
Color color = solidColorBrush.Color;
sb.AppendLine($" Color (R, G, B, A): {color.R}, {color.G}, {color.B}, {color.A}");
}
}
}
}
else
{
sb.AppendLine(" Plot Brushes: null");
}
}
}
}
}
}
return sb.ToString();
}
Ideal Skills:
- Proficient in C# (Ninjatrader's primary coding language).
- Experience with Ninjatrader.
- Ability to troubleshoot coding issues.
- Understanding of trading software.
- Skills in debugging and testing code.
This function just needs to loop over all indicators, and get all the plots, and then get all the distinct Brushes/colors from them, but for some reason, i can't get this to work. The follow function needs to be able to run from another indicator or strategy(for testing reasons I am adding a debug test indicator that should illustrate the issue:
public static string PlotInfo(ChartControl ChartControl, Bars Bars)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("=== Plot Information from Chart Objects (Indicators) ===");
for (int i = 0; i < ChartControl.ChartObjects.Count; i++)
{
if (ChartControl.ChartObjects[i] is IndicatorBase indicator)
{
if (indicator.Plots != null)
{
sb.AppendLine($"--- Indicator: {indicator.Name} ---");
for (int p = 0; p < indicator.Plots.Length; p++)
{
var plot = indicator.Plots[p];
if (plot != null)
{
sb.AppendLine($" ---> {plot.Name} {plot.PlotStyle} {plot.Brush} <---");
if (indicator.PlotBrushes[p] != null)
{
sb.AppendLine(" Plot Brushes:");
for (int j = 0; j < indicator.PlotBrushes.Length; j++)
{
Brush barColor = indicator.PlotBrushes[p][j];
if (barColor != null)
{
sb.AppendLine($" Bar {j}: {barColor}");
if (barColor is SolidColorBrush solidColorBrush)
{
Color color = solidColorBrush.Color;
sb.AppendLine($" Color (R, G, B, A): {color.R}, {color.G}, {color.B}, {color.A}");
}
}
}
}
else
{
sb.AppendLine(" Plot Brushes: null");
}
}
}
}
}
}
return sb.ToString();
}