Sunday, September 23, 2012

Meta-Trader - Moving Average Clusters

Welcome back Meta-Traders.

Taking a page from the Oliver Velez material, I recently setup my charts with 3 moving averages, 5, 21 and 50 periods.  I setup the colors with pink for for the 50-period, blue for the 20-period and red for the 5-period.

This is a great combination of indicators since the pink line gives you an excellent idea of the underlying trend, the blue the intermediate trend, and the red line the shortest time frame hugging the price and always leading the other 2 MA's in the direction of the price.   The indicators work well with nearly any time frame for the chart,  but my favorites are M5, M30, H1 and D1.

Next, I noticed that good trading opportunities often occur when all 3 moving averages are bunched up close to each other, along with the price.  Thinking of how to turn this into an indicator, and possibly a trading system, here's what I came up with:

double dMA5 = iMA(NULL, 0, 5, 0, MODE_SMA, PRICE_CLOSE, 1);
double dMA21 = iMA(NULL, 0, 21, 0, MODE_SMA, PRICE_CLOSE, 1);
double dMA50 = iMA(NULL, 0, 50, 0, MODE_SMA, PRICE_CLOSE, 1);
 
/* Lowest of the 3 MA's */
double dLowest = MathMin(MathMin(dMA5, dMA21),dMA50);
 
/* Highest of the 3 MA's */
double dHighest = MathMax(MathMax(dMA5, dMA21),dMA50);

// Grab bar high and low
double dBarHigh = High[1];
double dBarLow = Low[1];

// In Range action
bool InRange = (dBarLow <= dLowest) && (dBarHigh >= dHighest);

In other words, we had to have a single price bar whose low was lower than the lowest of the 3 MA's and whose high was higher that the highest of the 3 MA's.  Put another way we look for a single price bar that straddles all 3 MA's.  The result is an indicator call MA-Clusters with arrows show. above.  The chart above shows a buy signal on Thursday 9/20/2012 with a sell signal a bar or 2 later that led to a nice downward move in EUR/USD.

The signal direction comes in the direction of the price close.  In the example above, we had a lower close, so this would be a sell signal.   Stop loss for the trade would be the opposite end of the signal bar.  In other words, if you took the sell signal above,  the stop loss would be right around where the red arrow is located.  There are several ways to take profit, one is to stick with the trade until you get a close above the 5-bar MA.

The next step was to turn this into an Expert Advisor to see if the system had any merit as an Automated Trading system.  After all, automated trading is what this blog is about, right?  To simplify the system, I used a fixed number of pips for SL and TP.  For the tests below, I used a stop of 55 pips and a Take Profit of 150 pips.

What I found from testing is that the system has some decent recent performance.  On a year-to-date basis, the system is up about 20% with maximum draw down of about 18%. But the system does not appear to be profitable on a stable basis over longer periods of time and therefore seems to have more merit as a tool for manual trading.  Perhaps with more work, it can be turned into a long-term profitable Expert Advisor.

You can find the attached files: ma-cluster.mq4 indicator file, FxMA-Cluster.mq4 expert advisor file and year to date back test files attached to my Yahoo group in case you want to play around with it.

Have a great week.

Saturday, September 15, 2012

Meta-Trader - Don't fight the Fed

Welcome back, Meta-Traders.

It was an historic week in world markets. We had 3 huge developments with macro level implications as follows:

- On Wednesday the German high court ruled in favor (or at least not against) Angela Merkel's agreement with European Central Bank's plan championed by (Mario Party) Draghi to print large quantities of Euros to buy EUR denominated bonds to reduce pressure on Spain, Italy and other sovereign's under duress.

- Later on Wednesday, my favorite stock and world's highest capitalized stock Apple Computer announced the 5th generation of their popular iPhone smart phone.  By all counts, the product is a hit, lighter, thinner and with a higher resolution screen.  Throw in new 4G networking and the accolades came in from all angles.  Apple stock rallied on the day of the announcement and also on Thursday and Friday closing Friday at an all-time high of about $691 a share adding about 16 Billion in market cap for this week alone.

- The big bomb dropped on Thursday at 12:30 PM when the US Fed issued their interest rate decision ending weeks of speculation and hint-dropping with key highlights as follows:

1) New stimulus program centered on Mortgage-backed securities pledging to buy 40 Billion (that's right billion) of Mortgage bonds per month.  They also indicated this position was opened-ended, and they would continue to buy bonds as long as necessary until the economy improved.

2) The Fed indicated they would keep interest rates between 0 and 1/4 of 1% until late in 2015.

3) The Fed also indicated they would not be in a hurry to tighten policy and would remain accommodative well after the economy starts to show signs of strength.

Well this was all the Fed bulls could expect and was quickly tagged by the financial media as the most fiscally accomodative statement in the history of the Federal Reserve.  This was all it took to light a huge rally under stocks on Thursday which had already rallied significantly for weeks into the announcement.  Uncle Ben promised big action and he delivered beyond expectations.

Asian stocks also loved the news on their Friday session which ignited another rally in US Stocks on Friday pushing the Dow Jones 30 and the S&P 500 up to 4+ year highs and within a few percentage points of the all-time highs set back in 2007.

All this bullishness sent currencies rallying with across the board dollar weakness and a capping a huge week in EUR/USD which was in solid rally mode all week, even before the Fed Announcement.  2 of my 5 currency accounts had solid gains for the week.  But extreme volatility in the Atipaq instances took profits from those accounts and gave back some recent gains.

Its no doubt and free and easy money is here to say and tighter monetary policy is a long way off.

Not much happening on the development side with currency trading since my regular day job, college search and household responsibilites have me hemmed in.  But we had a great week in markets on top of an already great year.  So we'll take it for now and live to trade (and code) another day.

Have a great week.

Saturday, September 8, 2012

Meta-Trader - Super Mario Party

Welcome back, Meta-Traders.

It was a big week in world markets with a few notable developments as follows:

The European Central Bank (ECB) signaled their intention to create money out of nowhere and buy large numbers of EUR denominated bonds, taking a page from the US Federal Reserve and igniting a huge rally in EUR/USD.  As a result, US Stocks moved out to new 4+ year highs with the S&P 500 moving out to levels not seen since 2007.  Also, my favorite stock, Apple Computer quietly moved out to a new all-time high in anticipation of a release of the iPhone 5 expected this coming Wednesday September 12th.

Even more interesting is that this happened in the face of a very seasonally weak period for the stock market.  It reinforces the point that the "Smart Money" was widely expecting a correcting coming into September and as a result loaded up on put contracts and  long volatility which typically spikes in the face of big market sell-offs.  When everyone is expecting a sell-off, we don't get one, and instead the shorts and VIX bulls got slammed with volatility plunging throught the week.

While my Equity Portfolios benefited from this, my Forex accounts did not respond as well and the only account that was up for the week was Atinalla #3.  Breakout related systems took some trades in the breakout direction, but were shaken out on premature exits.  Fortunately, most accounts went out long EUR/USD with some solid unrealized gains as shown in the screen shot on the left.   We also took some gains in long AUD/USD trades in Atipaq Full Portfolio, but continue to be punished by our Atipaq USD/CHF instance.

Overall, Forex continues to underperform for me as an asset class.  But generally my assets continue to grow and I have my hands full with career and my son's college selection process.  My time will come with Forex, so stick with my on my journey and have a great week.

Sunday, September 2, 2012

Meta-Trader - Fun with Forex Historical

Welcome back Meta-Traders.

One cool thing to have come out of Asirikuy lately is forex historical data from http://www.forex-historical.com.  The site sells 5 minute Historical data on 21 currency pairs to Asirikuy members for a modest fee through an arrangement between Daniel and Forex Historical.  The site also offers free end-of-day data in for those same 21-pairs in 12-hour resolution. 

Free is always transformational, so I downloaded the data for the free end of day data to see if I could get a better idea about seasonality.  Specifically, I was contemplating how much seasonality can be measured.  Put another way, how much different are the movements of the market during 'busy' times versus quiet times during August?  With that in mind, I could potentially filter our trading signals during slow weeks to see if that would improve performance or perhaps decrease drawdown.

Data leads to information, and information leads to knowledge.  But you can't get there without some work.  So I dug right in and came up against these hurdles.  First, the data is in 12-hour format with a single 12-hour record for Sunday, then 2 records for Monday, etc.  I wanted to combine the data by date, so I imported it into MS-Access and ran some queries:

SELECT [EURUSD-Daily-RangePct].DayOfWeek, AVG([EURUSD-Daily-RangePct].PCTRANGE)*100 AS AVGOF1PCTMOVE
FROM [EURUSD-Daily-RangePct]
GROUP BY [EURUSD-Daily-RangePct].DayOfWeek;

