Ehlers Instantaneous Trendline

I am a big fan of John Ehlers’ work in technical analysis.  For those not familiar with him, he brought digital signal processing concepts into TA with a wide variety of new indicators.  DSP uses advanced mathematical techniques to find and reduce noise in a signal without damaging the signal itself.  For instance, it is used when cleaning up an image file or to remove static or distortion in audio.  Similarly, it can be used to isolate the signal or “real price action” from the noise. Disclaimer: the amazon link is an affiliate link and helps to support the site.

One such indicator is the “Instantaneous Trendline”.  This replacement for a fast moving average removes most of the lag associated with such indicators.  Normally when you look at a 10 bar moving average, for instance, you will see it’s value is more representative of the price 5 bars ago.  In an uptrend, this shows up as the price floating well above the moving average, and in a downtrend price stays well below it.  This is why moving averages are called “lagging” indicators.

EhlersInstantaneousTrendline
John Ehlers’ “Instantaneous Trendline” does a great job of tracking inside the current price action.

As you can see in this chart, the Instantaneous Trendline does a good job of staying inside most of the price action, with prices appearing equally above or below.  It’s a much better measure of the current price, without the noise, but without being stale.

The Instantaneous Trendline works similar to an Exponential Moving Average in that it weights recent  prices higher and derives from it’s past values.  Rather than selecting a period as you do with an EMA, you select an “alpha” or decay factor.  In this example, I have used an alpha of 0.2.

IT is not available in ThinkOrSwim, so I have written up a custom indicator for use on that platform.

input price = close;
input alpha = 0.5;

assert(alpha > 0, "'alpha' must be positive: " + alpha);

def IT = (alpha-((alpha/2)*(alpha/2))) * price + ((alpha*alpha)/2)*price[1] - (alpha-(3*(alpha*alpha))/4)*price[2] + 2*(1-alpha)*IT[1] - ((1-alpha)*(1-alpha))*IT[2];

plot EhlersInstantaneousTrendline= IT;
EhlersInstantaneousTrendline.SetDefaultColor(GetColor(1));

Market Order vs Limit Order

A question a lot of beginning traders have is, should they use market orders or limit orders in their trading.  I thought I would weigh in with my opinion (which is “both”).  Let’s start by looking at what are the strengths and weaknesses of each order type.

Market Order

The good news is a market order guarantees you an execution.  You will get filled more or less instantly.

The bad point of market orders is you effectively pay the spread.  That is, if the bid and ask prices are 2 cents apart, you will incur that 2 cents as a cost getting in and out of your position.  Stocks that trade with lots of volume tend to have narrow spreads and make market orders “cheap”.  Thin and low-float stocks tend to have wider spreads and make market orders “expensive”.

Limit Order

The good news for limit orders is you are guaranteed a specific price (or better).  For some commission plans, you also get a tiny rebate passed on to you from the exchange.

The problem with limit orders is you may not get filled, may get filled slowly, or may only get partially filled.  This is especially true of odd-lot orders (not a multiple of 100 shares) because an odd lot limit order can be passed over in favor of a round lot order even if you were at a better price.

So, let’s look at some situations and how they apply to these two order types.

Breakouts

Trading breakouts means you are entering as the price makes a new high or new low.  These moves can be explosive and easily leave behind a limit order completely unfilled.  Limit orders may save you a few pennies compared to a market order, but they cause a number of problems

  • You won’t get filled on many winning trades, causing you to miss those gains
  • You will get filled on every failed breakout, taking all of the losses
  • If you chase the limit order up with price, you will likely get a much worse fill than using market orders and not delaying entry

For breakout trades, you are much better off just using a market order and making sure you participate in every trade.

QLYS-runaway-breakdown

There are two alternatives if you want to use limit orders that can still work.  The first is to start accumulating shares with limit orders before the breakout.  As you see price consolidating at a level, you anticipate the move.  The drawback is many times the move never materializes and you take a small loss.

The second alternatives is to enter breakouts on a subsequent pullback near the breakout level.  This is called a  “breakout-pullback”.  Effectively, it is just a pullback trade and these lend themselves to limit orders placed slightly shy of the breakout level.

Pullbacks

With a pullback you are fading a short-term move lower (for longs) and these lend themselves well to limit orders.  You can just put an order in at your desired price and if the pullback is deep enough you get filled.

WTW-pullback-limit

This assumes you are entering the pullback before it reverses.  If your pullback strategy waits for confirmation, limit orders become more difficult.  for example, if your rules are to wait for a break above/below the previous candle, resuming the trend, that is really a mini breakout entry inside of your pullback and you risk missing some winners with a limit order.  It is still viable as the move will not be as explosive as a pure breakout, but you will need to track your live trading results to see.  I recommend adding rows for the trades you missed and adding a column for the spread saved so you can ask “what if I used market orders” after 50 or so trades.

Stops (loss control)

Many trades have a built in stop level.  If price moves beyond that level, you exit the trade.  In general, you are trying to avoid the possibility of a catastrophic loss and you should just use market orders here.

A more complex stop system allowing for limit orders would be to have two stop levels.  The outer stop would be the catastrophic stop.  This is what you use to set your max risk on the trade and you would exit with a market order.  The inner stop would be a tighter level that still causes you to exit, but as long as the outer stop is not touched you can manage the trade with a limit order.

Trailing Stops (trend followers)

Some traders use a trailing stop to manage their positions, particularly for trend trades.  If price triggers the stop, it implies the trend is over and it is time to exit the trade.

In this case, you are not facing your max loss on the trade and hopefully are even exiting for a profit.  This is effectively the “complex stop” scenario and you can manage the exit with a limit order.  If price drops below your original stop for the trade, though, then you should get out immediately with a market order.

Profit Targets

If you are using a profit target to exit your trade, a limit order makes perfect sense.  As such, choosing this style of exit will reduce slippage costs in your trading.

Exit On Close

If you are exiting on the close, you want to be sure you get executed and a market order is virtually required.  The spread is a small price to pay to avoid carrying overnight risk if the order does not get filled.

“Market” Limit Order

An alternative to market orders that I often use are what I call “market limit orders”.  This is just a limit order, but instead of trying to keep the spread you put it beyond the current price by a few pennies.

As an example, say you are watching VIX for a breakout above 20.  When the breakout occurs, the bid/ask will probably be something like 20.00/20.01.  I might have a limit order ready to go at a price of 20.03.  It’s very likely that I will get filled and will get the same price a market order would have had.  However, I can be sure if some wild price spike hits that I will not pay more than 20.03.  I am not using it to try to save pennies, just to protect myself from any extreme price gaps.

I recommend using this anywhere you would use a market order.  How much to pad depends on your expectancy per trade, the price and how it moves.  Use your intuition.  If you frequently miss trades because price moves too fast, then you might need to use more padding.

 

Book Review: The Honest Guide To Stock Trading

This book is a real undiscovered gem and I can’t believe it’s just a few bucks.  If you are looking for a long-term stock strategy, this one is very good.  My only caveat would be it employs a market filter that, for now, would keep you out of the market.  But that is just good practice.

A Complete Plan

This book is surprisingly in-depth.  It provides a complete start-to-finish trading plan.  It shows how to screen for fundamentals – that is, stocks with a strong financial footing.  It then goes on to technical screens, where to put stop loss orders, just absolutely everything.  You could give this book to someone with no market experience and it has all the information they need in a well-organized and clearly written form.

Fundamental Rules

With long-term stock trades, fundamentals do matter. This book goes into great detail about earnings, growth, debt ratios and more. It also shows sample screening criteria for fundamentals and walks you, step by step, through a screening session. It uses all free online tools and provides settings and screenshots to explain everything.

Backtested Technical Rules

The author also provides a technical framework that he has tested himself and he shares those results in the book.  Nothing requires you to have blind faith.  Other books may toss out a few well-chosen examples.  Here, you get fully quantified long-term results and equity curves.  Where charts are shown, it is simply to clarify the technical rules he uses.

Also, the backtests involve no discretion.  That is, the performance results he shows do not include any of the fundamental screening.  This makes it possible to replicate his tests using products like AMIBroker or WealthLab.  This also means his results are pessimistic.  Layering in the fundamental screens should allow you to do much better than the technical rules alone.

Controlling Losses

