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!
See more
See less

Partner 728x90

Collapse

Relative Strength Plot

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_JessicaP
    replied
    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.

    Leave a comment:


  • russ123
    replied
    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:


  • NinjaTrader_JessicaP
    replied
    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:


  • russ123
    started a topic Relative Strength Plot

    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
    }
    Last edited by russ123; 06-17-2016, 02:13 PM. Reason: added comments

Latest Posts

Collapse

Topics Statistics Last Post
Started by SnailHorn, 05-02-2024, 10:49 PM
3 responses
23 views
0 likes
Last Post SnailHorn  
Started by giulyko00, Today, 11:49 AM
1 response
3 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by marksingh87, 02-13-2024, 04:55 PM
6 responses
209 views
1 like
Last Post mshrstv
by mshrstv
 
Started by SnailHorn, Today, 08:38 AM
2 responses
4 views
0 likes
Last Post SnailHorn  
Started by Skifree, Yesterday, 11:38 PM
1 response
16 views
1 like
Last Post NinjaTrader_LuisH  
Working...
X