That query produced the first graph which shows that Sunday evening session is the slowest, with only 0.6 times 1% of an average move.  Monday comes up to just under 0.9 of 1% move followed by higher values on Tuesday and Wednesday and Thursday topping out at 0.98 of 1% and back to 0.82 of 1% on Friday.  So much for the myth that Friday is the most active day of the week.

So with Days of the week tackled, I went onto seasonality.  The way the holidays fall you can't really be sure that active times are going to fall on a specific day of the month, so month's are much help.  I decided to go with this qualifier:

DatePart("ww",EURUSD1.Date) 

This picks off the "week number" of the year.  There are number of different ways to consider week numbers, but I don't care about the implementation, I just want to see what it tells us.  

SELECT DISTINCTROW [EURUSR-Daily-WeekNo].TheWeek, Avg([EURUSR-Daily-WeekNo].MOVE1PCT) AS [Avg Of MOVE1PCT]
FROM [EURUSR-Daily-WeekNo]
GROUP BY [EURUSR-Daily-WeekNo].TheWeek;

This query produced the following table.  There is one column for each week.  As expected the busiest time of the year is actually the 2nd week of the year with average moves of over 1%.  After that, the moves generally decrease then form another plateau around week 40.  The 2nd highest expected move week is week #45 which is late October, early November.   

So now that we are armed with this data, we can calculate our current week of the year and know how much movement to expect the coming week.  We just finished week #36 which ends a period of several weeks with expected moved under 0.9 times 1%.  In the next 3 weeks, we are now expecting generally higher moves of > 0.90 of 1% for the next 3 weeks.

Overall, the seasonality factor was not as great as I expected, at the maximum about 40% of the movement, but on average is was closer to explaining at most 20 or 25% of the price action.  Anyway, I will upload both the MS-Excel file (Forex-Historical.mdb) and the Excel Spreadsheet DayOfWeek-WeekOfYear.xls to by Yahoo Group in case you want to play around with it.

On the topic of Forex performance, we finally had a good week, with nice gains in almost all accounts.  But with the amount of draw down we have seen, its going to take some pretty spectacular gains just to get back to even.   

Its a healthy reminder that Forex is not an easy way to make money versus say equities which at least have a positive historical expectation.  Throw in a decent dividend yields and the expectation is even better.  Makes me wonder why I even bother with Forex.  Except that its a challenge and so much fun.

Have a great week and enjoy upcoming week #37 when we expect 0.92 of 1% average moves for the EUR/USD.

Saturday, August 25, 2012

Meta-Trader - 0.625

Welcome back, Meta-Traders.

Sometimes I get a bit goofy over numbers.  After all, they are just quantities and one quantity should get pretty much the same consideration as any other quantity, right?  Wrong!

On our way from counting from 1 to 10, we reach the number 6 which it turns out is pretty close to 0.618 times 10 - and 0.618 which is approximately the ratio between any 2 numbers in the Fibonacci sequence.   And I know from years of watching the markets that advances often pause, and sometimes retrace, at 0.6 times the a magnitude of an advance.  Like anything else it the markets, its not a hard and fast rule, just a limit to keep in your mind sort of like support and resistance.

When a stock goes from 20 to 1000, it will have to stop is the 600's.  And when a stock is going from 600 to 700, its going to have to stop somewhere at about 660.  And that's where we are with my favorite stock Apple Computer which this week reached the 660 mark, and then took a rest.  At that point, I decided to take some profits, since they came fast and easy.  At that point, the stock pulled back to about 650, then worked its way higher and closed the week at about 663.  Then after the close on Friday, the jury ruled in the Apple vs Samsung patent infringement case.  Apple won big and the stock close just short of 675 in after hours trading on Friday!

You know I have been on the Apple case for some time.  Not long ago on this blog I remarked that Apple was the second highest capitalization stock on the market just below Exxon Mobile.  Since then Apple is now the biggest cap stock ever in history at 581B, bigger than Exxon Mobile by almost half.   Its market cap is now more than double that of competitors Microsoft and IBM and almost 3 times that of tech titan Google.   Apple is a mega-trend in itself and its obvious what you should do, wait for a pullback and buy some deep in the money calls.  After a pullback to point of resistance (now in the 660 area), next stop is 700 on its way to 1000.  Don't over think it, Meta-Traders.

