Stock Screener – Example 9: Multiple Parameters Multiple Values (“step”)

This is an example of an optimized scan that demonstrates the enhanced (“step”) function; it can replace the need for writing several scans (as was required in the older versions of ChartAlert); this functionality for the Advanced Scanner will be introduced in September 2023.

4 minutes

This functionality will be introduced in September 2023 (Version 23.9.1)

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

This one enhanced scan, wherein multiple parameters/ variables can now accept multiple values/ inputs for scanning, now replaces the need for writing atleast six separate scans as was required in the previous versions of ChartAlert.

[BEGIN EMA(timeP1), RSI(timeP2)]

Set OptVar timeP1 = min:10,max:30,step:10
Set OptVar timeP2 = min:10,max:14,step:2

List symbols where c crossed above ema(timeP1) AND RSI(timeP2) < 70

Add Column Close
Add Column ema(timeP1) chart(lw=2)
Add Column rsi(timeP2) chart

Apply to NIFTY100

[END]

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 latest Close has just crossed above various EMAs (Exponential Moving Average), while the various RSIs (Relative Strength Index) have been below the 70 threshold value; the EMAs used are EMA(10), EMA(20) and EMA(30), while the corresponding RSIs used are RSI(10), RSI(12) and RSI(14).
  2. To display the values of the latest Close, the various EMAs and the various RSIs in the scan results report.
  3. To scan the components of the following index: NIFTY100
  4. To plot the requisite EMAs and the RSIs on the chart if a symbol is opened from inside the scan results report.

Let’s go!


Line 1

[BEGIN EMA(timeP1), RSI(timeP2)]

The optimized scan procedure starts with a “BEGIN” command.

The text “EMA(timeP1), RSI(timeP2)” that comes after the “BEGIN” command serves as the designated heading for the scan results that will be showcased in the scan report.

See Line 2 and 3 below to know how “timeP1” (associated with EMA) and “timeP2” (associated with RSI) will get used in the scan.

“EMA(timeP1), RSI(timeP2)” is designed to work like this: EMA(30), RSI(14)


Line 2 and 3

Set OptVar timeP1 = min:10,max:30,step:10
Set OptVar timeP2 = min:10,max:14,step:2

We are configuring or setting multiple optimized variables (“Set OptVar”) that will be referred to as “timeP1” and “timeP2”.

The variable “timeP1” (to be used in association with Exponential Moving Average) will function as a temporary marker or placeholder within the scan heading and will be substituted with input values like “10,” “20” and “30”.

Because the minimum input value is 10 (“min:10”), the maximum input value is 30 (“max:30”), and it will be stepped up in increments of 10 (“step:10”), the inputs for “timeP1” will therefore be EMA(10), EMA(20) and EMA(30).

Similarly, the variable “timeP2” (to be used in association with the RSI indicator) will function as a temporary marker or placeholder within the scan heading and will be substituted with input values like “10,” “12” and “14”.

Because the minimum input value is 10 (“min:10”), the maximum input value is 14 (“max:14”), and it will be stepped up in increments of 2 (“step:2”), the inputs for “timeP2” will therefore be RSI(10), RSI(12) and RSI(14).

The number of inputs each variable (“timeP1” and “timeP2”) can accept should be identical . . . in the current scan context, both these variables accept three inputs each.

You can customize both the terms “timeP1” and “timeP2” with anything of your choosing . . . Just remember to globally replace them for the scan to work.

See Line 4 below to know more on how “timeP1” and “timeP2” get used in the scan.


Line 4

List symbols where c crossed above ema(timeP1) AND RSI(timeP2) < 70

This scan has two conditions, “c crossed above ema(timeP1)” and “RSI(timeP2) < 70”, and it will generate a list of symbols where both the conditions have been met.

Thus, this scan will look for symbols where the current close (“c”) has crossed above its EMA (“ema(timeP1)”), and where the value of the RSI indicator (“RSI(timeP2) ”) is below the stated threshold of “70”.

Remember, the parameters/ variables “timeP1” and “timeP2” will encompass three inputs each.

In essence, upon execution, this scanning process will look for symbols where the following conditions have been met:

1. Close crossed above EMA(10) AND RSI(10) < 70
2. Close crossed above EMA(20) AND RSI(12) < 70
3. Close crossed above EMA(30) AND RSI(14) < 70


Line 5, 6 and 7

Add Column Close
Add Column ema(timeP1) chart(lw=2)
Add Column rsi(timeP2) chart

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

In this case, the scanning report will display three columns: the latest closing value, the latest value of the EMA, and the latest value of RSI.

These columns will be titled “Close,” “ema(timeP1)” and “rsi(timeP2”, respectively.

The function “chart(lw=2)” will simply plot the Exponential Moving Average (EMA) on the chart of the resultant symbol in ChartAlert, and the line width of the EMA would be set to “2” pixels.

The function “chart” will simply plot the RSI indicator along side the chart of the resultant symbol in ChartAlert.


Line 8

Apply to NIFTY100

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


Line 9

[END]

The optimized scan code concludes with an “END” statement.


The Scan Report in ChartAlert

%d bloggers like this: