Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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:
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 CortexZenUSA, Today, 12:53 AM
|
0 responses
1 view
0 likes
|
Last Post
by CortexZenUSA
Today, 12:53 AM
|
||
Started by CortexZenUSA, Today, 12:46 AM
|
0 responses
1 view
0 likes
|
Last Post
by CortexZenUSA
Today, 12:46 AM
|
||
Started by usazencortex, Today, 12:43 AM
|
0 responses
5 views
0 likes
|
Last Post
by usazencortex
Today, 12:43 AM
|
||
Started by sidlercom80, 10-28-2023, 08:49 AM
|
168 responses
2,265 views
0 likes
|
Last Post
by sidlercom80
Today, 12:05 AM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
3 responses
11 views
0 likes
|
Last Post Yesterday, 11:58 PM |
Comment