This code adapts the code by vitvlkv to be appropriate for comparison of JSE stocks with the Top 40 index. It also includes moving averages and Bollinger Bands to identify extreme conditions. You can change the colours and deselect moving averages to make the plot less cluttered. You can also change the selection to compare the stock against to JSE:J201 if you want to compare it to the All Share Index.