Dear Ralph,
We killed like champions.

I think of this line from Hunter Thompson every time I book a good win.
I miss you, man.

The Long Way

I have a lot of time on my hands to run random studies during the day to see what happened the last time a particular setup appeared. Sometimes my studies yield interesting looks at the market and other times, meh, not so much.

Yesterday I noticed that the e-mini S&P had closed lower than it opened on six of the last seven days. I wasn’t sure how to code that question into thinkorswim (my trading platform) so if the code looks a little more verbose than it should be, well then feel free to help me shorten it by adding a comment below.

First, the code:

# random thoughts

def a1 = close < open;
plot b1 = if a1 is true then 1 else 0;
def a2 = close[1] < open[1];
plot b2 = if a2 is true then 1 else 0;
def a3 = close[2] < open[2];
plot b3 = if a3 is true then 1 else 0;
def a4 = close[3] < open[3];
plot b4 = if a4 is true then 1 else 0;
def a5 = close[4] < open[4];
plot b5 = if a5 is true then 1 else 0;
def a6 = close[5] < open[5];
plot b6 = if a6 is true then 1 else 0;
def a7 = close[6] < open[6];
plot b7 = if a7 is true then 1 else 0;
plot roosevelt = (b1 + b2 + b3 + b4 + b5 + b6 + b7) > 5;
AssignPriceColor(if roosevelt is true then color.blue else Color.CURRENT);
AddLabel(yes, if roosevelt is true then “true” else “”, color.yellow);

Now the picture:

I was expecting to see that perhaps the bears were adding selling pressure on the occurrences, and that the sellers would have eventually driven the market lower after each one of these 6-of-7 occurrences (marked with yellow arrows on the chart). Wrong. Each occasion saw the bulls roaring back from swing lows; the one exception being that time just before the big drop during the summer of 2015. I only ran the study with a look-back of three years, so if you want to run it for longer just copy and paste the code and see what you get.

Cheers, and stay safe out there.

John Ehlers’ Reverse EMA

I just listened to this podcast in which the “Better System Trader,” Andrew Swanscott of Australia, interviewed John Ehlers and was handed the code for Andrew’s listeners to have a brand new indicator that Mr. Ehlers calls his “Reverse EMA.” I translated the text file into my trading platform at thinkorswim. Before I share my translation of the text file, however, I would like to add a caveat for anyone who might try to use this as a “predictor” of future price action.

In the interview the author of this Reverse EMA makes a point of saying that moving averages generally have no predictive ability, until now with his new creation of the “Reverse EMA.” The fact is, neither does this indicator. Any moving average, oscillator, or any other indicator that is derived from past prices has NO predictive power whatsoever for future prices. More succinctly, anything derived from price cannot predict future price. For that to happen you need something unrelated, like every time the wind picks up there will be eagles looking for ducklings. Or, as a more relatable example, the advance-decline line has been strong and trending higher therefore I suspect that prices will stay firm to higher from here.

declare lower;

input lincoln = 0.1;
input length = 8;

def polk = 1 – lincoln;
def EMA = ExpAverage(close, length);
def EMA1 = lincoln * Close + polk * EMA[1];
def washington = polk * EMA + EMA[1];
def adams = Power(polk, 2) * washington + washington[1];
def jefferson = Power(polk, 4) * adams + adams[1];
def madison = Power(polk, 8) * jefferson + jefferson[1];
def monroe = Power(polk, 16) * madison + madison[1];
def quincy = Power(polk, 32) * monroe + monroe[1];
def jackson = Power(polk, 64) * quincy + quincy[1];
def vanburen = Power(polk, 128) * jackson + jackson[1];
plot signal = EMA1 – lincoln * vanburen;
plot h = 0;

Obviously I have changed the verbiage of the code for no particular reason than to be ornery, since Mr. Swanscott is an Aussie. The host of the podcast and I had a few exchanges in twitter, during which I apologized for posting the code and the translation without asking him first. He has since granted me permission to post the thinkorswim translation but not the original text file, which was only for subscribers of Mr. Swanscott to receive and hopefully drive more subscribers to his podcast by way of sharing the original text version that Mr. Ehlers provided.

Here’s what the final product looks like. If any thinkorswimmers out there want to comment on my translation, feel free to comment.

Ehlers Reverse EMA

Cheers, and stay safe out there.

That is all. Enjoy your day, and thanks for reading.


I’m a 55-yr old digital immigrant, which basically means that I did not grow up with a computer in my house like a digital native, a millennial. How I came to be so comfortable with technology was simply diving into it, secure in the knowledge that I was unlikely to blow something up or launch a rocket from a silo simply by playing around with a little internet or platform coding. It hasn’t necessarily been easy though. I like to consider myself a smart cookie, possessing pretty good intuitive skills, but self-teaching comes with certain hurdles that require more than a high IQ and/or grit; it also requires a relentless passion to figure out the puzzle. I have that in spades, and perhaps more than a healthy share of O.C.D.

I have a title for all of my charts that I keep at stockcharts.com that reads: “Proprietary? What a joke.” Several years ago, when I first started trading I came across more than a few charts that traders would share that had lines and moving averages drawn on them. It wasn’t always obvious how these lines were derived and inevitably the host would say something like, “it’s my proprietary moving average.” On many occasion I set out to figure how those lines were drawn, i.e. – the basis for them. Since almost all indicators that you can put on a chart are in some form derived from the price itself, it was usually just a matter of time before I figured out the puzzle. I no longer read posts from these people, or perhaps it is more accurate to say that once I see the word “proprietary” I immediately lose interest as the person is probably trying to sell their readers something. Proprietary? Get over yourself!

In the spirit of wanting to share with other traders what I have learned, I have started a new category in this blog that currently has more than 1 reader but probably less than 5. Without further ado, this is the first post.

Sometime back in 2008 (guessing) I saw a post from the blog, Vix and More, in which the author mentioned that when a certain ratio of the three-month volatility index ($VXV) relative to the current volatility index ($VIX) was less than 1.0, it was a good time to start initiating positions in the S&P500 stock market index ($SPX). I’ve been tracking this ratio ever since and I have used it with success using exchange-traded funds that track the $SPX.

I keep a spreadsheet with market data that goes all the way back to April 1987, but this only shows me the results for the S&P500. What if I want to trade futures contracts on the $VIX and see how that would have worked out with those signals? The good news? I have figured out the solution. The bad news? From the perspective of wanting to help other traders flatten their personal learning curves, I can only share the code that I use in my trading platform with TD Ameritrade, which is called thinkorswim. I have only used the thinkorswim platform since 2008 so that is my preferred playground for learning, so to speak. However, if you use another platform and my shared studies help in any way, then copy and paste as you see fit.

The text in the blockquote below is to get you started.

# this strategy sells one contract of /VX when VXVbyVIX ratio is less than 1.0, and holds for 15 trading days.
# BEWARE! – this strategy may come with a very large drawdown as it uses a futures contract.

def VXVbyVIX = close(“VXV”) / close(“VIX”);
plot bullish = VXVbyVIX < 1;
input units = 1;
input days = 15;
def go = bullish is true;
def cover = bullish[days];
AddOrder(OrderType.SELL_TO_OPEN, go, close, units, tickcolor = GetColor(2), arrowcolor = GetColor(2), “Short @ ” + close);
AddOrder(OrderType.BUY_TO_CLOSE, cover, close, units, tickcolor = GetColor(1), arrowcolor = GetColor(1), “Cover @ ” + close);

You can add more criteria behind the condition, which is on line 3 and reads:
plot bullish = VXVbyVIX < 1;

For instance, let’s say you only want to see this condition when the $SPX is above its 200-day moving average, then line 3 would read as follows:
plot bullish = VXVbyVIX < 1 and close(“SPX”) > Average(close(“SPX”), 200);

Here are two screenshots of the signals and the report for this strategy in which I only looked at how it performed for the last three years. I kept the prints small on purpose as I merely wanted to show what the results look like instead of perhaps readers getting fixated on the dollar figure in the report.

That’s all for now. Enjoy the show and I will be sharing more as I go.