Monte Carlo: Getting to know your system

Thomas Dall
2019-03-26

Who am I?

  • PhD Astrophysics, 10+ years in research.
  • Lecturer in Data Analysis.
  • Trading — I thought I was smart…

An Objective Process (Really??!)

  • Principle: Normalize!
  • Focus: System Operations
    • AFTER System Design and Backtest
  • Know Your System Numbers…
    • …at least the relevant ones
  • Two Real Examples

Normalize #1: Risk & Return

Fig1

Risk on this trade:

\[ \begin{aligned} \mathrm{risk} = & 11559 - 11549 \\ = & 10 \mathrm{EUR/cfd} \\ = & \mathrm{R} \end{aligned} \]

“R” is the normalized Risk Unit.

Normalize #1: Risk & Return

Fig1

Result of this trade:

+2R

Make lots of trades

\( \rightarrow \) R-distribution

R-distribution -- Example #1

plot of chunk unnamed-chunk-1

\( \bar{R} = 0.04 \)

This is “mean-R

But: Reality is not normally distributed!

R-distribution -- Example #2

plot of chunk unnamed-chunk-2

\( \bar{R} = 0.08 \)

\( f_\mathrm{win} = 0.55 \)

R-distribution -- Real Example #1

plot of chunk unnamed-chunk-3

\( \bar{R} = 0.1 \)

\( f_\mathrm{win} = 0.59 \)

System Type:

Mean reversion Swing

R-distribution -- Real Example #2

plot of chunk unnamed-chunk-4

\( \bar{R} = 0.29 \)

\( f_\mathrm{win} = 0.34 \)

System type:

Trend-following Break-outs

Equity Curve

plot of chunk unnamed-chunk-5

plot of chunk unnamed-chunk-6

Underwater Equity

plot of chunk unnamed-chunk-7

plot of chunk unnamed-chunk-8

Normalize #2: Expectancy

Usual definition of break-even:

\[ N_\mathrm{win} \bar{P} - N_\mathrm{loss} \bar{L} = 0 \]

First step: divide by \( N_\mathrm{total} \):

\[ f_\mathrm{win} = \frac{N_\mathrm{win}}{N_\mathrm{total}} \]

Second step: Use average R instead of “real” amounts.

Normalize #2: Expectancy

Normalized definition of break-even:

\[ f_\mathrm{win} \bar{R}_\mathrm{pos} - f_\mathrm{loss} \bar{R}_\mathrm{neg} = 0 \]

where: \( f_\mathrm{win} + f_\mathrm{loss} = 1 \)

Which means:

\[ \mathrm{PF} = \frac{\bar{R}_\mathrm{pos}}{\bar{R}_\mathrm{neg}} = \frac{1-f_\mathrm{win}}{f_\mathrm{win}} \]

Where PF is the Normalized Profit Factor

Expectancy Curve

plot of chunk unnamed-chunk-9

Expectancy Curve

plot of chunk unnamed-chunk-10

Questions!

  • How much to risk on each trade?
  • How long is…
    • … average losing streak?
    • … maximum losing streak?
  • Probability of a losing month/week/day?

And the Big One:

  • When actual results \( \ne \) BT, how to tell if it's “normal” behavior or system malfunction?

Monte Carlo Simulation

Investopedia:

Monte Carlo simulations are used to model the probability of different outcomes in a process that cannot easily be predicted due to the intervention of random variables.

Monte Carlo Simulation

Fig2

Select Sample Size and Number of Samples

Typically I use Number of Samples = 1000

The Sample Size depends on reporting time frame etc…

Real Examples...

  • BO system:
    • 152 trades in 3 months \( \rightarrow N_\mathrm{1M} = 50 \)
  • MR system:
    • 326 trades in 3.5 months \( \rightarrow N_\mathrm{1W} = 25 \)

Monte Carlo Expectancy - BO System

plot of chunk unnamed-chunk-11

Monte Carlo Expectancy - MR System

plot of chunk unnamed-chunk-12

Monte Carlo Expectancy - MR System

plot of chunk unnamed-chunk-13

The "Big One" -- An Answer?

t.test(rBO$R,rRSI$R)

    Welch Two Sample t-test

data:  rBO$R and rRSI$R
t = 1.0735, df = 182.32, p-value = 0.2845
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.1555376  0.5267527
sample estimates:
mean of x mean of y 
0.2897303 0.1041227 

Problem: Requires high numbers for accuracy