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 Mindset, 04-21-2026, 06:46 AM
|
0 responses
67 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
95 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
53 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
108 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
63 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment