Stock Screener – Example 20: List all instances of a n-mo Price Performance greater than 100% in the last 5+ years

This is an example of a scan (all instances of a 100%+ return in any ‘n’-month rolling period in the last ‘m’ years) that can be written using the Advanced Scanner that ships with ChartAlert.

3 minutes


ATTN: This scan is similar to an earlier scan (refer to Example 19: n-month Price Performance greater than 100% in the last 5+ years), with the exception that we’re actually going to extract data in this scan.


List data from "01-Jan-2018" 
where chg%(cl, cl 2 months ago) > 100

Add Column date 2 months ago as Dt2mAgo
Add Column close 
Add Column close 2 months ago as C2mAgo

Add Column chg%(cl, cl 2 months ago) as 2moChg
Add Column SymbolValue(chg%(cl, cl 2 months ago),NIFTY) as 2moChgNifty

Apply to nifty500

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


Purpose of the Scan

  1. Generate a list of symbols and the dates when a symbol had a return of over 100% in the last 2 months at any point within the last 5+ years.
  2. In the scan results report, include the following five columns in this specific order:
    • The date that is two months prior to the current date
    • The closing price of the symbol
    • The closing price of the symbol from two months ago
    • The registered 2-month percentage gain of the symbol
    • The registered 2-month percentage gain of the popular NIFTY50 Index
  3. Apply this scanning process to the components of the NIFTY500 index.

Let’s go!



Lines 1 and 2

List data from "01-Jan-2018" 
  where chg%(cl, cl 2 months ago) > 100

The “List data” function enables users to obtain historical data for specific dates for symbols within a chosen group or portfolio.

In this particular scan code, we aim to retrieve data starting from January 1, 2018 (“from “01-Jan-2018””).

Moreover, the “List data” function in this scan code incorporates a filtering condition (“where ”) that screens symbols based on a query expression “chg%(cl, cl 2 months ago) > 100”.


Lines 3 through 5

Add Column date 2 months ago as Dt2mAgo
Add Column close 
Add Column close 2 months ago as C2mAgo

In this scan code, we use the “Add Column…” function to enhance the information presented in our scan results report.

Firstly, we introduce a customizable column titled “Dt2mAgo”, which will display, for reference purposes, the date corresponding to two months prior to the current date (“date 2 months ago”) for each symbol that meets our criteria.

Additionally, we are including another column that will display the closing price of the qualifying symbols. This column is being assigned the default name “close”.

Lastly, we are incorporating a customizable column labeled “C2mAgo”, which will display, for reference purposes, the closing price of each qualifying symbol from two months ago (“close 2 months ago”).


Line 6

Add Column chg%(cl, cl 2 months ago) as 2moChg

We are including a new column, which you can customize with a name of your choice, labeled “2moChg”, to display the actual two-month percentage return value (“chg%(cl, cl 2 months ago)”) for each symbol that meets the specified criteria or has been filtered accordingly.


Line 7

Add Column SymbolValue(chg%(cl, cl 2 months ago),NIFTY) as 2moChgNifty

In the current context, we are introducing an additional column, which you can customize and name as you prefer, labeled “2moChgNifty”.

This column will display the actual 2-month percentage return (“chg%(cl, cl 2 months ago)”) of the NIFTY Index (“SymbolValue(DataField,NIFTY)”) whenever a qualifying symbol’s 2-month percentage return exceeds a 100% gain.


Line 8

Apply to nifty500

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


The Scan Report in ChartAlert

%d