Sunday, January 27, 2013

Meta-Trader - Range Bands - Part 2

Welcome back, Meta-Traders.

As promised, here is part 2 in my series on the Range Bands indicator.  If you missed part #1, check it out here.

In this post, we create a Meta-Trader Expert System to trade the range bands indicator and test it out on our favorite Forex pair EUR/USD.  We also make some interesting observations about seasonality, so read on for that.

The trading logic is extremely simple as follows:
  • If bar closes above the upper range band, buy.  If already in a short position, close the short position before going long.
  • If bar closes below the lower range band, sell.  If already in a long position, close the long position before going short.
  • Risk 0.05 of the account per position using our standard lot sizing algorithm discussed early in the history of this blog
  • Run tests against the hourly charts although the expert is also coded to run at any other time frame
  • Calculate the range bands against a 14-bar look back of whatever time frame Meta-Trader is using at the time.
  • Also, I ran the back tests using the "Open Prices Only" option, so tests were lightning fast and the took only a matter of minutes rather than the hours it takes for the "Each Tick" method.
The first round of back-tests were pretty terrible as expected. In a 12-year back test, the results were negative in 10 out of 12 years.  Even worse, the draw down nearly always exceeded the profits, most of the time by a factor of 2x1.  2006 is a good example, where the system lost -24% for the year, but suffered -44% in draw down.  The only good year was 2010 where results were clearly spectacular returning 134% for the year with only -32% draw down.

These results were consistent with just about every other trend-following EA that I have coded.  Whether its a Moving Average Crossover or a Donchian breakout (breakout of X-bar high) the results were the same.  Bottom line is that Forex is just to whippy a market with too many false breakouts to work well with a trend-following system most of the time.   That's most of the time, what about part of the time?

We know from my prior post Fun with Forex Historical that the second week of January has the largest amount of movement of any other week of the year based on a 20-year study.  And we also know that January has a strong seasonal effect in the stock market.  So what if we limited our trading to just January? Would that change the results?

I went back and ran the expert for each of the 12 years, but used the date range feature of MT4 back-tester to start trading on 1/1 of the year and end of 1/30 of the year.  Lo and behold, the system turned a profit for 7 out of 12 years!  Overall, the system turned a small average yearly profit, but average draw down was still many times larger than average profit.

Not willing to leave it at that, I coded the EA to check for the month and only trade in the month of January by adding this code:

if (Month()!=TradeOneMonth)

Print("Proceeding with month: ", Month());

I made the variable TradeOneMonth to be an external parameter passed into MetaTrader.  This would allow   the following improvements:
  • Allow for a single 12-year back test where only the month of January was traded
  • Allow for optimization across the 11-year period to see if any other month of the year was more profitable than January.
  • I also adjusted the EA to close any open positions as of February 1st to prevent any side-affects from positions open in January staying open all year until the next January.
This time the results were even better with an average annual profit of 3.87% but with Drawdown still pretty high at -14.28%.   But when you consider the fact that this capital is only deployed one month a year and can be deployed elsewhere the other 11 months of the year, the results started to get interesting.

Next, I ran an optimization over the entire 12-year period to see what would happen if I only traded February, or only traded March etc.  This would add some scientific rigor and show that the January effect was indeed real, or not as the case may be.

The results are shown below.

The bottom line is January was the most profitable month to trade by a factor of 3!  Drawdown was also highest in January, but only about 30% above other months which shows only about 30% as much profit.

Bottom line is this.  Trend trading in Forex is not profitable most of the time, but shows a strong seasonal tendency to be profitable in the month of January.

The next step is to code the Range Bands system in TradeStation and run some back tests with Forex to compare the MT4 results with those of TradeStation.  That should be interesting it itself, and get me started coding trading systems in EasyLanguage, the language of TradeStation.

I uploaded the expert system to my Yahoo group at FX-Mon group. Use in good health and have a great week.

Friday, January 25, 2013

Meta-Trader - $250 a second

Welcome back, Meta-Traders.

It was a spectacular week in world markets with the Dow-30 and the S&P 500 just a few percentage points short of all-time highs. Meanwhile the broader market as measured by the Russell 2000 scored new all-time highs in 6 of the last 7 sessions as reflected by ETFs IWM and IWN.  Fortunately, my portfolio participated and has already exceeded the highs of 2007 and broken out to new all-time highs.

It reminds me of a story heard back in the 1990's as told by the SOES (Small Order Execution System) bandits.  Due to the rules at the time, they were able to hit the bids and offers of the market makers who were obligated to quote and automatically execute on 1000 shares at a pop.  At that time, large cap stocks were quoted in fractions with a minimal tick of 1/4 or $250 on 1000 shares.  When a position worked in your favor, you made $250 a second and could easily be up a few thousand dollars by 9:45 AM.  And at that point, you could take the rest of the day off and go fishing!

As for me, I made $250 a second at several points during the week, but all I had to do was click the refresh button on my browser.  There was no crazy risk taking,  mostly just position trading.  I also had a few spectacular trades as follows:

  • Bought the FB 30 calls for 90 cents and sold them at $1 about 10 minutes later.  That's a 10% gain in 10 minutes!
  • Bought the AAPL 485 calls for $29.90 and sold them for $31.50 later that day pushing my TradeStation account to a new high up about 2.5% for the year.
  • Sold my position in IBM stock at $207 on a huge earnings-related spike.

In the interest of fairness, all was not good and I had possibly worst timed-trade in my entire trading career as follows:

  • Took a small position in AAPL stock at the close of Tuesday's trading ahead of earnings.
  • Position size was 10 shares in 1 account and 15 in the other.  Total exposure ahead of earning, plus or minus $25 per point move in the stock.
  • Stock cratered 50 points and I lost $1250 overnight on that trade!   I took my lumps and sold early on the day expecting more carnage ahead.

Despite the fiasco in AAPL, most of my other positions worked out well including nice rallies in CTRX, DNKN, FB, HRL, NEOG, RIMM, and TCX.  Most of these are fast-growing mid-cap stocks, so they benifitted from the rising tide of the broad market.  Finally, to cap off the week, I went out long the Priceline PCLN Feb 1 115 calls and made nearly $500 (unrealized) in the last 10 minutes of the trading day!  Thanks John Carter and looking for an opening gap on Monday to take profits.

I'm almost starting to feel guilty making money so easily while other people struggle all day to make $100 or less.  But I am reminded that life is a zero-sum gain and I have stepped up my spending (particularly for local goods and services) to increase the velocity of money and do my part to grow the economy.

One commentator reminded me that in some years we make 30% a year returns in the stock market.  2013 could very well be the year.  And if that happens, Financial Independence could be much closer that I expected.

That's enough for one week.  Get some rest and check back later for Range Bands part 2.

Sunday, January 20, 2013

Meta-Trader - Range Bands - Part 1

Welcome back, Meta-Traders.

In this post, we lift the curtain on the Range Bands indicator.  I consider this to be the ultimate Trend Following indicator. Many a product and career has been launched with less than this much information. And I'm giving to you here at no cost or obligation - just because I can.

Before I give you the algorithm, let's review the qualities of a good trend-following indicator:

  • Indicator should work in multiple time frames from Intra-day through Daily Weekly and Monthly
  • Indicator should work for multiple tradables including Stocks, Futures, Forex
  • Indicator should give unambiguous signals regarding long or short including price level at which the trend direction changes
  • Indicator should never miss a big move
  • Indicator should be purely price-based
  • Indicator should not get overly whip-sawed between long and short signals
This last one is pretty important because you could make the case that a simple moving average crossover meets all of the above criteria.  But in a flat or direction-less market, moving average crossovers whipsaw your account into poverty, and we certainly don't want that.

Okay, enough rhetoric.  Here is the algorithm:
  • Find the Highest High and the Lowest Low over the look back period.  14 bars is my favorite look-back period
  • Find the Midpoint as the Lowest Low plus half the different between the Highest High and the Lowest Low
  • Find the Average True Range (ATR) over the lookback period
  • Find the Offset as 1.05 times the Average True Range
  • The Upper range band is the Midpoint plus the Offset
  • The Lower range band is the Midpoint minus the Offset
Now for any given price bar we have the closing price, the Upper Range band and the Lower Range band.
  • If Price is below the Upper Band, we are in an a Uptrend 
  • If Price is below the Lower Band, we are in a Downtrend
  • Otherwise, the price is Neutral and the most recent Uptrend or Downtrend signal is still in effect
The top graphic above is created with TradeStation which easily allows bars to be easily painted blue (for Uptrend) or red (for Downtrend) or green for between the upper and lower Bands.  I coded the indicator for Meta-Trader (left) but have not yet accomplished the bar coloration. I uploaded the Range Bands MQL4 indicator to my yahoo group at: Fx-Mon group.

Next steps are to implement as a trading system inside inside Meta-Trader and see if it has any merit.  I expect I know what the answer is going to be, but its worth the exercise.  It will also be interesting to back-test in Meta-Trader versus TradeStation to see if there are any significant differences in the results.

Range bands are similar to Bolliger Bands except Bollinger Bands use a Moving Average center line and Standard Deviations from the mean for the bands.  They are similar to Keltner Channels except Keltner uses  a moving average center line and multiple of the ATR set as a parameter.

One weakness of the range bands as a trading system is that the distance between the high and low signal bars is 2.1 times the ATR.  The system allows that much for slippage before changing directions.  Active trading should instead demand a much smaller possible loss for potential gain, say risk $1 for a potential gain of $3.

Come back later for part 2 and have a great week.

Friday, January 18, 2013

Meta-Trader - Delta Seven

Welcome back, Meta-Traders.

It was another spectacular week for the bulls with new, 5-year highs in the SP-500 and my portfolios. I took some pretty good profits in Facebook (FB) and RIMM. I also had winning directional trades in NFLX (thanks John Carter) and AAPL. I am also learning a lot from John Carter and SimplerOptions, more on that below.

Sometimes in the course of watching price charts, I see subtle changes in behavior. The behavior of the price action around certain price levels gives you information that you can’t get anywhere else except by looking at the chart. Case in point is CTRX – Catamaran which is the former SXCI Health Systems.

I have been long the stock since they were SXCI and it has recently run up against resistance in the 52.5 area. I wrote some options against the stock and collected some premium on that same contract selling at about 1.20 and covering below 0.50 twice over the past few weeks. Recently I noticed change in behavior and I closed the short option position and went long more shares and CTRX is now my single largest position at about 9% of the portfolio

The chart of CTRX seems to be tracing out the right side of a 6-month cup-with-handle pattern. The way it has repeatedly attacked the 52.5 level, and the speed that it bounced back after recent sell offs has me buying more. Earnings are due out on February 18th.

Here is one simple thing I learned from John Carter and SimplerOptions.  When buying options for directional plays, buy the cheapest option you can find with a delta 0.7 or above. That number means the option will rise 70 cents for each $1 move in the underlying. Exercise to the reader - can you find the delta 0.70 option in the graphic above?  If so what strike would you buy?  FYI - the symbol is LinkedIn (LNKD) for next Friday expiration.

Regarding TradeStation, I learned the following:
  • There’s a monthly data fee of $1 each for NYSE, AMEX and Nasdaq and $3 for Options Data. So that’s $6 a month and I think I can handle that.
  • My account was limited to 3 day trades in a consecutive 5-business day period. To get around this limitation, I need to have at least $25,000 on deposit. Taking care of that.
  • John Carter does most of his options trading inside the ThinkorSwim (TOS) platform and not inside TradeStation. I have used Tradestation for simple directional’s, but not sure how well it handle more complex positions that John puts on.  We'll see how this goes.
Another huge thing I learned is to Trade the Close!

By 3PM,  most of a daily bar of price action has already been formed. Trading the close allows you to get ahead of the next day’s price action before the move happens. It’s sort of like betting on a horse race after the race has already begun. You wait around to see which horse is going to win, then bet on that one! It’s so obvious; I can’t believe it took me so long to figure it out. Note to self: Scan the market after 3PM for “bull elephant” bars in the day’s action. That’s where tomorrow’s winners will be found.   Fortunately, TC2000 has a built-in scan called "Poppers" which fits the bill perfectly.  John Carter enters most of his positions on the close and usually joins the SimplerOptions room at about 3:15 PM EST and stays through the close.

A recent case in point is RIMM. We had a huge daily price bar on Friday 1/11/2013. In fact, looking at the price bar – it was the biggest daily price bar in months! Buy that bar before the close of the day. The result was the stock closed the day at 13.56 and opened the next trading day at $13.90 and hasn’t looked back since!

Finally, it was an interesting week in Forex.  Forex system Sunqu is leading the pack with a year to date gain of +4.51%. This system is a bit of a black box, but has the advantage in that its behavior is so opaque, the market makers can't figure it out! Sunqu was reviewed previously on this blog here.

That's enough for now, enjoy your weekend and get some rest.

Saturday, January 12, 2013

Meta-Trader - 2013 Week One

Welcome back,  Meta-Traders.

Week one of 2013 is now in the books and it was an incredible week in world markets.  My portfolios finally eclipsed the highs made prior to the 2008 crash and after a 5 year correction my net worth is now at new all-time highs!   Don't confuse brains with a bull market of course since we had new multi-year highs in some of the indices.

As for equities, we had nice gains in Facebook (FB) and Research in Motion (RIMM).  RIMM is in a much better buying position now since it just had a bull-elephant bar on the daily chart after a reasonable consolidation period.  Also, they are releasing their Blackberry 10 device shortly and there is a lot of pent-up demand for their devices on the corporate side since they have not released a new device in about 2 years.

Also, I think there is a lot of fatigue with Apple Computer APPL, and the stock continues to behave like crap and weigh on the Nasdaq.  But its clear to me that Apple is last year's story and the baton has been passed to Facebook and RIMM for tech gainers of 2013.

I also started a position in Mastercard (MA) which recently cleared $500 and looks a lot like Apple did last year at this time.   The move from cash and check-based transactions to credit cards is a monster trend which continues to grow.  For example, I now pay my cable television, cell-phone and whatever other expenses I can through a credit card.  Why? Because its essentially a free 30-day interest-free loan - plus I get 1% or more rebate on whatever I spend.  Its free money as long as you pay on time which fortunately is not a problem for me.  Also on the receiving end are credit card giants, Mastercard (MA) and Visa (V).  Mastercard is not cheap at $530 a share, so I'm starting small with 10-share blocks.

And speaking of starting small, I'm trading like a complete wimp in my new TradeStation account.  How much of a wimp?  I bought an EBAY 55 call for $6 and sold it for $18 a day later!  After fees and commissions, that was a $9.71 profit on an investment of $7.04!   In retrospect, that was somewhat lucky trade since the pop occurred on an analyst upgrade of BIDU which caused a sudden, sharp rally above $54 which faded almost immediately thereafter giving me a perfect opportunity to take profit.  In the interest of honesty, I bought the same contract for $2 on Thursday and it expired worthless on Friday.

More typical was a day trade in the RIMM on Friday where I bought the January 12 call for $125 and solid it for $137 11 minutes later!   The cool part about this trade its that I was up about $15 with 2-3 minutes of getting into this trade.  I didn't want to give back any profits, but wanted to let it run, so I put in a 0.05 trailing stop and walked away to get some cleaning supplies.  Within a few short minutes, I heard the platform speak "Order Filled" and I was out with my $10 profit!  Finally I have been unleashed from the commissions and slowness of the Web-based E*Trade platform, and I'm working with some solid trading technology!  But I don't want to keep chasing nickels.  So my plan is to get the account up a few hundred dollars, then up position size and start playing with the houses's money.

On the Forex side, we had a pretty good week.  We took a monster, 220-pip profit from Teyacanani in my AT#1 and AT  #3 accounts.  Sunqu currently has a 3% open profit in a long position in EUR/USD.  3 of the 4 Forex accounts have open long positions in EUR/USD, so hopefully we can get some further upside action next week.

Also on Forex, recall that my study Fun with Forex Historical shows that the 2nd week of January has more average movement than any other week of the year over the prior 20 years. So we don't expect these results to continue, but sometimes luck plays a factor, and we are certainly overdue for some luck with our Forex accounts since everything seems to have gone against us in 2012.

Back to the Tradestation platform, I have coded my foundational trending indicator "Range Bands" which I consider the ultimate trend indicator.  I will share the EasyLanguage code.  I will also consider making it a Meta-Trader indicator and an associated Expert Advisor.  However, I don't expect it be very profitable in Forex, which is just too whippy and has too many false breakouts.   More to come on that, maybe tomorrow.

That's enough for now, enjoy your weekend!

Saturday, January 5, 2013

Meta-Trader - Meet John Carter

Welcome back, Meta-Traders.

Week #1 of 2013 is now in the books, but was only half a week, so let's reserve judgment on what the rest of the year has in store.  For now, let's introduce you to my latest trading mentor, John F Carter. Recall that John runs in combination with Hubert Senters who was previously profiled on this blog here.

The great thing about John and Hubert's business is that they offer a free daily trading video which you can get at no cost by visiting the site and signing up.   From there, you get daily e-mails with free videos where you can see the setups and decide if what these guys have to offer to help with your trading.

Recently, John Carter and Hubert Senters have been going in somewhat different directions where Hubert has been promoting himself heavily via and Facebook, while John started another similar enterprise called which offers daily trading videos, both a free version and a members only version. John's style suits me more since he watches the major, active stocks (AAPL, GOOG, MA) and how to play them via options along with some futures.  John is also the author of the best-selling day-trading book Mastering the Trade.

Both John and Hubert mainly use the platform and the videos are frequently peppered with tips on how to use it. And speaking of TradeStation, my account was funded and I did my first few trades of the year and I netted about 0.4 of 1% in 3 days trading which is a good start.  Its only a matter of time before I transfer my E*Trade accounts over to and save myself thousands a year in commissions.  I have a lot of cool ideas about studies and systems inside TradeStation so come back for that.

This past week, I signed up for a trial membership to for $7 for the first month and for $149 a month after that which can be cancelled at any time.  For that you get 3 times a day strategy updates via e-mail and video along with a chat/trading room.  The trading room runs for about 2 hours in the morning hosted by a guy named Henry who sits next to John in his office.  In the middle of the day, a woman named the Fibonacci Queen comes on who runs her own service at  Finally, John Carter himself comes on to trade the close from 3-4 PM and takes you through his setups and trades.

One cool thing about listening to John is that has the experience to trade for a living - although he probably now makes more money from his various trading related ventures.  In any case, his calm voice and experience is a constant remainder that trading is a tough business and that most of the time, the best trade is no trade at all.  Its also a reminder to keep a "clean and clear head" and to your risk under control since many traders run themselves over the cliff chasing opportunities which are just not there.

All that said, I have high hopes for 2013 and beyond.  Its a better time to be an active trader now than in ~30 years I have been trading and investing.  The tools, technologies and abilities to interact with other traders are just amazing, and only getting better.

Thanks all for now, have a great week and good trading.