This topic comes up over and over in the book and that’s a good thing.  Rather than focus on returns, this book seeks to control losses.  That is the most important part of trading but it is rarely addressed in trading books and never in such detail.  Before he even begins to talk about returns, he spends about 20% of the book talking about risk, how to control it, and why you should respect it.

He does discuss stop losses in-depth.  This is basically in-line with other trading books, using the stop to guide how many shares you buy.  While nothing new, it is part of the overall plan and is well described.  He also details various approaches to trailing stops.  He shows a trend-following strategy and a trailing stop exit is a sensible and common way to exit those trades.  While citing his own preference, he also shows a number of other approaches such as moving averages and encourages the reader to do their own testing and personalize their approach.

The book also recommends trading multiple strategies.  This is a common approach as a combination of strategies will, together, tend to have lower drawdowns than just trading a single strategy.  He even shows you how adding a losing strategy to your portfolio can actually reduce your risk and lead to better overall results.  This is a topic you almost never see.  You still don’t need to buy another book, though, as he gives you three different (winning) strategies to trade.

Trading a portfolio of stocks can still expose you to market risk.  Generally, most stocks move along with the market overall.  To diversify risk outside the market, he shows how adding a basket of ETFs can help.  Indeed, he both lowers drawdowns (risk) and improves returns at the same time.

Also rare for a trading book, he puts quite a bit of time into discussing correlations and how that can be a warning sign to go to cash.  He includes some detailed examples of this and offers a spreadsheet to do the calculations on your own periodically.  Again, the idea being to reduce your risk.

This focus on controlling losses, repeated throughout the book, is the hallmark of an experienced trader.

Conclusion

I’ve read hundreds of trading books.  Most of them are junk.  This is especially true of the self-published $5 or less category.  In fact, I’ve never found a self-published trading book that was good and wasn’t an endless plug for their website/service.  This book is a dramatic exception.  Perhaps the best indication of all, I plan to put many of his ideas to work with real money.

You can find the author’s website here:

http://backtestwizard.com/

 

Trading on Linux

Most trading applications are written specifically for Windows.  As one of the few people that prefers to run Linux, I thought I would share the tools you can use to trade on Linux without making sacrifices.  These are actually the same tools I use when I am on Windows.

Both of these programs can be run as a trial before opening an account.  You will only have access to delayed data, so it will not be useful for daytrading until you have funded the account.

linuxtradingapps

Charting/Long-Term: TD Ameritrade

As a long-time fan of the Thinkorswim platform, I continue to use it now that it is owned by Ameritrade.  I have my IRA account with them and this gives me free access to this incredible feature-rich platform.  After hours, I do complex scans of the market to find stocks setting up the way I like.  I also page through hundreds of charts with custom indicators (some I wrote myself in “ThinkScript”).  The best part is, it’s Java, so it runs just fine on Linux with the Oracle Java package.

When you install, you are given the option to install for everyone or just for the current user.  Choose the “current user” install.  The “everyone” install has a bug that prevents the application from launching.

I recommend having, at a minimum, a proper i3/i5/i7 CPU and at least 4 gigs of RAM to run their platform.   Increase that to at least 8 gigs of RAM if you are also running the Interactive Brokers application mentioned below.

You can download Thinkorswim here

https://www.thinkorswim.com/t/trading.html

Short-Term Trading: Interactive Brokers

For short-term swing and day trading, low commissions are critical.  Interactive Brokers is a great broker in this space offering low per-share commissions with a $1 minimum.  If you are starting out as a trader, you want to trade small and that requires small commissions like this.  Fortunately, their trading platform is also written in Java and, again, runs fine on Linux with the Oracle Java package.

These programs also work natively on OSX if you have a Mac.

I recommend having, at a minimum, a proper i3/i5/i7 CPU and at least 4 gigs of RAM to run the TWS platform.   Increase that to at least 8 gigs of RAM if you are also running the TD Ameritrade application mentioned above.

You can find TWS here

https://www.interactivebrokers.com/en/index.php?f=14099

How much money do you need to start trading?

I often see this question in trader forums and in various trader blogs online.

The problem is this is not really their question.  What they are really asking is How much money do you need to live off your trading exclusively.  This is also never the right question to ask.

Usually, the answer given is either an incredibly vague one or some huge amount of money like $600,000.  Both of these answers are responding to the question literally, but they are no help to the student trader.

Those who ask this question are invariably new or inexperienced traders.  They are looking at trading as a lifestyle upgrade.  They are trying to see if they can quit their job, which they probably hate, tomorrow or if they have to wait a month.

The problem is, even the small minority who succeed as traders and become profitable only get there after years of working at it.  So the answer to the real question, when can you quit your job, is not for a long time and not until you’ve proven yourself as a trader.

The good news is you can stop worrying about how you can scrape together $500k or how you can make 1000% per year daytrading.  Neither of these were realistic anyway, but it turns out the real path is something you can start right now.

Since almost everyone is not profitable in the beginning, you should start out paper trading.  There are a number of platforms out there, but if you do have a little savings I recommend Ameritrade for US residents.  You need to fund an account to get access to live data.  Don’t trade this money, though.  If you can’t leave it in cash, invest in a low risk index fund and just leave it there.  You can also just use a spreadsheet and do it yourself with a little more work.

After you’ve found a strategy that fits you and you’ve had success trading it, only then should you trade with real money.  This will be, minimum, many months down the road.  If you are aggressively saving up then you will have a small account ready and waiting.

The common rule of thumb is to risk, max, 2% of your account.  So if you only have $1000 in your account, you should risk $20/trade.  This is the distance from your purchase price and the stop loss.    Suffice to say you are taking very small trades.  What if you have $10,000 or $100,000?  You should still risk $20.  The 2% rule is for successful traders.  And you know what?  Those traders don’t actually risk 2% most of the time.  They usually risk 1% or 0.5%.  Start at $20 or so.  In your case, you should assume you will lose money for a long time while you are learning.  The amount of risk you take will determine how much you lose.  Less is better.

After trading for a while and keeping a record of your trades, you can see how you are doing.  When you see that you are making money over at least 50 or so trades, you can increase your risk to $50 (but no more than 2%).  By now, it has been a few more months and you are still saving aggressively from your regular job so you should have more money in your account as well.  As you continue to gain experience and comfort with your style, you can continue to slowly increase your size to more meaningful levels.

So how much money do you need?  $0.  Start now.  Save half your take home pay and trade as small as you can.  In two years, you will have saved up a year’s worth of pay.  By then, if you are successful, you can continue trading but at full size and continue saving from your regular job.  When you are ready to quit and go full time, you’ll know.

Tap Count Indicator

This one is my own indicator. I use it for quick and dirty scans for stocks tapping a high multiple times. You can set the period over which taps on the high occur and you can set the margin of flexibility in your prices.  For instance, in the screenshot it is tapping on the 50 day high and counts all taps within 0.02c of that high in the same 50 days.

You can also incorporate this into your scans by doing a scan by indicator value.

declare lower;

input period = 100;
input price_range = 0.05;

def minhigh = Highest(high,period) – price_range;

def taps = fold index=0 to period-1 with p do p + if high[index] >= minhigh then 1 else 0;

plot “NumTaps” = taps;

“NumTaps”.DefineColor(“Normal”, GetColor(7));

Do Stop Losses Hurt Trading Results?


Two of my favorite authors, Larry Connors and James Altucher, have both made this claim. They suggest not using stops to get the best performance from your trading. In Connors’ Short Term Trading Strategies That Work”, he lists this as “Rule 5 – Stops Hurt”. He shows a simple reversion to the mean strategy with results comparing no stops against % stops from 1 to 50. Even the 50% stop shows decreased returns. In his later book, “High Probability ETF Trading”, he just says “One of the reasons the test results are so strong for each strategy is the fact that stops are not used.”. Note, book link is an Amazon link and helps support this website

The problem with these assertions is they take some otherwise fascinating ideas both authors present and move them from “useful, actionable ideas” to being “interesting, but ultimately useless ideas”. The two biggest problems come from shorting and the scale of the typical retail trader.

Shorting Without Stops

The problem with shorting is obvious: you always have a stop when you are short. If you do not, your stop is determined by your broker when they margin call your position and liquidate it. Admittedly, this can be unlikely if you are taking very small positions relative to your account size. In any case, at least for shorts, you have to at least have very wide stop losses.

Options As Alternatives

