Slope of Hope Blog Posts

Slope initially began as a blog, so this is where most of the website’s content resides. Here we have tens of thousands of posts dating back over a decade. These are listed in reverse chronological order. Click on any category icon below to see posts tagged with that particular subject, or click on a word in the category cloud on the right side of the screen for more specific choices.

Bolling for Soup (by nummy)

By -

So, for at least the past 4 weeks, SPX has maintained itself in a 35 point range.  What this has done to band systems like the Bollinger Bands (red) and Keltner Channels (yellow) has set us up for a fairly rare occurrence.  Firstly, the Bollinger Bands width (upper band – lower band) has dropped below 30 SPX points.  This hasn't happened for several months.  Secondly, the Bollinger bands have turned fairly flat.  Lastly, the Bollinger Bands (BB) have worked their way inside the Keltner Channels (KC).

2009-12-12-TOS_CHARTS_01

A good question is, how can one quantify this to look for a similar situation that has occurred in the past?  Ideally, we would like to see where this has happened in the past, and look at the result for clues as to what could happen in the present.  We could do this visually, but it would take a lot time staring at charts.  I will briefly go through how to develop a simple thinkscript indicator to indicate when this situation is occurring.

Firstly, it is fairly easy to check the BB band width.  You just subtract the LowerBand value from the UpperBand to get your width.

Secondly, to describe the flatness of a line, we want to use a derivative, or difference.  If we take the current upper band value and subtract the upper band value of the previous candle, we get the slope of that line.  In the chart above, what is in the lower portion of the chart are the derivatives of each band (upper BB', lower BB', upper KC', lower KC').  We want to find a time in the past where the derivatives are close to 0, implying BB/KC flatness.  We don't really care whether the slope is negative or positive because, since they are so close to 0, they imply flatness.  In order to disregard the sign of the derivative, we can use the AbsValue() function and compare it to a threshold to determine flatness.  Here is some pseudo-code for what we would be looking for:

AbsValue(UpperBBSlope) < threshold and AbsValue(LowerBBSlope) < threshold and 
AbsValue(UpperKCSlope) < threshold and AbsValue(LowerKCSlope) < threshold

If we look at our current BB/KC slope values, we want to check that the AbsValue of the current slopes of upper/lower BB/KC lines are less than a threshold, say, 2.5.  Then, we also want to check that we have been flat for some time.  To do this, we can verify that the slopes of BB/KC lines of the last three periods are less than another threshold, say, 1.  Please note that these thresholds are only applicable to the scale of SPX.  In SPX, the BB width is about 30 SPX points while in SPY, the BB width would be about 3 SPY points.  These thresholds must be adjusted in the code if you intend to use this with another ticker symbol.  If you were going from SPX to SPY, you could multiply the threshold and BB width by approximately 1/10 (since SPY is approximately 1/10 of SPX).  All this checking of band slopes is doing is making sure we are near 0 for the past 4 candles.

Finally, we want to check that the BB is inside the KC.  This is also fairly simple, we can check that UpperKC > UpperBB and LowerKC < LowerBB.

Now we have all of our conditions to give us a signal:

1- BB width is less than or equal to 30 points
2- AbsValue(UpperBBSlope) < 2.5 and AbsValue(LowerBBSlope) < 2.5
3- AbsValue(UpperKCSlope) < 2.5 and AbsValue(LowerKCSlope) < 2.5
4- AbsValue(UpperBBSlope[1]) < 1 and AbsValue(LowerBBSlope[1]) < 1
5- AbsValue(UpperKCSlope[1]) < 1 and AbsValue(LowerKCSlope[1]) < 1
6- AbsValue(UpperBBSlope[2]) < 1 and AbsValue(LowerBBSlope[2]) < 1
7- AbsValue(UpperKCSlope[2]) < 1 and AbsValue(LowerKCSlope[2]) < 1
8- AbsValue(UpperBBSlope[3]) < 1 and AbsValue(LowerBBSlope[3]) < 1
9- AbsValue(UpperKCSlope[3]) < 1 and AbsValue(LowerKCSlope[3]) < 1
10- UpperKC > UpperBB and LowerKC < LowerBB

Note that UpperBBSlope means the current slope of the upper BB while UpperBBSlope[1] means 1 period ago (and [2] for 2 periods ago, [3] for 3 periods ago, etc.).  We can combine this into an if statement in thinkscript and check that all conditions are met.  Again, in pseudo-code:

if condition 1 and conditions 2-9 and condition 10 are all true, return 1, otherwise return 0.

So our signal should be 0 all the time unless our conditions are all true in which case it should spike to 1.  To create this script, I used the existing BollingerBandsSMA and KeltnerChannels scripts that come with TOS.  I combined both BB & KC into one script, so I could use data from each.

2009-12-12-TOS_CHARTS_02

So above we have our signal.  Let's look in the past to find similar occurrences.  Look familiar?

2009-12-12-TOS_CHARTS_03

So, keep in mind this happened before in December 2005.   The candle action looks almost identical to where we are today.  Three white candles up and above the mid-lines of BB and KC.  Back in December 2005, SPX re-tested the lows of the range it had been in for about a month (like now) and made slightly new lows.  Will history repeat itself?  Probably not, but it would be nice to see a selloff into OPEX week for once.  So take away what you will from this past occurrence and keep in mind there is always the chance of a fake-out on a BB squeeze.  The bulls seem ready to take charge again and break the range to the upside, but a lonely bear can dream of a downside squeeze, right?

If you'd like, you can download the script here Download NewStudy7STUDY.

New Slope Design

By -

Today I'm taking the wraps off the blog's new design; I hope you like it!

I've been doing computer stuff for 30 years now, so I've been around the block a few times. Based on my experience, I imagine out of 100 people, 96 folks will be fine with the site, 1 will say so, and 5 people will have some kind of expressed complaint. So it will seem like 80% of folks don't like it, most of whom simply "preferred things the way they were!" But maybe I'm just being cynical.

But if you see out-and-out problems (e.g. visiting Slope erases your hard disk), say so in the comments section. Things should be pretty self-explanatory; I've just spiffied things up.

Freedom’s Call

By -

I believe that the forces of history are larger than the people living within them. A handful of people try to push back at these waves – and those who do so with virtuous reasons (like those who truly deserve the Peace Prize, such as Walesa and Mandela) are remembered fondly. But as a whole, humanity is heaved by these waves, for better or worse.

The "wave" right now is pro-government, pro-taxes, pro-regulation, anti-business, and I think we're only a couple of years into it. My rantings against investment banks might be misinterpreted as those of a socialist fringe, but it's not. I am pro-business, pro-freedom, and anti-bureaucracy. It doesn't surprise me that Washington's answer for what had harmed this country is more government, because……..well…….what else would a government say? Self-interest holds sway, whether for a person or an institution.

Fortunes made through innovation and industry are admirable. Fortunes made through rigged games and government bailouts are contemptible. That's why someone like Steven P. Jobs is worth about 100,000 Lloyd Blankfeins.

But the lure of socialism in troubled times grows stronger, and as I think times are going to get worse, I think government's "help" is just going to keep increasing. If public outrage can spur on legislation that we're seeing these days in a year where the market has exploded higher, what do you think things will be like if the market falls for a few years?

These little videos are potent reminders of what was……….

…….and, cornball as it might be, here is some U.S. propaganda (and I use the term fondly) declaring what this nation was all about. That's the America that I love.