Forex showed some signs of improvement this week, with finally a winning trade in Atipaq USD/CHF after a long series of losers.  It seems, in some ways, the market has "learned" this system, and seems to find a way to hit its stop losses in the course of slopping around in the directionless Forex action we have seen lately.   Every system goes through losing periods but the question - whether I will be around long enough to withstand the draw down - remains to be answered.

Anyway, Daniel Fernandez will be coming back from Europe in a few weeks.  Perhaps his return will ride to the rescue of our Automated Forex career, and snatch victory from the jaws of Forex Failure.

I am more convinced then ever that adaptive trading algorithms - those which change their tactics based on what has worked recently - are the way to go.   The only system on Asirikuy which meets this description is Sunqu.  And all 4 accounts on Asirikuy are up - albeit modestly.   More to come on this topic.

Enjoy your weekend and what's left of the Summer of 2012.





Monday, August 20, 2012

Meta-Trader - AAPL Day Trade

Welcome back, Meta-Traders

I hope you took my advice from the weekend post to buy some Apple computer.  The chart on the left shows 5 minute bars with 3 moving averages: 8-period, 21-period and 50-period.   Check out the way we had a large opening candle followed by a partial re-tracement.  After that, it hugged the 8-period moving average all the way up the large red candle about 11:15 AM.  Perfect trading conditions for Oliver Velez type day trading.

After that sell off, AAPL went into a complex correction which eventually found support right at the 50-day moving average. Finally it closed at a new all-time high on the closing tick. A classic example of 'painting the tape'. 

Apple is now the largest capitalization stock of all time and has exceeded Microsoft and Exxon Mobile with this latest move.

I'm still long and expecting some further upside tomorrow before a blow-off top later in the week.

Sunday, August 19, 2012

Meta-Trader - AAPL New Highs

Welcome back Meta-Traders.

As you know I am a big fan of Trend Following. I like it because its pretty easy all things considered. You don't have to be particularly clever, or hard working, you just need the simple power of observation. And the stock that has made me more money than any other stock is - your guessed it - Apple Computer!!

Apple staged a major breakout this week by eclipsing the prior all-time high at $644 set back on April 10th. This move corresponds with 4-year highs in the SP 500 and Dow Jones Industrial Average.  I didn't take as full advantage of this move as prior trades - using options - but I was (and still am) holding some AAPL shares in anticipation of more new highs.  

Last quarter's earnings in AAPL were a bit of a disappointment with earnings come in lighter than expected.  That accounted for the sell-off we see on the left hand side of the chart.  The word on those earnings is that sales of the iPhone were light because users are holding out for the introduction of the iPhone 5 - which is expected in the first few weeks of September.  There's also talk of another, smaller iPad and a new version of Apple TV!   If AAPL can do for the TV what they did for the cell phone, they could have a major hit on their hands.  Bottom line is APPL is coming into the fat part of their product cycle, and the fat time selling season (back to school and 4th Quarter) which are traditionally their strongest.   And with a 5-year earnings growth rate of 60% and a PE of 15, the stock is still absurdly cheap.  Next stop is $700 a share and beyond with an ultimate price target of at least $1000.   Don't bet the farm, but don't miss out either, this one is obvious.

And speaking of the obvious, Forex is going the other way with new equity lows in 3 of the 4 systems I am trading.  Let's review the damage.

Atinalla #1 is the only account still holding into gains and actually had a small gain for the week. While its down about -5.61 year to date, its still up about 23% since starting it back in November of 2010.

Atipaq Full Portfolio continued its losing ways, and is now down nearly 42% for the year and -12.46% since start up back in January of 2011.

Atinalla #3 is now down -22.84% for the year and -22.5% since start up back in January of 2011.

Finally, Atinalla Custom is down -26.49% for the year and a down as nasty -42.28% since start up back in November of 20.10%

No action in COATL H1 and Sunqu Live which are stopped.

Totaling the damage, I'm down just over $3000 on a $20,000 investment which is minus about -15%. 

Overall, its not as bad as the individual performance numbers would suggest. I'm going to continue to let the systems run since I recall at times in 10-year back tests, systems go into draw down that looks so nasty, I wouldn't have been able to stand it. If these systems are truly long-term profitable, then they should eventually assert themselves to the upside, right? We'll see, but in the meantime, I'm not committing any more money to Automated Forex Trading.

That's all for now. Go buy some AAPL, even its just 10 shares.  It will soothe the pain of money lost in Automated Forex Trading.   And have a great week.