IBD Relative Strength Line, within or not within a consolidation

One of the key uses of IBD's Relative Strength Line is when it makes a new high (three months, typically) within a consolidation, which shows unusual strength in a stock that can lead to a powerful breakout. Therefore it's a good idea to look out for them!

Here is some useful code to calculate the RSL, find the new highs, find the new highs within the latest consolidation, and plot them in the chart.

IBD usually plots a blue dot on the last value of the RSL if it is a new high, rather this code plots them along the whole RSL, and colours them differently if they are within a reasonable length of consolidation.

This was tested with version 6.30.5.

// Calculcate the RSL
RSL  = C/Foreign("$SPX", "C")*1500;

// bias the RSL to appear below your chart without screwing it up (you may need to adjust the 2.25 value to your tsate)
rslb = RSL + LastValue(C)/2.25;

// plot the RSL on the chart
Plot(rslb, "RS Line", colorBlue, styleDashed);

// find the last highest value in the last three months
H_HHV = HHV(H,69);

// find the number of bars since this high occurred
BaseHigh = BarsSince(H == H_HHV);

// find the high of the RSL within the consolidation
RS_HHV = HHV(RSL, BaseHigh);

// check if a new RSL new high occurs
RSNH = RSL > Ref(RS_HHV, -1);

// determine if the RSL new high is within a decently long consolidation (I chose four weeks)
RSNH_inbase = RSNH AND BaseHigh > 20;

// plot the dots for regular RSL new highs and those within consolidation with different colours
PlotShapes(IIf(RSNH, shapeCircle, shapeNone), colorAqua, 0, rslb, 0);
PlotShapes(IIf(RSNH_inbase, shapeCircle, shapeNone), colorOrange, 0, rslb, 0);

Example chart:
image

7 Likes

Note the multiplication by 1500 on the RSL is also part of the biasing to get it to chart correctly. I probably should move that calculation to the bias code line. Sorry for the sloppiness!

// Calculcate the RSL
RSL  = C/Foreign("$SPX", "C");

// bias the RSL to appear below your chart without screwing it up (you may need to adjust the 2.25 value to your tsate)
rslb = RSL*1500 + LastValue(C)/2.25;
4 Likes

Sorry, I realized there is one small error:

This:

// find the high of the RSL within the consolidation
RS_HHV = HHV(RSL, BaseHigh);

Should be:

// find the high of the RSL within the consolidation
RS_HHV = HHV(RSL, 69);

This is because the RSL New High "blue dot" rule is for 3 months.

Full code repasted for convenience:

// Calculcate the RSL
RSL  = C/Foreign("$SPX", "C");

// bias the RSL to appear below your chart without screwing it up (you may need to adjust the 2.25 value to your tsate)
rslb = RSL*1500 + LastValue(C)/2.25;

// plot the RSL on the chart
Plot(rslb, "RS Line", colorBlue, styleDashed);

// find the last highest value in the last three months
H_HHV = HHV(H,69);

// find the number of bars since this high occurred
BaseHigh = BarsSince(H == H_HHV);

// find the high of the RSL within the consolidation
RS_HHV = HHV(RSL, 69);

// check if a new RSL new high occurs
RSNH = RSL > Ref(RS_HHV, -1);

// determine if the RSL new high is within a decently long consolidation (I chose four weeks)
RSNH_inbase = RSNH AND BaseHigh > 20;

// plot the dots for regular RSL new highs and those within consolidation with different colours
PlotShapes(IIf(RSNH, shapeCircle, shapeNone), colorAqua, 0, rslb, 0);
PlotShapes(IIf(RSNH_inbase, shapeCircle, shapeNone), colorOrange, 0, rslb, 0);
7 Likes

Thanks for this @rocketPower! Your code examples are amazing. I was actually scouring the forum just now looking for examples of searching for consolidations/bases. I saw your VCP post and I plan to look into that one.

But I also noticed your text off to the side of your chart posted here. Do you have some sort of automated base detection and labeling going on? Did you happen to do a write up on that?

That whole panel on the side of your chart is pretty great for at-a-glance information.

3 Likes

Yes I developed code with Sebastian DiMauro that detects bases and VCPs and parameterizes them to check for basic quality. It's not perfect but it helps a lot.

This was for his The Private Trader service before i took it over and renamed it the DiMauro Tribe. I continue to maintain this code but I can't share it, unfortunately!

Thanks so much for the kind words!

3 Likes

Makes sense. Thanks for all you do share though. Your posts are especially helpful for someone trying to learn Amibroker with an IBD slant because you do such a great job explaining your rationale with comments. I definitely appreciate what you have done here.

1 Like

Hit me up if you ever have questions!

4 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.