Relative Index Comparison function - RIC()
RIC() function is based on the Relative Index Comparison tool to calculate relative strength against a benchmark over a defined period of time. For example, to calculate the performance of a stock against the benchmark index (eg XJO for ASX equities, SPX for US equities) over the last quarter in a watchlist:
RIC(DATESEL=Last Quarter, ZEROBASED=True, INDEX=XJO:ASX)
To display as a % in a watchlist divide by 100 and change the Column Type to Percentage:
RIC(DATESEL=Last Quarter, ZEROBASED=True, INDEX=XJO:ASX)/100
To calculate the relative performance from a fixed date change the Normalization Date property to User Defined and select the date from the calendar:
Change the colours for positive/negative values under Custom Labels:
New Highest Relative 3 Month High
For new relative 3 month highs versus the S&P500 index use the following script in a scan:
//Get relative value - RIC R1=RIC(DATESEL=Last Year, INDEX=SPX:WI); C1=CLOSE(R1); // Get highest RIC for last 3 months; H1 = HIGHESTHIGH(C1, BARS=3, BACKTYPE=Months); //Is latest RIC > last 3 months? R1 > H1
The Relative Index Comparison tool has the ability to display as a line (default) or as a bar or candlestick chart. As a result this indicator has Open / High / Low / Close values, though all but the closing values are hidden by default.
This needs to be considered when building scripts for the RIC indicator, especially when using functions that reference High / Low values such as HighestHigh() and LowestLow().
In the following example you will see a Show Plot has been applied to the RIC with the following script:
You can see in the above example the red line is not reflecting the highest value of the green RIC line. This is because the default of the HighestHigh will plot the highest value, but the default of the RIC will plot the closing value, and unless it closes on the high there will be a gap.
If we swap the RIC plot to display as a Bar or Candlestick chart you will see the source of the Show Plots value:
To display the Highest Value of the Close value produced by the RIC we need to adjust the script to the following:
V1 = CLOSE(); HIGHESTHIGH(V1, BARS=30)