here is NT chart and amibroker side by side.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
custom vertical bars on CCI charts
Collapse
X
-
Hello junkone,
If you are referring to setting a plot to the bar style (or histogram style) in code (development), this would be done with PlotStyle.Bar overload parameter.
AddPlot(Stroke stroke, PlotStyle plotStyle, string name)
If you are asking how to draw a vertical line, this is done with Draw.VerticalLine().
Chelsea B.NinjaTrader Customer Service
-
ok, i am trying this but it does not work
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "CustomCCI";
Name = "CustomCCI";
IsSuspendedWhileInactive = true;
Period = 100;
AddPlot(Brushes.Goldenrod, PlotStyle.Bar, "custom cci");// i get error on this line
AddLine(Brushes.DarkGray, 200, NinjaTrader.Custom.Resource.CCILevel2);
AddLine(Brushes.DarkGray, 100, NinjaTrader.Custom.Resource.CCILevel1);
AddLine(Brushes.Yellow, 0, NinjaTrader.Custom.Resource.NinjaScriptIndicatorZe roLine);
AddLine(Brushes.DarkGray, -100, NinjaTrader.Custom.Resource.CCILevelMinus1);
AddLine(Brushes.DarkGray, -200, NinjaTrader.Custom.Resource.CCILevelMinus2);
}
else if (State == State.DataLoaded)
sma = SMA(Typical, Period);
}
Comment
-
Hello junkone,
To use the PlotStyle parameter, you will need to use the overload signature with a stroke.
AddPlot(Stroke stroke, PlotStyle plotStyle, string name)
There are no overload signatures with (Brush, PlotStyle, string) in the help guide that I linked.
The Brush can be supplied to the new stroke object.
Chelsea B.NinjaTrader Customer Service
Comment
-
perfect. how do I color the histo green if its above 0 and orange if its below 0?
public class CustomCCI : Indicator
{
private SMA sma;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "CustomCCI";
Name = "CustomCCI";
IsSuspendedWhileInactive = true;
Period = 100;
AddPlot(new Stroke(Brushes.Goldenrod), PlotStyle.Bar, "custom cci");
AddLine(Brushes.DarkGray, 200, NinjaTrader.Custom.Resource.CCILevel2);
AddLine(Brushes.DarkGray, 100, NinjaTrader.Custom.Resource.CCILevel1);
AddLine(Brushes.Yellow, 0, NinjaTrader.Custom.Resource.NinjaScriptIndicatorZe roLine);
AddLine(Brushes.DarkGray, -100, NinjaTrader.Custom.Resource.CCILevelMinus1);
AddLine(Brushes.DarkGray, -200, NinjaTrader.Custom.Resource.CCILevelMinus2);
}
else if (State == State.DataLoaded)
sma = SMA(Typical, Period);
}
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
Value[0] = 0;
else
{
double mean = 0;
double sma0 = sma[0];
for (int idx = Math.Min(CurrentBar, Period - 1); idx >= 0; idx--)
mean += Math.Abs(Typical[idx] - sma0);
Value[0] = (Typical[0] - sma0) / (mean.ApproxCompare(0) == 0 ? 1 : (0.015 * (mean / Math.Min(Period, CurrentBar + 1))));
}
}
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
597 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
343 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
556 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
555 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment