Your interactive trading laboratory!
 • 
4 users online

Connors RSI (CRSI) in QS

Hi Glitch, Is the Connors RSI available in QS for the public? If not, can you make it available?

I currently have an sample written in Ninja.

public class ConnorsRSI : Indicator
{
    private int rankPeriod = 100;
    private int streakPeriod = 2;
    private int rsiPeriod = 3;
    private int barsAgo = 0;
    private double rank = 0.0;
    private double percentRank = 0.0;
    private ROC rateOfChange;
    private RSI streakRSI;
    private RSI defaultRSI;
    private Series<double> streak;

    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
            AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Line, "Connors RSI");
            AddLine(Brushes.Red, 90, "Upper");
            AddLine(Brushes.Green, 10, "Lower");
        }
        else if (State == State.Configure)
        {
            BarsRequiredToPlot = rankPeriod / 2;
        }
        else if (State == State.DataLoaded)
        {
            streak = new Series<double>(this, streakPeriod < 250 ? MaximumBarsLookBack.TwoHundredFiftySix : MaximumBarsLookBack.Infinite);
            rateOfChange = ROC(Input, 1);
            streakRSI = RSI(streak, streakPeriod, 3);
            defaultRSI = RSI(Input, rsiPeriod, 3);
        }
    }

    protected override void OnBarUpdate()
    {
        if (CurrentBar < 1)
        {
            streak[0] = 0;
            ConnRSI[0] = 50.0;
            return;
        }

        barsAgo = Math.Min(rankPeriod, CurrentBar);
        rank = 0.0;

        for (int i = 1; i <= barsAgo; i++)
        {
            if (rateOfChange[0] > rateOfChange[i])
                rank = rank + 1.0;
        }

        percentRank = 100 * rank / barsAgo;

        if (Input[0] > Input[1])
            streak[0] = streak[1] < 0.5 ? 1.0 : streak[1] + 1.0;
        else if (Input[0] < Input[1])
            streak[0] = streak[1] > -0.5 ? -1.0 : streak[1] - 1.0;
        else
            streak[0] = 0.0;

        ConnRSI[0] = (percentRank + streakRSI[0] + defaultRSI[0]) / 3.0;
    }
}
Attachment

Cancel

Responses

Yes, we will get this added to the indictors library for the next release.

Yes, we will get this added to the indictors library for the next release.

Thanks

Thanks
Forum Tips

Please sign in if you want to participate in our forum.

Our forum uses Markdown syntax to format posts.

To embed code snippets, enclose them in [CODE][/CODE] tags.