Connors’ books suggest the use of options as an alternative to stop losses because stops are “expensive insurance”. This seems pretty odd because options are a far more expensive form of insurance. If you buy near-date at the money options, as he suggests, you are looking at significant time decay eroding the value of your position. If you buy at the money, as he also suggests, the delta will be 0.5 – meaning, you will only experience 50% of the returns you would have with the underlying stock. Additionally, even the most liquid options will have a spread wider than the underlying equity. Hardly a great alternative to a stop loss.

Position Sizing As Protection

The second “solution” is to use position sizing. In other words, by taking a very small total position as a percentage of your account, your risk is minimized. Of course this will work fine for longs. Unfortunately, it will also minimize your returns. Connors’ strategies in these books typically return around 2%. These are short-term strategies so that is not bad. We will also use the fairly standard 2% of our account size as our “max risk”. Assume further a $100,000 account. So, we are only allowed to take $2,000 size on our trade since it has no stop loss. That, in turn, makes 2% or $40. Half of this goes to commission and then there will be slippage and real-world effects on top. If you have a very large account, this might be a viable solution, but not for the majority of readers.

Defining Decreased Returns

Given the above, without a million dollar account, I decided to look at just what these “decreased returns” actually amount to. I looked both at longer-term trend following and at short-term reversion approaches. The trend following results use a basic 50/200 moving average crossover. The reversion trade uses bollinger bands set to 20 period average and 2 standard deviations. Both were tested over 10 years long-only on a large basket of stocks with thousands of trades generated for each test.

Trend Following Results

Stop Loss Absolute Return % Return on Risk % Winning Trade % Ave. Hold Time (days)
None 3.04% 3.04% 37.33% 251
32% Stop 2.87% 8.97% 37.08% 248
16% Stop 2.45% 15.31% 33.8% 220
8% Stop 1.49% 18.63% 24.00% 156
4% Stop 0.75% 18.83% 13.94% 93
2% Stop 0.19% 9.56% 7.17% 50

Reversion To The Mean Results

Stop Loss Absolute Return % Return on Risk % Winning Trade % Ave. Hold Time (days)
None 1.59% 1.59% 70.76% 19
10% Stop 1.21% 12.06% 65.60% 14
5% Stop 0.88% 17.51% 50.55% 10

 

Conclusions

Trend following has been having a rough time lately and both of these strategies are very well known, crowded trades.  Individual stocks are also not the best vehicle for trend trading.  However, both strategies are profitable and illustrate how stops hurt and, more importantly, how they don’t.  Right away, we can see that when Connors and Altucher say that stops hurt, they are looking at the absolute return and the winning percentage.  Stop losses have a big negative impact on these values and these are the first things most people look at when evaluating trading results.

However, there is an equally dramatic improvement in the return on risk and the hold time.  Let’s consider the bollinger band trade with a 10% stop vs with none.  If you are limiting your risk to $2000 you will make about $32 before commissions with no stop.  With the 10% stop loss, you can put on a $20,000 position (since 10% of $20,000 is $2000).  Your return is only 1.21% (vs 1.59%) but since you have a $20,000 position you make $240.  Winning 65% of your trades is not so much worse than 70%.  Your average hold time has also dropped by 5 days giving you that return in a shorter time period.  Also note commissions will be a much smaller portion of that $240 than the stopless $32 return.

In general, both for reversion and trend following, as you add and tighten a stop loss your % return on the overall trade and your win rate will suffer.  For reasonable stop levels, though, your return on capital at risk and trade duration will both improve (assuming shorter is better).  Caution is warranted as the stop gets close to the normal market volatility, as seen with the 2% trend following stop deteriorating across the board.  Even the 4% stop does not seem preferable in my judgement to the 8% stop.

When evaluating stops in your own strategies, it is worth considering these tradeoffs and not simply focus on one variable.  For myself, I am just as concerned with having a good % win rate as a good return on risk.  Unilateral statements about stops being good or bad are too simplistic and the real answer depends on your tolerances for risk, % win rate, account size and many factors.

 

Cumulative RSI

Another one of Larry Connors’ custom indicators is the Cumulative RSI.  He and Alvarez use this in their book Short Term Trading Strategies That Work.  I recommend the book for this and many other ideas, but you can adopt this indicator anywhere you would use the regular RSI.

