Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relative Strength Comparison

See original GitHub issue

Relative Strength Comparison

Relative Strength Comparison compares a security’s price change with that of a “base” security or index. When the Relative Strength Comparison indicator is moving up, it shows that the security’s price is performing better than the base security/index in relative terms. When the indicator is moving sideways, it shows that both securities prices are rising and falling by the same percentages. When the indicator is moving down, it shows that the security’s price is performing worse than the base security/index in relative terms. Relative Strength Comparison is often used to compare a security’s performance with a market index.

Read More…

And another read from

I’ve built this in my own system but I’d like to migrate my system to use your library. It shouldn’t be too hard to port to your formatting and I wouldn’t mind making an attempt PR on this, though I’m not sure when I’ll have time. Also your chops are definitely better than mine so perhaps you can improve upon my version.

Here’s my code:

    public class RelativeStrengthComparison : IndicatorBase
        public int AvgLength = 9;

        public decimal[] Result { get; set; }

        public decimal[] Average { get; set; }

        private bool _computeAverage = false;

        private int _collectionLength = 0;

        public RelativeStrengthComparison(IEnumerable<Candle> focus, IEnumerable<Candle> compare, int length, bool computeAverage = false)
            : base(focus, compare)
            AvgLength = length;
            _computeAverage = computeAverage;

        protected override void Initialize()
            _collectionLength = Math.Min(Series.Length, SeriesCompare.Length);
            Result = new decimal[_collectionLength];
            Average = new decimal[_collectionLength];

        public override void Compute(int startIndex = 0, int? endIndex = null)
            if (endIndex == null)
                endIndex = _collectionLength;

            for (int index = startIndex; index < endIndex; index++)
                decimal focusClose = Series.Close[index];
                decimal comprClose = SeriesCompare.Close[index];

                decimal result = focusClose / comprClose;

                Result.SetValue(result, index);

                if (_computeAverage)
                    Average[index] = Avg(Result, index, AvgLength);

        public decimal Avg(decimal[] input, int index, int period)
            var pos = Math.Max(index - period + 1, 0);

            if (pos == 0)
                return 0;

            var sum = input.Sum(index, period);
            return sum / period;

Additional context or information

My use case for this is building watchlists for my algorithm to watch.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

DaveSkendercommented, May 18, 2021

This is similar to our existing indicator: Price Relative Strength. I’m adding it to the backlog and will likely take a look at it this weekend.

github-actions[bot]commented, Aug 21, 2021

This Issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new Issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relative Strength Comparison
Relative Strength Comparison compares two securities, or a security and an index, to show relative performance to each other. ... Relative Strength Comparison ......
Read more >
Price Relative / Relative Strength - ChartSchool
The Price Relative indicator compares the performance of one security to another with a ratio chart. This indicator is also known as the...
Read more >
Comparative Relative Strength
Comparative Relative Strength (CRS) is used to compare a security against an index, or against another security. The comparison is used to show...
Read more >
Relative Strength (Compare)
Relative Strength (Compare) ... Similar to the Price Ratio indicator, Relative Strength plots the ratio between two stock, or index, prices as a...
Read more >
Relative Strength - What Is It, Explained, Example ...
Relative strength is a tool used in technical analysis to compare the price performance of one stock or asset to a benchmark, such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found