Sunday, October 28, 2012

Meta-Trader - The 5-minute bar

Welcome back, Meta-Traders.

This past week I came to an important realization regarding trading the Forex market.  Up to now I have been convinced that we can approach Forex trading as a science. In other words, we can apply a set of algorithms and indicators to the Forex market and pull steady profits from the markets while we go about whatever else we do for a living.

What I have realized instead is that if we want to make our daily bread in Forex we have to treat it as a practice.  What I mean is that doctors, dentists, electricians, plumbers and computer programmers go about their business on a daily basis.  At the end of a day's work, hopefully they have something to show for their efforts.  Very few people in those professions expect their work to go out and produce profits without their direct intervention with the possible exception of business owners.

Put another way, I don't know anyone making a living based on the profits from Automated Forex Trading,  I'm sure someone somewhere in the world of high-frequency trading is doing so, but those people are not about to include us in their efforts. Taking it down to a practical level, here's what I propose:

- Trade only during active market hours say from 6AM to 12 noon Eastern time

- Stick with highly active, low spread pairs such as EUR/USD, USD/CHF and AUD/USD.  Avoid higher spread pairs such as GBP/USD and GBP/JPY.

- Run an Expert Advisor which take entries on 5-minute bars using the moving average cluster indicator configuration discussed a few weeks back.

- Stop out of a position once it breaks below of the low of the signal bar for longs, or below the high of the signal bar for shorts. This means you should never lose more that the range of the signal bar, plus the spread plus slippage.  Make no exceptions and cut losses without hesitation.

- Do not consider taking profits until the position moves at least 2X the height of the signal bar plus spread.  Ideally, we are looking for a "runner" where the position moves many times the height of the signal bar.

- Generally speaking, stay with a position as long as it in profit and the MA5 stays above the MA 20 for longs or below the MA 20 for shorts..   Also consider taking profits once they exceed 2-3X the size of the signal bar, or by 11AM since day traders are looking to unload profits for the day by that time.

Following such rules, I had a decent week trading a demo account with dime pips or 0.01 lot size. Should this method further prove to be successful, I will switch to a live account with low lot size and move up based on further results.

What I like about this method is that it usually enters positions automatically several times early in the day and often in the direction of a major break.  The losses take care of themselves, but more often than not, the winners run and run big until later in the morning.  Also, I have found that they markets sometimes make a false break in one direction or the other, the real move of the day does not get under way until after 9:30 AM EST.

The trade in the screenshot above above is an excellent example in AUD/USD on Friday.  First we had a sell signal which got stopped out for a loss of 78 cents.  Next, we had a buy signal where the range of the signal bar was 6.5 pips and it turned out to be a "runner" and was closed for a 42.1 pip profit or 7 times the height of the signal bar!

Once noon eastern time comes, shut down your Meta-Trader program and turn on CNBC's Fast Money Halftime report to see what's going on in equities.

Note that much of this system can be automated, and I already have an EA which handles the entries and the stops, and leaves the take profits to the operator.  The EA needs further refinement, and will be free to my blog readers of course so stay tuned for that.

As for our other Forex accounts, things are looking up and I dare say we are on a bit of a winning streak in the Atipaq Full Portfolio and Atinalla #3 accounts.  On the negative side, a system system which I started trading back in August called System-U (which I haven't talked about yet) has been stopped for the year since it exceeded at -10% equity stop loss. I will likely restart that system in in early 2013 since it has an excellent historical track record.

That's all, have a great week and stay tuned for further results.

Sunday, October 21, 2012

Meta-Trader - A Downhill Slide

Welcome back Meta-Traders.

This past week was ugly in world markets and it was capped off by Friday's -2% plunge in the major indices.

Leading the parade lower was IBM which noted mixed results on "disappointing revenue".  The stock gapped down -2.5% on the next day's open and has given back nearly 10% since.  Then on Thursday Google accidentally released (disappointing) earnings early and the stock lost about 50 points or 7% in a matter of minutes before the stock could be halted.  Even technology giant Apple has been in a steady downtrend and has sold off nearly 12% from its recent all-time high set less than a month ago.

Keep in mind that its October and this type of sell-off is typical for this time of the year.  In fact, this Friday was the 25-year anniversary of the October 1987 stock market sell off.  I went into October (and September also) with a high cash position, so most of this years profits have already been booked.

The only exception was AAPL which I rode down all the way from the top, although only with a small number of shares.   There's some indication that results could be constrained by supply issues with the iPhone 5 which otherwise has been a runaway hit.  This coming week is going to be an exciting one for Apple shareholders with a press event on Thursday when they are expected to release the iPad Mini (dubbed the Amazon Kindle killer).  Also, Apple earnings are due for release after hours on Thursday which should make for some fireworks.

And speaking of disappointments, Automated Forex Trading has continued its disastrous slide with fresh equity lows in every system.  My Atinalla custom account just crossed down 50% from the account opening.    I recently tried a different set of parameters on USD/CHF which have been profitable year to date, but not profitable historically.   That change only accelerated the slide with 2 large losers and one smaller winner.  I'm taking Daniel's advice and stopping my USD/CHF instances in my remaining systems.

Professional Trader Dan Zanger once said that all stocks are bad, and they are only good when they are going up.   I think the same can be said of Forex systems as well.  I think us Asirikuy members have been schooled into thinking we have to sit through long periods of draw down, but I don't think any professional traders (except maybe mutual fund managers) operate like that.  Profits have to be realized, captured and protected, otherwise the market will take them away just as sure as it gave them to you in the first place.

I think the next few weeks are going to have some great opportunities to day-trade options.  Protect your profits and keep your position size small until the market tips its hand on direction.  Then go in for the kill.

Have a great week.





Saturday, October 13, 2012

Meta-Trader - Equity Account Protection

Welcome back Meta-Traders.

What is single most important job of any Trader or Investor?   Protecting your capital of course!

So many new traders come to the markets under capitalized and with high expectations. Their high expectations are soon dashed when, due to poor loss control, their accounts are decimated.

And it doesn't matter how good a trader or investor you are, or how good your system is, because once your account sustains a 50% loss, its takes a 100% gain just to get back to even!

Admittedly, we have been doing a poor job of loss control with our Forex accounts. Asirikuy doesn't offer much help in this regard (as I understand it) because the overall recommendation is to stop trading a system when its draw down from an equity peak exceeds the Monte Carlo worst case scenario which is in excess of 50% for many portfolios.  In addition, it does not cover the issue of when to start trading systems again once they reach the worst case scenario.  After all, if a system has lost 60% or more of your funds, why would you want to trade it again?  So we end up with a scrap heap of discarded systems and no way forward in the world of Automated Forex Trading.

My initial approach to this challenge was to vary the lot sizes according to performance such that lot sizes are  decreased as equity falls and increased as equity rises.  This way we could trade a variety of systems and they could either succeed or fail based on their own merits. I haven't given up on this approach entirely but initial tests were not favorable since, once the system went into draw down, the lot sizes were reduced.  This reduced the system's ability to climb out of draw down, and thus increased the rate of both failure and success.  We ended up with a situation where draw down was reduced, but profits were also reduced such that we could achieve a more favorable outcome by just reducing risk.

After further consideration, I came up with a few simple equity-based account trading rules as follows:
  • Stop trading a system once Account Equity falls below -10% for the year
  • Stop trading a system once Account Equity falls -10% from the highest equity high experienced in that calendar year
  • Once a system is stopped, restart it on the first of the following calendar year
To see how this works in practice, let's take a look at a system I whipped up recently called FxMaCluster which takes a position once we get a price bar which straddles both the 8, 21 and 50 period moving averages.  For a more complete explanation, take a look at this post: Moving Average Clusters.

This chart shows a 12-year back test without the equity stops applied.

We had some great years, but we also had some terrible years including draw downs exceeding 30% in 5 out of the 12 years in the test.  For example, if we started trading this system at the beginning of 2007 and stuck to the end of the year, we would have experienced a 32% loss of our equity which would require a 60% gain the following year just to get back to even!

To implement the 10% stop loss rule, we added this code to our system:


// Equity calculations here
if (dStartingEquity == 0.0)
{
   dStartingEquity = AccountEquity();
}

// Current Equity
dCurrentEquity = AccountEquity();

// Equity cutoff
dEquityGain = dCurrentEquity - dStartingEquity;

// Calculate the loss as a percent of starting equity
dEquityPct = dEquityGain/dStartingEquity;

// Check for equity stop out
if (dEquityPct < -0.10)
{
   Print("Stopped due to breakdown from open", dEquityPct);
   return(0);
}


We added similar logic to stop out once we exceed a 10% loss from the equity high.  After these adjustments, we arrived at the following 12-year back test results.

First observation is that draw down never exceeds about about 12% in any given year.

Second observation is that average profit is almost cut in half, but draw down is reduced to an even higher extent.

Third observation is that in every single year, we hit the 10% loss from either the starting value or from the equity high of the system. Notice however, that we hit the 10% stop from starting equity only one of the 12 years. In the other years, we went to some level of profitability  but ended up stopping out once we fell down 10% from that equity high.

While overall profitability is reduced, overall survive ability is increased since our odds of surviving a devastating loss of equity are improved.  Granted, this is just one system, and one stop loss value and with a different set of systems, and different stop loss values, we could have a complete different result.  But the system does introduce a stop loss discipline into forex system trading which is a much needed addition.

One final point that I would like to make is as follows. Previous research on the topic has shown that the early part of the year, particularly the first few weeks of the year show high levels of trend behavior in Forex markets.  As a result, Forex trading systems have a higher propensity to produce profits in the first few weeks of the year than in any other time of the year generally speaking.  Therefore, if our system has a chance of making a profit, is has a higher chance to do so in the first few weeks of the year. Once a system has moved into profit, we have a higher change of surviving a draw down and being able to hang on for a much larger gain as we saw in 2004.

One final point is the following.  For the past few years, I have been in search of the Holy Grail system which will produce regular profits much higher than draw downs.  What I have found, is that despite what back tests show, such a system does not exist and we must be prepared for the worst case scenario at all times if we wish to survive in this business.

Final realization is that Forex is no a road to riches, its just another asset class to be considered along with Stocks, Bonds, Commodities, Real Estate, etc, etc.  Granted we have a better degree of loss control in Forex versus other asset classes, but only if we choose to exercise that loss control.

Next step is to implement the stop loss discipline inside the scrap heap of systems I have tested and discarded to see if it makes them worth trading.  Also worth a try is to see if implement this stop loss discipline inside the Asirikuy systems reveals any interesting conclusions in term of whether they are worth trading when equity stops are enforced.

Have a great week.

Sunday, October 7, 2012

Meta-Trader - Analyzing Account Equity

Welcome back Meta-Traders.

When last we left off, we were considering the analysis of account equity.  The objective of this exercise is to analyse the recent behavior of our trading system by examining the actual trading results.  Our goal is a money management scheme that works as follows:

- If a system is behaving poorly in current conditions, reduce the lot size or stop trading it altogether

- If a system is behaving in a neutral fashion, neither gaining or losing money, we can continue to trade it with standard lot sizes.

- If a system is behaving well under current market conditions, then we can go ahead with the full market exposure.

When this method is working properly, we can be trading (or monitoring) a whole crowd of trading systems and having the systems automatically scale into systems which are working and scale out of systems which are not.  Keep in mind that this method will work only for systems which trade frequently, and make (or lose) their money over a series of trades.  It will not work for long term trend followers which may have say 9 small losses and make it all back on the 10th trade.

Looking further into this, I found that Meta-Trader does not have functions which allow tracking of historical account equity.  However, there is a function called AccountEquity() which does just that and spits out the AccountEquity at any given point in time.  Fortunately, this function works as expected whether running live or in back testing mode.

Next, we have a series of functions which can determine (for any given magic number), how much money that instance made or lost as follows:

double OrderHistoryProfit(int nMagic)

int i;
int nOrders = OrdersHistoryTotal();
double dProfit = 0.0;

for(i=0; i < nOrders; i++) 
{
  if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
  {
    if (OrderMagicNumber() == nMagic)
    {
      dProfit = dProfit + OrderProfit();
    }
  }
}
return(dProfit);
}

This function takes a system's magic number (set inside your EA or in the EA Properties) and returns the total amount made or lost.  You might think that the total amount of money made or lost is a poor indicator of whether we should be trading the system.  On a long-term basis, I agree.  But on a short term basis (say the systems last 5 to 10 trades, it could be a good indicator of how well the system is performing.  If you don't agree, take a look at the equity graphs of the systems I have been trading live for the past few years.  Its clear to be that those systems have long, sustainable equity trends.

With this function, we can continue last week's thought experiment and adjust our lot sizes dynamically based on recent performance.

Unfortunately, that's all the time I have for this week.  Check back later and have a great week.