Disclaimer: the book link is an Amazon affiliate link and helps to support this site.

Anyway, I like the idea and coded it up for ThinkOrSwim.

This is how it appears in use.  As you can see, much like the RSI, but it focuses in on extended short-term down-moves.

And here is the ThinkOrSwim study code you can use to get it.

declare lower;

input over_Sold = 10;
input over_Bought = 190;
input rsi_length = 2;
input num_rsis = 2;

def rsi = reference RSI(price = close, length = rsi_length);

plot “Cumulative RSI” = fold index = 0 to num_rsis with p do p + rsi[index];
plot OverBought = over_Bought;
plot OverSold = over_Sold;

“Cumulative RSI”.DefineColor(“OverBought”, GetColor(5));
“Cumulative RSI”.DefineColor(“Normal”, GetColor(7));
“Cumulative RSI”.DefineColor(“OverSold”, GetColor(1));
“Cumulative RSI”.AssignValueColor(if “Cumulative RSI” > over_Bought then “Cumulative RSI”.Color(“OverBought”) else if “Cumulative RSI” < over_Sold then “Cumulative RSI”.Color(“OverSold”) else “Cumulative RSI”.Color(“Normal”));
OverBought.SetDefaultColor(GetColor(8));
OverSold.SetDefaultColor(GetColor(8));

As always, you have to create a custom study and paste this code in yourself inside ThinkOrSwim.  I wish there were a better way.

Average Percent Range

Often when I am evaluating stocks, I look at the ATR or Average True Range.  This gives some indication of how much a stock’s price can move in a day.  However, I am at least as concerned with what a typical percentage move would be.  ThinkOrSwim doesn’t offer anything like this so I coded one up real quick.  It simply re-expresses the ATR as a percentage of the close price.

Here is how it looks (bottom panel)

OLED-apr

To get this indicator in your ToS chart, just create a new custom study and paste in the following code:

declare lower;

input length = 20;

def atr = ATRWilder(atr_length = length);

plot “Average Percent Range” = 100 * atr / close;

“Average Percent Range”.SetDefaultColor(GetColor(7));

You can use APR in your scans in ToS too.  I ran a scan for all stocks that were

  • over $1
  • Average Volume over 20 days >= 500k shares
  • ATR > 0.5
  • APR > 4

ToS spat out 80 names and most of them looked very familiar.

APRScan

Connors RSI for ThinkOrSwim

Recently, Larry Connors published a new oscillator he calls “Connors RSI”. It is interesting because it is a composite of various price behaviours merged into a single overbought/oversold indicator. It is not available on most platforms yet, but I have written up a version for ThinkOrSwim.

It looks like this

 

ConnorsRSI

You can learn more about ConnorsRSI at the TradingMarkets website here

To add to ThinkOrSwim, create a new study and paste the following ThinkScript code in.

declare lower;

input over_Sold = 10;
input over_Bought = 90;
input rsi_length=3;
input streak_rsi_length=2;
input percent_rank_length=100;

def rsi = RSIWilder(price = close, length = rsi_length);
rec streak = if streak[1] <= 0 and close < close[1] then         streak[1]-1      else if streak[1] >= 0 and close > close[1] then 
        streak[1] + 1 
    else 
        0;
rec ret = (close - close[1])/close[1];

def streakrsi = RSIWilder(price = streak, length=streak_rsi_length);
def percentrank = max(0,
  min(100,
    (100/percent_rank_length) 
    * fold index = 1 to percent_rank_length 
      with p do p + if ret > ret[index] then 1 else 0));

plot "Connors RSI" = (rsi + streakrsi + percentrank)/3;
plot OverBought = over_Bought;
plot OverSold = over_Sold;

"Connors RSI".DefineColor("OverBought", GetColor(5));
"Connors RSI".DefineColor("Normal", GetColor(7));
"Connors RSI".DefineColor("OverSold", GetColor(1));
"Connors RSI".AssignValueColor(if "Connors RSI" > over_Bought then "Connors RSI".Color("OverBought") else if "Connors RSI" < over_Sold then "Connors RSI".Color("OverSold") else "Connors RSI".Color("Normal"));
OverBought.SetDefaultColor(GetColor(8));
OverSold.SetDefaultColor(GetColor(8));