Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Plotting EMA on RSI
Collapse
X
-
Actually, instead can you tell me what im doing wrong in the section of code below. I have the RSI setup to plot a different color based on over or under 50 which works fine, but trying to add an EMA but the line doesn't show up. It seems to just adjust the RSI line instead...
protectedoverridevoid Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "Bull"));
Add(new Plot(Color.FromKnownColor(KnownColor.DarkGray), PlotStyle.Line, "Neutral"));
Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Line, "Bear"));
CalculateOnBarClose = true;
Overlay = false;
Plots[0].Min = 50.5;
Plots[1].Max = 50.5;
Plots[1].Min = 49.5;
Plots[2].Max = 49.5;
}
protectedoverridevoid OnBarUpdate()
{
if (CurrentBar < Period) return;
double average = EMA(RSI(period, 3), Fast) [0];
Bull.Set(average);
Neutral.Set(average);
Bear.Set(average);
}
-
zachj,
Unfortunately I do not have a link to assist you.
However, you are on the right track. You will need to create a new Plot for your RSI line and the calculation for your RSI line.
Example:
You will also need to expand the Properties region to include the following:Code:protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "Bull")); Add(new Plot(Color.FromKnownColor(KnownColor.DarkGreen), PlotStyle.Line, "Neutral")); Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Line, "Bear")); [B]Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "RSIPlot"));[/B] Overlay = false; Plots[0].Min = 50.5; Plots[1].Max = 50.5; Plots[1].Min = 49.5; Plots[2].Max = 49.5; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (CurrentBar < Period) return; double average = EMA(RSI(Period, 3), Fast) [0]; [B]double rsiline = RSI(Period, 3)[0];[/B] // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. Bull.Set(average); Neutral.Set(average); Bear.Set(average); [B]RSIPlot.Set(rsiline);[/B] }
Code:[Browsable(false)] [XmlIgnore()] public DataSeries RSIPlot { get { return Values[3]; } }
Note that you can also use the New Indicator Wizard to create plots.CameronNinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
607 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
353 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 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
560 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
561 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment