ISMEMBER() Function
Overview
The ISMEMBER()
function can be used to show if the underlying stock is part of the selected index (S&P500, ASX200 for example) either currently, or at some time in the past. This is particularly useful when backtesting to avoid survivorship bias.
Note
This function requires Optuma Symbol Lists to be enabled as part of your subscription.
In a Signal Test or Back Test, select the Historical Membership option if available when the index is selected so that all stocks will be used in the test, and not just the current members.
However, the test will include the stock for the entire period of the test, and not just when it was in the index. For example, $TSLA was added to the S&P500 index in December 2020, but if the testing period starts in 2000 then $TSLA should not be included in the test until it has joined the index.
This is where the ISMEMBER()
function comes in. By adding it to your script formula then it will only include signals when ISMEMBER()
is true.
Note
US stocks will defualt to S&P500 membership, ASX stocks will defualt to ASX200 index, etc
For example, running a test on a moving average crossover will include all the signals for $TSLA that occurred before 2020 - as seen with the red arrows - which can significantly skew the results. By adding the ISMEMBER()
condition will only include the signals after the stock was added to the index (green arrows):
MA(BARS=50, CALC=Close) CrossesAbove MA(BARS=200, CALC=Close)
and ISMEMBER()
The chart below shows the progression of $LYV from S&P600 SmallCaps (2006-2014), S&P400 MidCaps (2014-2019), and S&P500 (2019-present) using the Show View formulas: