The Mathematical Approach to Mechanical Trading

Hotch

Experienced member
Messages
1,409
Likes
256
As I've really reached a bit of a slow point in system development (need to get my TS account sorted, and waiting for hardware to arrive). I thought I'd try posting my thoughts on developing systems, hopefully without giving away the most important bits about my system.

Most of the things I'll say are probably simple and obvious, but I found I didn't instantly know them, and had to think about them. To explain the title, while it is important to know how the markets work, I think many traders find it hard to make systems because they find it hard to work out what they actually do, especially if they've been trading a long time and it's now become instinct.

Coming from a mathematicians point of view, with a knowledge of trading, I think I have a good skill set, and hopefully, I can put down some thoughts which will help others.

The first thing most people want to do (people I have talked to at least) is to see if their initial thoughts are profitable. I think most people (me included) agree this is the first thing to do. They do this by seeing if they reach you're profit target before you hit your stop loss.

Also, it's probably good for me to keep notes on my thoughts, why not make em public.
Oh, and I'm really not sure if all/any of this is correct, especially as I'm rubbish at getting my point across in text. Discussion is always good!

This IMHO is wrong. You have decided that the first thing to do is see if your strategy is profitable, but what you've actually done first is set profit targets and stop losses.

I saw this problem coming, and thought on it, and decided on the following.

For any given product at any given time, there are but 3 options.

1-Go Long
2-Go Short
3-Leave it alone.

Now, most people automatically think, "well, long is the correct play trade if the price goes up, short is correct play if the trade goes down, and leave it alone is the right trade if neither of the above apply", some people even forget about option 3, claiming that eventually the price will move, but that's not an effective use of your money, if you get your signal a significant time before the movement, then work it into your strategy that you wait the appropriate amount of time.

To define it a bit better, the movement has to be profitable (larger then commission, the spread etc).

This still isn't really good enough. The best definition I have come across (as said before, it might be obvious to everyone else), is that...

1 is correct if the trade becomes profitable before option 2 becomes profitable
2 is correct if the trade becomes profitable before option 1 becomes profitable
3 is correct if neither 1 and 2 are profitable until you get another signal*

*This definition is tweaked depending on how many symbols you trade etc. For example, if your system runs on 2 symbols, 3 would be correct if 1 or 2 would be correct on either of the symbols etc.

Now you can calculate the percentage of the time of which your signal is correct.

To stop losses and profit targets!

Now stop losses and profit targets are interesting things. They really can be as simple or as complex as you want. There are tonnes of ways of thinking about them, but I'll go through my logic from first principles.

In a perfect world, you wouldn't need stop losses and profit targets. Signals would be your only exits (eg, you're long, when you reach the maximum profit, you get a short signal etc). However, your signal won't (probably) pick up every movement. This means market direction will change without you getting a signal, profit targets are to get you out of trades when your signal is no longer correct, without you having another signal. As time goes on, your signal will become less important as it fades into the past, so you can't rely on it.

So how do I calculate my profit target. I've simply taken the highest profits possible, before I get a differing signal (leave alone signals don't count here as I'm already involved), and averaged them. Now I might take a small amount off this as it is hard to get the highs (if you understand me). This assumes that maximum profits follow a normal distribution.

Now stop losses are for when you get it wrong, and you haven't got a new signal to tell you so. The obvious problem is that without a signal, you don't know whether the price will continue to go against you or not. What I decided to do was try to differentiate between the trades which win before an contradicting signal and the trades which lose. So I take the average of the lows which my winning trades get to and put the stop loss just below this.

I am pretty sure lots of this is wrong actually as I am shattered. Sorry for glaring mistakes. Hope you enjoy. Will try to put some more things in later. Any questions, fire away.

I'd like to get this part of the forum a bit more busy :D

Oh yeah...do you consider the above curve fitting? From what I've seen, I'm not sure I agree with all the definitions of curve fitting. Some seem to say that using past data to draw any conclusion is curve fitting.
 
TBH, I've decided I am far too inarticulate to express my views which can apply to all systems, they are far too individual for me.

FAIL
 
Last edited:
Hotch,

by my way of thinking, profit targets are only one way of exiting a trade. You definitely wouldn't want to use profit targets if you were for instance trend-following. Only really makes sense to me if you're swing trading.

You could have time targets, e.g. exit after 24 hours, or exit on close.

You could have trailing stops.

Basically I've never found an algorithm that can make money with profit targets. But then I'm end-of-day only.

On another subject, since you ask, I think you probably are overfitting your past data if you calculate your profit targets like that. Have you done much statistical analysis of it? What does the parameter landscape look like for profit target size? i.e. if you plot profit target against final profits, is it a nice curve with a smooth peak in the middle, or is it all spikey?
 
I thought I put in that only some of the exits are stop losses and profit targets?
Bah, was probably in one version. Sorry.

The more I look at my post, the more I realise that some of things I typed are just plain wrong, really was zoned out last night.

I think once my TS application goes through I'll have another look at it, and should probably leave it til now.

Sorry once again. I'll come back when I've figured how to make a half decent contribution :p
 
No problem, sometimes I forget to take my pills as well.
 
Now you can calculate the percentage of the time of which your signal is correct.

To stop losses and profit targets!

Oh yeah...do you consider the above curve fitting? From what I've seen, I'm not sure I agree with all the definitions of curve fitting. Some seem to say that using past data to draw any conclusion is curve fitting.

So tell me how that is different when applied to the stock market versus being applied to the craps table or the roulette wheel? There ARE books out there with live results of those games documented over a 48-72 hour period for people to "backtest" strategies.

Would use trust your "stop loss and profit target" backtest using such data, when you know the game can mathematically be proven to have negative expectation?

To some extent, I think the stock market IS similar to craps. That is:

-- In craps, you can fairly accurately predict the distribution of die rolls over a long period. But that doesn't help you in predicting the next roll of the dice.

-- In the market, you can may have some idea of the long-term results of investing in the market. But that may not help you predict what will happen in the next month, week, day, hour, on minute.
 
Top