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
Relative Strength Plot
Collapse
X
-
Hello russ123,
Can I ask, what was the result when you added the two lines of code I sent you to your initialize routine? If you can provide us with a stripped down version of your code I would be happy to return you a tested copy with that code added, which will allow both data series to plot in the same panel.
-
Extending relative strength 5 to relative strength 5 and 20
Any body know the code to add to this indicator to allow for both plots - relative strength 5 and relative strength 20. Appreciate the feedback.
Leave a comment:
-
Hello russ123, and thank you for your question.
I am including a link to the Help Guide section on working with multiple time frames (as is your case) and instruments.
When you add your 20 day time series, I would recommend adding it like this :
Add("SPY", PeriodType.Day, 20);
I would add a Plot for relative strength (which will plot in the same panel as your indicator), like this,
Add(new Plot(Color.Orange, "RelativeStrength"));
Please let us know if there are any other ways we can help.
Leave a comment:
-
Relative Strength Plot
Hello,
I have developed a relative strength indicator that plots the 5 day relative strength vs. the spy. I want to plot the 20 day on it also. How do I add the second plot for the 20 day relative strength on the same pane as the 5 day relative strength ?
public class relativestrength : Indicator
{
#region Variables
int period =5; // this is for the 5 day relative strength. For the 20 day, it would be 20
private DataSeries RelStr;
double rs =0;
#endregion
protected override void Initialize()
{
Add("SPY", PeriodType.Day, 1);
Overlay = false;
// adding a 0 line. when the plot is above this line, stock is stronger than spy for the //specified period. When the plot is below this line, stock is weaker than the spy for the //specified period (eg 5 day -20 day etc.)
Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGree n), 0, "Zero"));
RelStr= new DataSeries(this);
CalculateOnBarClose=true;
}
protected override void OnBarUpdate()
{
if (CurrentBar <period){return;}
if(BarsInProgress==0)
{
// this is the relative strength formula
rs = ((Close[0]/Closes[1][0])-(Close[period]/Closes[1][period]))/(Close[period]/Closes[1][period]);
RelStr.Set(rs);
Value.Set(SMA(RelStr,3)[0]);
}
}
#region Properties
[Description("Numbers of bars used for calculations")]
[GridCategory("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
#endregion
}
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by TradeSaber, 05-17-2024, 10:33 PM
|
2 responses
15 views
0 likes
|
Last Post Today, 04:33 PM | ||
Started by Marklhc1988, 04-19-2023, 11:11 AM
|
13 responses
584 views
1 like
|
Last Post Today, 04:30 PM | ||
Started by ttrader23, Today, 09:33 AM
|
2 responses
16 views
0 likes
|
Last Post
by ttrader23
Today, 04:22 PM
|
||
Started by ETFVoyageur, Yesterday, 12:45 AM
|
2 responses
17 views
0 likes
|
Last Post Today, 04:12 PM | ||
Started by ETFVoyageur, Yesterday, 10:27 AM
|
3 responses
23 views
0 likes
|
Last Post Today, 03:49 PM |
Leave a comment: