Whats up my fellow Trend Followers!
As someone who trades trends I have to ask myself 3 questions everytime I look at a potential trade.
1) Is There a Trend?
2) How long has it been a Trend?
3) Do I think the Trend will continue?
The downside to being a trend trader is you never show up first, you just hope you dont show up last. That's what this indicator is for. It is super simple, and would be a useful indicator, label, watchlist column and screen.
I am just going to give you the logic, a pretty picture, and some code and if you want to spin it up into something else that awesome sauce =)
Here is the logic:
A trend as far as charts goes is most obvious when a stock is above the 200sma and the 50sma. But not every stock above the 200SMA and 50SMA is a good trend.
Note the following chart:
This is one of the most commonly tracked ETF's. You will notice from the chart its in a long term uptrend, but you also might notice its been chopping for a bit as noted by the multiple crosses of the 50SMA. Notice how wide the gap is between the 50SMA and the 200SMA. That large gap is a strong indication that the trend is Mature, or what I call a Stage 3 trend.
Now consider the following chart:
This chart has everything a trend is supposed to have right? I mean the price is above the 50SMA and the 200SMA, so its a trend yes? No, its obviously not. That is because the stock has obviously been crossing the 50sma and 200sma for quite a bit of time. We dont want that, this is a chop chart. Verdict, no Trend.
Lastly consider the following chart:
This chart is beautiful. The 50SMA crossed the 200SMA and stayed above while the stock mostly respected the 50SMA as a support trend line. Also notice the gap between the 50SMA and the 200SMA. Not to crazy like what we saw on the QQQ. This is what I would call a Stage 2 Trend.
So what is a trend and can we define it mathematically through the use of indicators? I have come up with a method I think is mostly sufficient. A trend exists when the 50SMA-200SMA is greater than or equal to 3*ATR. I model this with (50SMA-200SMA)/(3*ATR) >=1. Why 3*ATR? Because 3*ATR is enough time for a stock to breathe and go through a couple of volatility cycles.
In my world view, a trend has 3 stages:
1) Stage 1 is when the stock initially satisfies the definition of the trend. That would have been about July 7th on the XLI chart above. In this stage the dips become tradeable as long as our supports hold and it respects the moving averages. If it breaks our 50SMA multiple times however its chopping and untradeable. However a break of the 200SMA is required to throw out the company.
2) Stage 2 is when (50SMA-200SMA)/(3*ATR) >=2 (the first time it happens when the trend occurs). This is when a trend is confirmed and the most durable.
3) Stage 3 is when (50SMA-200SMA)/(3*ATR) >=3 (the first time it happens when the trend occurs). This trend is mature, but its also the one you want to be more willing to cut the trade short. Lower size, or tighten stops.
I hope you will find some utility out of this. I dont use a bunch of indicators anymore. I am not smart enough to be a contrarian investor, I show up after the party has already started. My hope is to just get there as close to the beginning without being too early and also to get some idea when the party might end.
Enjoy!
The Code:
As someone who trades trends I have to ask myself 3 questions everytime I look at a potential trade.
1) Is There a Trend?
2) How long has it been a Trend?
3) Do I think the Trend will continue?
The downside to being a trend trader is you never show up first, you just hope you dont show up last. That's what this indicator is for. It is super simple, and would be a useful indicator, label, watchlist column and screen.
I am just going to give you the logic, a pretty picture, and some code and if you want to spin it up into something else that awesome sauce =)
Here is the logic:
A trend as far as charts goes is most obvious when a stock is above the 200sma and the 50sma. But not every stock above the 200SMA and 50SMA is a good trend.
Note the following chart:
This is one of the most commonly tracked ETF's. You will notice from the chart its in a long term uptrend, but you also might notice its been chopping for a bit as noted by the multiple crosses of the 50SMA. Notice how wide the gap is between the 50SMA and the 200SMA. That large gap is a strong indication that the trend is Mature, or what I call a Stage 3 trend.
Now consider the following chart:
This chart has everything a trend is supposed to have right? I mean the price is above the 50SMA and the 200SMA, so its a trend yes? No, its obviously not. That is because the stock has obviously been crossing the 50sma and 200sma for quite a bit of time. We dont want that, this is a chop chart. Verdict, no Trend.
Lastly consider the following chart:
This chart is beautiful. The 50SMA crossed the 200SMA and stayed above while the stock mostly respected the 50SMA as a support trend line. Also notice the gap between the 50SMA and the 200SMA. Not to crazy like what we saw on the QQQ. This is what I would call a Stage 2 Trend.
So what is a trend and can we define it mathematically through the use of indicators? I have come up with a method I think is mostly sufficient. A trend exists when the 50SMA-200SMA is greater than or equal to 3*ATR. I model this with (50SMA-200SMA)/(3*ATR) >=1. Why 3*ATR? Because 3*ATR is enough time for a stock to breathe and go through a couple of volatility cycles.
In my world view, a trend has 3 stages:
1) Stage 1 is when the stock initially satisfies the definition of the trend. That would have been about July 7th on the XLI chart above. In this stage the dips become tradeable as long as our supports hold and it respects the moving averages. If it breaks our 50SMA multiple times however its chopping and untradeable. However a break of the 200SMA is required to throw out the company.
2) Stage 2 is when (50SMA-200SMA)/(3*ATR) >=2 (the first time it happens when the trend occurs). This is when a trend is confirmed and the most durable.
3) Stage 3 is when (50SMA-200SMA)/(3*ATR) >=3 (the first time it happens when the trend occurs). This trend is mature, but its also the one you want to be more willing to cut the trade short. Lower size, or tighten stops.
I hope you will find some utility out of this. I dont use a bunch of indicators anymore. I am not smart enough to be a contrarian investor, I show up after the party has already started. My hope is to just get there as close to the beginning without being too early and also to get some idea when the party might end.
Enjoy!
The Code:
Code:
# ============================================
# Normalized Moving Average Spread
# (MA1 - MA2) / (ATR * Multiplier)
# LOWER STUDY
# ============================================
declare lower;
input fastMALength = 50;
input slowMALength = 200;
input maType = AverageType.SIMPLE;
input atrLength = 14;
input atrMultiplier = 3.0;
# === Moving Averages ===
def fastMA = MovingAverage(maType, close, fastMALength);
def slowMA = MovingAverage(maType, close, slowMALength);
# === ATR ===
def atr = Average(TrueRange(high, close, low), atrLength);
# === Spread ===
def maSpread = fastMA - slowMA;
# === Normalized Spread ===
def normalizedSpread = maSpread / (atr * atrMultiplier);
# === Plot ===
plot NormSpread = normalizedSpread;
NormSpread.SetLineWeight(2);
# === Zero Line ===
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);
# === Threshold Bands ===
plot UpperBand = 1;
plot LowerBand = -1;
UpperBand.SetStyle(Curve.SHORT_DASH);
LowerBand.SetStyle(Curve.SHORT_DASH);
UpperBand.SetDefaultColor(Color.DARK_GRAY);
LowerBand.SetDefaultColor(Color.DARK_GRAY);
# === Color Logic ===
NormSpread.AssignValueColor(
if NormSpread > 1 then Color.GREEN
else if NormSpread < -1 then Color.RED
else Color.YELLOW
);