I’ve created this thread for some of the charts that are posted on our Twitter account. If there are any you would like to see post the request and Tweet link in a reply.
I’ll start with this one that uses the custom Market Breadth module to calculate the daily percentage of stocks in the S&P500 that outperform the index. As the S&P500 is a market cap weighted index the largest companies have a bigger impact on performance. So when the number of companies outperforming the index is low its the big guys doing the work, whereas if 73% are outperforming then performance will be skewed to the smaller caps.
This will count the number of stocks whose relative performance is higher than the previous bar. If true, then it has outperformed the index on that day and is given a value of 1. The breadth engine will then calculate the percentage of true results for each day to build the data. For accuracy, use the Historical Membership if running on the S&P500 so that only stocks that were in the index at the time are included.
Once the breadth data has been built (this example created a ticker symbol SPXOUTPF) then it should display when you open the attached workbook. The Watchlist will load the latest data for the S&P500 stocks and put them into true/false groups. If you have our Fundamental Data on your account then it will also calculate the average market cap size of each group for that day’s trading.
Download and save the workbook top open the chart (if you don’t have the Market Breadth module then the lower panel will be blank).
This uses the Switch function to signal when the RSI crosses above 70 and remain true until it crosses below 30, as seen in the green shaded area (created in a Show View dragged over the RSI).
SWITCH(RSI(BARS=14)>70, RSI(BARS=14)<30)
Days since Overbought:
V1 = RSI(BARS=14)>70;
TIMESINCESIGNAL(V1)
Number of Overbought conditions since the last Oversold:
//Create 2 Boolean conditions
V1 = RSI(BARS=14) CrossesAbove 70;
V2 = RSI(BARS=14) CrossesBelow 30;
//Count the number of times V1 occurred since V2
COUNTMATCHSINCESIGNAL(V1,V2)
//Define Swings;
GS1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar, USEINSIDE=True);
//SwingTrend is Up;
R1 = SWINGTRENDUP(GS1) == 1;
//Swing direction changes to up when trend is Up;
R2 = SWINGUP(GS1) ChangeTo 1 and R1;
//Lower swing low when trend is down;
R3 = SWINGTRENDDOWN(GS1) == 1;
//Count how many occurrences of R2 since R3 (not incl initial low swing);
COUNTMATCHSINCESIGNAL(R2, R3) - 1
The example in the Tweet was using IQFeed data (VINA.Z / VINT.Z) but the same can be calculated using our Breadth Measures data. This example is for SPX, which can be used in a Show View set to histogram:
ADV = GETDATA(CODE=AVVSPX:BM);
DEC = GETDATA(CODE=DVCSPX:BM);
ADV/(ADV+DEC)*100
This can then be used in a Show Bar to highlight when the day’s value is > 80% or < 20%. The following combines the two to show when an >80% day follows a <20% day:
ADV = GETDATA(CODE=AVVSPX:BM);
DEC = GETDATA(CODE=DVCSPX:BM);
V1 = ADV/(ADV+DEC)*100;
R1 = V1>80;
R2 = V1<20;
//Is today > 80 and yesterday < 20?
R1 and R2[1]
This script can be used to show if there was a gap greater than 0.5% from the low on Friday 17th:
//Set Gap Low Date;
LowDate = BARDATE()==STRDATE(DATE=2021-09-17);
//Set Gap High Date;
GapDate = BARDATE()==STRDATE(DATE=2021-09-20);
//Get High / Low values for those days;
FriLow = VALUEWHEN(LOW(),LowDate);
MonHi = VALUEWHEN(HIGH(),GapDate);
//Was there a 0.5% gap down?
MonHi < FriLow * 0.995
To find if the gap has been filled add this to the last line:
and HIGHESTHIGH(RANGE=Range, RANGESTART=2021-09-20) > FriLow
As of Thursday 23rd, 128 of the 150 gaps had been closed.
The Tweet was based on a 3 bar Gann Swing, but it can be applied to a Percent or Volatility Swing (simply change the S1 variable which will then be used by the SWINGTRENDUP and SWINGTRENDDOWN functions).
//Define swing;
S1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar, USEINSIDE=True);
SWINGTRENDUP(S1) ChangeTo 1 or
SWINGTRENDDOWN(S1) ChangeTo 1