This functionality will be introduced in October 2023 (Version 23.10.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 as well as create a processing matrix between inputs, now replaces the need for writing at least twenty (!) separate scans as was required in the previous versions of ChartAlert.
ATTN: This scan is similar to the earlier scan (refer to Example 9: Multiple Parameters Multiple Values (“step”)), with the exception of the 4th line (“Cross OptVar”).
[BEGIN EMA(timeP1), RSI(timeP2)]
Set OptVar timeP1 = min:10,max:30,step:5
Set OptVar timeP2 = min:10,max:16,step:2
Cross OptVar
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
- 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 remained below the 70 threshold value; the EMAs used are EMA(10), EMA(15), EMA(20), EMA(25) and EMA(30), while the RSIs used are RSI(10), RSI(12), RSI(14) and RSI(16).
- To display the values of the latest Close, the various EMAs and the various RSIs in the scan results report.
- To scan the components of the following index: NIFTY100
- 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(20), RSI(14)
Line 2 and 3
Set OptVar timeP1 = min:10,max:30,step:5
Set OptVar timeP2 = min:10,max:16,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 five input values like “10,” “15,” “20,” “25” 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 5 (“step:5”), the five inputs for “timeP1” will therefore be EMA(10), EMA(15), EMA(20), EMA(25) 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 four input values like “10,” “12,” “14” and “16”.
Because the minimum input value is 10 (“min:10”), the maximum input value is 16 (“max:16”), and it will be stepped up in increments of 2 (“step:2”), the four inputs for “timeP2” will therefore be RSI(10), RSI(12), RSI(14) and RSI(16).
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 5 below to know more on how “timeP1” and “timeP2” get used in the scan.
Line 4
Cross OptVar
The “Cross OptVar” is a function that will help set up a processing matrix between the two optimized variables, namely “timeP1” and “timeP2”.
Since the variable “timeP1” has five inputs (EMA(10), EMA(15), EMA(20), EMA(25) and EMA(30)), and the variable “timeP2” has four inputs (RSI(10), RSI(12), RSI(14) and RSI(16)), the “Cross OptVar” function will help set up a matrix of (“timeP1” x “timeP2”) (5 x 4) 20 inputs for scanning the data.
See Line 5 below for specific details.
Line 5
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 a processing matrix of (5 x 4) 20 inputs.
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(10) AND RSI(12) < 70
3. Close crossed above EMA(10) AND RSI(14) < 70
4. Close crossed above EMA(10) AND RSI(16) < 70
5. Close crossed above EMA(15) AND RSI(10) < 70
6. Close crossed above EMA(15) AND RSI(12) < 70
7. Close crossed above EMA(15) AND RSI(14) < 70
8. Close crossed above EMA(15) AND RSI(16) < 70
9. Close crossed above EMA(20) AND RSI(10) < 70
10. Close crossed above EMA(20) AND RSI(12) < 70
11. Close crossed above EMA(20) AND RSI(14) < 70
12. Close crossed above EMA(20) AND RSI(16) < 70
13. Close crossed above EMA(25) AND RSI(10) < 70
14. Close crossed above EMA(25) AND RSI(12) < 70
15. Close crossed above EMA(25) AND RSI(14) < 70
16. Close crossed above EMA(25) AND RSI(16) < 70
17. Close crossed above EMA(30) AND RSI(10) < 70
18. Close crossed above EMA(30) AND RSI(12) < 70
19. Close crossed above EMA(30) AND RSI(14) < 70
20. Close crossed above EMA(30) AND RSI(16) < 70
Line 6
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 7
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 8
[END]
The optimized scan code concludes with an “END” statement.
The Scan Report in ChartAlert
