RRC Stock Screener – Example 5: Present in a specific RRC quadrant for more than ‘n’ bars

Sectoral Rotation, or Relative Rotational charts, are a powerful visual tool in assessing how different sectors compare in terms of their relative strength and momentum; it’s easier to spot stronger and weaker sectors, thus highlighting possible changes in market leadership and trends in asset performance

7 minutes

This functionality, pertaining to Relative Rotational Charts (RRC), was introduced in October 2023.


RRC Scan Example #5:
Look for stocks that are presently in a specific RRC quadrant, and have been in that quadrant for more than “n” time period

List symbols where 
pattern is RRC Q2
AND barssince(pattern is RRC New Q2) > 10

Add column barssince(pattern is RRC New Q2) as BS
'Sort on column BS desc

Add Column RSRATIO as RSR
Add Column RSMOMENTUM as RSM
Add Column RRCSTATUS as Status
Add Column RRCSTATUS a bar ago as PvsStatus
Add Column RRCQUADRANT as Quad chart
Add Column RRCQUADRANT a bar ago as QuadYest chart

Apply to NIFTYTOTAL

Purpose of the Scan

The purpose of this scan is to look for component stocks of the “NIFTYTOTAL” Index that presently reside in the “RRC” quadrant “Q2” (Leaders or Outperformers), and they must have been residing in that quadrant for more than “n” bars.

The scan also creates a column called “BS” (for Bars Since) to keep track of how long ago the pattern showed up, and sorts the stocks based on that column in descending order.



Lines 1 through 3

List symbols where 
pattern is RRC Q2
AND barssince(pattern is RRC New Q2) > 10

The “List symbols where …” function establishes a condition, or conditions, that stocks must meet in order to be included in the scan results.

The “pattern is RRC Q2” function looks for symbols that are presently residing in the RRC Q2 quadrant. Please note that the Q2 quadrant is where leaders or stocks outperforming the underlying benchmark (say, NIFTY) reside.

The “pattern is RRC New Q2” function looks for *when* the stocks newly moved into the RRC Q2 quadrant from other quadrants, usually the Q1 (Improving Relative Strength) or Q3 (Weakening Relative Momentum) quadrants.

After determining *when* the stocks moved into a specific quadrant, it becomes easy to determine how long ago that ‘when’ was. That’s what the next function determines.

The “barssince(pattern is RRC New Q2) > 10” function checks and ensures that the qualifying stocks had newly moved into the RRC Q2 quadrant at least more than (“>“) “10” bars ago. A “bar” is like a time unit, one day on a daily timeframe or one week on a weekly timeframe, so this part of the scan code checks if the pattern happened a while ago.


Lines 4 and 5

Add column barssince(pattern is RRC New Q2) as BS
'Sort on column BS desc

This one creates a column (“Add Column“) called “BS” and fill it with the number of bars (“barssince()“) that have elapsed since the occurrence of the event “pattern is RRC New Q2” for each qualifying stock. This column (thus) helps keep track of how long ago the pattern showed up.

The column title “BS” can be modified or personalized to your preference.

After creating the “BS” column, the scan code will arrange the stocks in descending order (“Sort on column BS desc“) based on the values in the “BS” column. This means stocks with a higher “BS” value (meaning the pattern occurred longer ago) will be listed first.

Please note that the function “Sort on column BS desc” has (however) been commented out or disabled in the above scan code by prefixing it with ““. Therefore, this line will be ignored when the scan code is executed.


Line 6

Add Column RSRATIO as RSR

This line instructs the scan to create a column (“Add Column“) called “RSR” and list the values of the “RSRATIO” function into it. This is done to make it easier to work with the RSRATIO data.

The column title “RSR” can be modified or personalized to your preference.


Line 7

Add Column RSMOMENTUM as RSM

Similarly, this line creates a column (“Add Column“) called “RSM” and copies the values of the “RSMOMENTUM” function into it. Again, it’s for convenience and analysis.

The column title “RSM” can be modified or personalized to your preference.



Line 8

Add Column RRCSTATUS as Status

Here, a new column called “Status” is added (“Add Column“), and it contains information related to the stocks’ status or condition (“RRCSTATUS“) in the context of a Relative Rotational chart’s (RRC) scatter plot.

The column title “Status” can be modified or personalized to your preference.


Line 9

Add Column RRCSTATUS a bar ago as PvsStatus

This line creates another column (“Add Column“) called “PvsStatus” and lists values of the “RRCSTATUS” function from one bar ago (“a bar ago“) into it. It helps in comparing the current status with its previous status.

The column title “PvsStatus” can be modified or personalized to your preference.


Line 10

Add Column RRCQUADRANT as Quad chart

A new column named “Quad” is created (“Add Column“), and it contains information related to the stocks’ status or condition (“RRCQUADRANT“).

The “RRCQUADRANT” function helps us figure out which quadrant a symbol falls into on the Relative Rotational chart (RRC), and it gives us one of the labels like “Q2” (which is the same as LEADERS) or “Q4” (which is the same as LAGGARDS) to describe its position.

The function “chart” allows the RS-RATIO and RS-MOMENTUM indicators to be plotted an the chart should you open a symbol’s chart from within the scan results report.

The column title “Quad” can be modified or personalized to your preference.


Line 11

Add Column RRCQUADRANT a bar ago as QuadYest chart

This one creates a column (“Add Column“) called “QuadYest” and displays values of the “RRCQUADRANT” function from one bar ago (“a bar ago“) into it. This allows for comparisons between the current quadrant and the one from the previous bar.

The function “chart” allows the RS-RATIO and RS-MOMENTUM indicators to be plotted an the chart should you open a symbol’s chart from within the scan results report.

The column title “QuadYest” can be modified or personalized to your preference.


Line 12

Apply to NSE

This “Apply to …” function tells the scan code to focus its search on spot or cash stocks that are listed on the National Stock Exchange (“NSE“).


The Scan Report in ChartAlert

%d