23.11.2012 г.

Trading strategies: using computing simulation to maximize profits and to control risk

Download link: 

This is a free e-book from Larry C. Sanders from his website tradelabstrategies.com. On this discussion forum you can read an interesting discussion about it.

Larry C. Sanders addresses the topics of probability, marble game and MonteCarlo simulation. He has also designed a software program TradeSim which he sells at his website. The book can be downloaded at this site for free (this is the bookmark link). This book also talks about the Monte Carlo analysis of trades.

19.11.2012 г.

Monte Carlo simulation for trading system's risk control for real newbies

"What is the last thing you do before you climb on a ladder? You shake it. And that is a Monte Carlo simulation" 
Sam Savage, Stanford University

So if we make an analogy the ladder is the result of the trading system's back tests.

Have a look at the picture. Here we have 10 trades of our imaginary trading system, they are numbered from 1 to 10. Each trade is either good or bad, what is important is that we have an equity curve that is formed by those trades.



Here you can imagine we have a result consisting of 10 trades. What we do is that we shaken those results randomly, however no trade is added or deleted. What we do is that we just replace their position randomly. This is called selection without replacement. In other words we change the positions of the trade sequence of the system. 


By doing selection without replacement we duplicate the probability distribution of the initial trade sequence.

If we apply this many times on an initial trading sequence we will get something that looks like that, check the screen shot.

The beginning and the end is at the same point because it is the same trading sequence, but the paths are different.

However the next questions arise, how many permutations we can do? 10, 100, 10000 or 100000.

The practical limits are given by the statistics.

Imagine we have 1000 trades. By calculating the permutations that will give us:

1000*999*998*997*...3*2*1

The number we get is unbelievably big. The number of permutations of 200 is bigger than the number of all atoms that exist in the whole universe. So it if obvious we are not going to do all those permutations.
Hopefully there is a simple algorithm that will help us:


If the probability p is close to 0.5 So the 95 % confidence interval reduces to the following formula:

If we have a flipping coin of 1000 times and we want a confidence level of 95 %. The confidence level will explain how likely the 500 heads is placed within the confidence interval around the estimation.


For the Gaussian distribution we can be 95 % sure that the value is accurate within 3.1 %. With 95 % probability the coin will will fall between 469 and 531 times a head from the 1000 trials you can do.


If we use the formula we get

0.5+1/sqrt(1000)= 0.5+ 0.3162277

0.5-1/sqrt(1000)=0.5- 0.3162277


So we can share that the value is 95 % sure that is accurate within 3.1%.

Practical use of Monte Carlo simulation for traders

So what does it means in practice. In fact the most important aspect of this kind of Monte Carlo analysis is the analysis of the drawdowns. For example with a given confidence level you can say what that worse drowdown can be.

Look again at the shot where are the equity curves. We are going to be interested at the worse case scenario.

Imagine the original system has 500 USD drow down an 1500 USD average profit per year. In our hypothetic example that would be the system with the blue line.

So now we are going to look at the hypothetical equity line with the worst drow down.

If your Monte Carlo analysis show you for example 1000 USD as the worse drowdawn at 95 % confidence level that means that there is 5 % chance of facing 1000 USD drow downs before making any profits. Well if you look at even lower confidence levels the expected drowdown can be lower.


However the worst drow down is not more than the average profit of the system. According to Urban Jaeckle and Emilio Tomasini it is unacceptable to have a drowdown lower than the average profit per year.


The main limitation of the Monte Carlo analysis are that if your initial results are curve – fitted your results will be a nonsense. The Monte Carlo analysis is good only when it is applied for a sound trading system and not to an over-fitted one.

If your trading system is sound or not that is just another thing. The Monte Carlo simulation need to be applied with care but it is a valuable tool for risk control of a sound trading system.


Recommended readings 


Urban Jaeckle, Emilio Tomasini, 'Trading Systems A new approach to system development and portoflio optimization' Hariman house, p.101-108

Farell, Christopher, 'Monte Carlo models simulate all kinds of scenarios' Business Week 2001

Discrete Event Simulation a First course at this link



14.11.2012 г.

Range and timing: John Last's Forex Jokers

John Last's Jokers are useful in three games on the market ;) (market states).

For each game (phase) we have one joker.

You can play three games and they come over and over again. Range, Breakout, Trend, Range, Breakout, Trend and so on.

For each game you have one joker ;)

This is a tactic for range daytrading

Here look at this screen shot below.

Here I try to make an accurate timing of the range.

The idea is as follows. Range can be played but we need it to be fairly broad. This is clearly visible on the fractal bands, but also the common Bollinger is also useful.

In the narrow range (from the perspective of fractal technical analysis) is difficult to be played. Why? Because then orders accumulate  on both sides and it is a matter of chance where will break, and the fake break - outs are pretty nasty. We have to wait patiently for a breakthrough, not to bet which way will break. Well the general technical analysis bet for the continuation of the previous trend but on the 5 m time frame this is ... hard.




OK loot at the screen shot again. We have a christmass tree here but if you wait for Santa Claus this is a good thing to do.

1. Brain trend setting 14 (You can optimize the smoothing visually or run the Brain Trend EA in order to get the best performing set on the current market state)

2. Bollinger bands with 20. This is the fast Bollinger.

3. Bollinger bands with 60 period. This is the slow Bollinger.

The idea is to match roughly with Bollinger of 20 on  15 m time grame. So I multiply the period of three (According to Bollinger should do 2.1 standard deviation increase in the period but you need a special indicator to do that).

4. Oscillator-based digital filter and here a simple smoothed stochastic works (on this chart I use a commercial product but nowadays you can find good indicators easily)


Watch for signals from reaching the two borders of Bollingers the fast and the slow. You can use only the slow if you want.

Then use your price action skills, or use oscillators or wait for convirmation from Brain trend.

Even better you can have your individual oscillator based range system.

Or look for overbought or oversold  levels of your favourite oscillator.

What makes this different is that we do not identify a fractal break - out from the FGDI, or iVAR indicator. And not peak in the indicator: variation of the Hurst exponent.

A can add many confirmations of stochastic on the 15 m time frame but it is useless.

The idea here is that we have two independant statistical tools that come together with pattern recognition.

The Bollinger bands are giving a deviation from the central tendancy.
The Fractal indicators need to detect an anti-persistent situation.

Then you can bet for the reversal.


About Money Management seems reasonable following system:

When signal meets the criteria found three items:

1 Close for a small profit to cover the transaction costs
2 Close at the reaching the midline of the 60 period Bollinger
3 When you reach the opposite levels of resistance and support levels of the channel opposite Bollinger.

Position 2 and 3 can have dynamic stf opso Brain The line.



-Be careful with the News



Trend Joker

Never  counter the trend by having  fractal dimension in the RED of FGDI and the fractal bands have to be wildly apart there. Again a brutal reversals are possible but to catch them you should not suppose it but to react ASCTrend or Brain trend are a good choice.



Range Joker 2

Rage divide it into two types. Narrow and wide. Narrow is risky.


Break-out Joker 3

We have a valid break when fractal dimension crosses 1.5. If this is accompanied by a large variation of the Hurst exponent is morethan- a strong signal.

Again Joker # 1.