Stock Screener – Example 16: 3mo Relative Performance (% change of a portfolio’s components)

This is an example of a scan that demonstrates the enhanced “relperf()” and “rank()” functions; these functions can be used to compute and compare the % change of a portfolio’s components with any Index

3 minutes

This functionality was introduced in October 2023 (Version 23.10.1)

Below is an illustration of an enhanced scan that can be created using the Advanced Scanner in ChartAlert.

List symbols where relperf(cl,3,m) > Symbol Value(relperf(cl,3,m),NIFTY)

Add Column cl
Add Column Symbol Value(c,nifty) as CNifty
Add Column relperf(cl,3,m) as RP
Add Col Symbol Value(relperf(cl,3,m),NIFTY) as RPNifty
Add Column rank(relperf(cl,3,m), DESCENDING) as Rank

Sort on Column Rank 

Apply to Nifty

Below is a breakdown of the scan presented in a step-by-step manner.


Purpose of the Scan

  1. To generate a list of symbols where the 3-month percentage change (Relative Performance) of a portfolio’s components have outperformed the 3-month percentage change of the Nifty Index.
  2. To display the latest closing price of a qualifying symbol.
  3. To display the latest closing price of the Nifty Index.
  4. To display the 3-month percentage change of a qualifying symbol.
  5. To display the 3-month percentage change of the Nifty Index.
  6. To first sort the 3-month percentage change of a qualifying symbol (see point #4 above) in descending order and then rank the scan output.
  7. To scan the components of the following index: Nifty

Let’s go!



Line 1

List symbols where relperf(cl,3,m) > Symbol Value(relperf(cl,3,m),NIFTY)

The “List symbols” function plays a crucial role in creating a list of symbols. In this context, the scan function is used to generate a list of symbols that meet a specific condition: “relperf(cl,3,m) > Symbol Value(relperf(cl,3,m),NIFTY)”.

The “relperf(cl,3,m)” function calculates the 3-month relative performance, which is the percentage change in a symbol’s closing price over the past 3 months.

The “Symbol Value(relperf(cl,3,m),NIFTY)” function calculates the 3-month relative performance or percentage change in the closing price of a specific symbol, which in this case has been defined as “NIFTY,” using the notation “Symbol Value(xxx,NIFTY)”.

In both cases, “cl” represents the most recent closing price, and “3” and “m” indicate a 3-month period.

Therefore, when we analyze the entire expression “relperf(cl,3,m) > Symbol Value(relperf(cl,3,m),NIFTY)”, this scan will create a list of symbols where the 3-month percentage change in the symbols’ prices is greater than that of Nifty.


Lines 2 through 6

Add Column cl
Add Column Symbol Value(c,nifty) as CNifty
Add Column relperf(cl,3,m) as RP
Add Col Symbol Value(relperf(cl,3,m),NIFTY) as RPNifty
Add Column rank(relperf(cl,3,m), DESCENDING) as Rank

In this scan, the function “Add Column…” serves the purpose of displaying additional columns within a scan report.

In this case, the following five columns will be displayed:

  1. The most recent closing price (“cl”) of the symbol will be displayed in a column titled “cl.”
  2. The latest closing price of the Nifty index, denoted as “Symbol Value(c,nifty),” where “c” signifies the closing price, will appear in a column labeled “CNifty.”
  3. A column titled “RP” will exhibit the percentage change in a symbol’s closing price over the last three months, denoted as “relperf(cl,3,m).”
  4. The percentage change in Nifty’s closing price over the same three-month period, denoted as “Symbol Value(relperf(cl,3,m),NIFTY),” will be shown in a column named “RPNifty.”
  5. Another column, designated as “Rank,” will be included to first sort the data in the “RP” column in descending order (“DESCENDING”) and then rank it using the “rank()” function.

Please note that you have the option to customize the names or titles of all the columns to your preference.


Line 7

Sort on Column Rank

The “Sort on Column” is a function that allows a column to be sorted in an ascending or descending order.

In this case, the column titled “Rank” will be sorted in an ascending order (default setting).

Please note that you have the option to customize the name or title of a column to your preference.


Line 8

Apply to Nifty

The “Apply to…” function applies the scanning process to the Nifty Index, and the scan will effectively examine all the constituent elements of Nifty.


The Scan Report in ChartAlert

%d