середа, 23 березня 2011 р.

Trading system design

Lucky...That would be far more exciting.



I rarely post on the FF, but I have seen a lot of these posts recently - questioning (or, in some cases, audaciously claiming) that it is impossible to trade successfully in the long term, or that any long-term prospect of success is weighted far more towards luck than a sound trading practice. Let me address this as thoroughly as possible, hopefully in a somewhat logical order.

The time-frames that are you trading on (1m, 5m, etc) will undoubtedly be exposed to a significant amount of noise - news releases or other liquidity spikes will be much more likely to stop you out if you hold tight-stopped, short-term positions. I am NOT saying that is it impossible to trade smaller time frames, but just for someone that is worried (and seemingly overwhelmed) by the numerous factors that effect the market, I think larger timeframes would be a better bet.

I will now run through the process that I personally use to construct trading systems. Yes, I only ever trade a system with a strong statistical basis, since trading anything other than that would be impossible for me to put any long-standing faith in, and subsequently impossible to mentally stick with in times of greater drawdown. Even an EA that I hadn't PERSONALLY tested and judged to be statistically significant in its expectation would be very difficult to stick with during losing streaks. But I digress...

The first step of the process is to identify variables that you believe create a slight statistical edge - where given 1000s of incidents of that variable occurring, you would expect the chance of "something" occurring slightly more 50/50 (the greater the ratio, the greater the edge of that particular variable). Once you have that variable, you look for other variables that can be used in conjunction to further increase your statistical outcome through filtering out some of the initial trades. Eventually, you have an entry condition that could be expressed as an if statement: if x=3 and y=5 and z=10 then you place a buy stop/sell stop at a certain predefined point (the numbers and variables used are completely arbitrary, so don't pm me asking how I defined z...). On that note, to truly create a system that you have any statistical confidence in, everything - every single possible action that you take entering, existing or modifying a position - has to be 100% defined.

So at this point, what do you have? You essentially only have an entry condition where you are confident that when x,y and z align in a certain way the outcome over many instances should be within some statistical expectation. Does this mean you have a winning system and can conquer the world? If only it were so easy...

At this point - which honestly is the point that many traders stop at, if they even define things so precisely at all - you simply know when to enter the market. That’s it. You have no concept of money management, stop placement (fixed pip or varying based on recent volatility), or exit conditions. How do you go about defining those? In much the same way as you defined the entry. By looking at 1000s of occurrences where your system produced an entry, and then meticulously testing variations of all of the above. Sounds pretty tedious right? Well, it is, but it is double for those with patience and reasonable logical faculties.

Let me give you an example. (Disclaimer: this is by no means an actual system - I am literally making this up right now with no basis in anything. I will sell it to you though…) Say you have defined your timeframe as the daily charts. The entry condition that you have defined is that when the RSI 96 is above 50 AND when you have an inside bar AND when the price breaks the inside bar by at least 15 pips (through the use of a buy). Your stop lose is based on some consistent measure of recent volatility (ATR, etc), and you are using fixed fractional position sizing for your MM. Your exit is defined as whenever the move reaches 1.5R in profit. You also mechanically cut loses depending on other x,y,z factors that you observe at the end of a given period (at the end of the day, in this case). All trading actions are taken at the end of the period, and only at the end of the period, to remain 100% statistically consistent.

So, now you have a system that is completely defined, but does it work? The only way to answer that (aside from live trading, of course), is to first backtest it over 1000s of occurrences. Another point is that in a statistically based system, you have to take EVERY SINGLE INCIDENCE of a trade that aligns with your variables, making it more difficult to do on lower time frames without an EA unless you want to watch the monitor at the end of every period like a crazy insomniac. Backtesting over a large sample size with 100% defined trading rules will allow you to see how your system would have performed over a certain time period.

To make it clear, when I say backtest, I don't mean what I think many in this forum do: looking at their chart over a couple of years (or months - or even weeks...) and gleefully counting in their head "winner, winner, winner, winner, loser, winner, winner, loser, winner", while half-focusing on the finishings on next year's 200 foot mega yacht. The testing should be nothing less than scientific. You are a market scientist, trying to create a market theory, so every stage of the process needs to be defined and testable. You will know that you are doing this right when you aren't thinking of all the money you are going to make but instead simply recording, in thorough detail, all of the data that you are going to need to properly formulate a compelling theory; as a side benefit, you will also limit testing bias, since you will no longer TRYING to prove anything, but simply testing to see if it could be a tenable theory.

Lets say you do this, and you find that your system over 5000 consecutive trades would have produced a win rate of 55% and a average win/average lose ratio, as a percentage of R, of 1.3/1. As a brief aside, for those that haven't done this before, constructing a system is always a balancing of two often-competing factors: win rate and ave win/ave lose ratio. Generally they are inversely correlated to a degree. A trend following system, where you typically have high R multiple winners will typically have a high ave win/ave lose ratio, but a lower win rate (often below 50%). A scalping system, on the other hand, where you are quicker to take profits, will typically have a higher win rate, but a lower ave win/ave lose ratio, since, well, you are quicker to take profits and therefore don't capitalize on those large R moves. It is the balance of these two factors that creates your expectancy - and, if you have developed a good edge, hopefully a positive one.

So are we done yet? Haha - not quite. Those two factors are only a small measure of a system's success. Ultimately you should focus on the biggest factor that will determine your system's biggest success: its annual return/worst annual drawdown. And the ratio itself is only part of the battle. Sure, you can have a 50/1 ratio, but if you have a max drawdown of 60% than the ratio is somewhat misleading, even with that 3000% return. You can of course decrease the drawdown by decreasing your position risk, but that will also exponentially decrease the ratio due to less compounding on the upside. Ultimately, you are looking for a decent ratio - but more importantly, a reasonable drawdown that is psychologically palatable for you, and which your system can reasonably recover from.

After that you have that, for an extra measure of confidence, you should perform a monte carlo test on your 1000s of results. You want to make sure that 1,000,000s of permutations of the results are consistent, and that the results that you obtained were not just the product of 'lucky' historical sequencing.

Finally, once you have all of that, then you are finally ready to...forward test. How glamorous, huh? So, you forward test the system over a couple of months, and if it clearly performs within statistical expectation, then, and only then, are you ready to go live.

Some other notes on system development:

1. Make sure that your sample size is suitably large. Constructing a system over 50-100 or so trades is complete foolishness, and 'curve-fitting', in the negative sense of the word (with the arduous strategy above being in the more positive sense). You are a scientist, and you need enough results to formulate a plausible market theory.

2. Make sure that EVERYTHING is measurable and defined. If not, then your system will have elements of inconsistency. Wishful thinking prays on these little pockets of testing-inconsistency, and can significantly distort your statistical expectation if you allow it to leak into a system that is crafted with anything less than 100% precision.

3. Make sure that your testing period includes diverse markets, and preferably functions over numerous market conditions and many years. Even better if it broadly functions across different currencies, but this is not essential. Essentially, you want to limit the myopic curve-fitting experience, where your system is highly calibrated to a rigid set of market parameters. If for instance, your system works great in 2008, make sure that is works well in 200x, since 2008 is not necessarily broadly representative.

4. Always remember that there will be testing inaccuracies. Be it that certain positions were different/entered/not entered based on spread changes, charting errors (hopefully not if you choose a good feed) and the tendency for human positive bias (mitigated by 100% rigid testing parameters). Generally, a shorter time-frame system will be affected more my the spread change issue than a longer-term one.

Whew! So there you have it: a system that you can put a fair degree of faith in moving forward. And that, ladies and gentlemen, is about all you can ever hope for in trading. Why? Well, to finally address the initial question in the thread, because you can never, ever, ever get away from the fact that the market is uncertain, and that at any moment in the future it can behave completely differently from any way that it has behaved before. So is that luck then? Only if you define luck as the market consistently behaving based on robust expectation. At that point it just becomes a question of semantics.

One thing that certainly isn't luck, though, are the long-term track records of the successful few; that type of legacy is the product of systematically superimposing robust constraints on the markets. But what about when the systems stop working - does that not then negate the proceeding accomplishments and make it all a lucky ride? Not in the slightest. For one, the more robust and broadly functioning the system, the less likelihood that it will stop working - which, of course, is a design feature that has nothing to do with luck.

Sure, Chris, but even THOSE can stop working too - isn't that luck? Well, yes, in that very rigid sense I suppose that you could define this inextricable luck component as the "duration of time that a particular robust system functions before it no longer functions". I will concede that limited point, but again, I more than accept that as inevitable uncertainty, that you will necessary have in any endeavor that you peruse. You could start an orange juice company that does great year after year for 20 years until the FDA comes out and says that orange juice knocks 10 years off the average life, and the market completely shrivels up. I never look at any system I develop as a sure thing, or something where I can simply press play, go into a 50-year coma, and wake up the richest man in the world. Again, this is where long-term success should not be confused with luck. There are always exogenous uncontrollables (black swans, as it were), but the part that isn't lucky is having a feedback mechanism to recognize when one has happened, and having a plan in place for when it does.

To bring it back to the example, say the system that you designed had a maximum drawdown, over a 15-year period, of 20%. With monte carlo analysis, over millions of permutations based on 1000s of initial observations, you conclude that you have a 95% confidence of never dropping below a 25% drawdown. Does this mean that it will never happen - is this the certainty that you were looking for? No way. It very well may happen; in fact, I would postulate that given enough time it will happen, since, after all, it is only a 95% confidence. Even a 100% confidence would still be based on only x thousands of occurrences, never escaping the uncertainty of what may come.

What you do know, however, is that if you drop below 25% drawdown then you are starting to venture outside of statistical expectation. So you make a fail safe. You write it on your wall and you stick to it no matter what. If the system ever breaches x% drawdown, then I will stop trading until I am again assured that it is operating within expectation, and that the drawdown was merely a standard deviation event; if, however, it doesn't resume its normal functioning - if it doesn't recover from the drawdown based on a reasonable logarithmic expectation - then it is time to go back to the drawing board, figure out what changed, modify your variables accordingly, and strive to develop a version of your system that incorporates all of your previous 1000s of occurrences AND the new ones that had previously thrown it off. Curve-fitting? Sure, but again over many, many occurrences so that it is broadly functioning. The more robust your model in the first place, the fewer changes that you will likely have to make, and it will be easier to integrate them without a complete overhaul.

Well, that’s about it from me for today. I hope this was helpful. I obviously know that it can appear overwhelming, but this is simply the reality that has allowed me to be consistently successful. Stop looking for certainty, stop worrying about luck and designing something that will prove to be infinitely viable. Become a market scientist, create a viable market theory, play it out until it stops working (hopefully, if it is exceedingly robust, you will be dead long before that happens), and then have a feedback mechanism ready so that you can roll with the punches, make your adjustments, and continue moving forward. And specifically for the initial poster, don’t worry so much about all the millions of factors that move the market. Stop trying to know and control everything - you can’t and you don’t need to.

Best,

Chris


http://www.forexfactory.com/showpost.php?p=2212020&postcount=12


Немає коментарів:

Дописати коментар