The Trading Simulator
A good Trading Platform always includes a Trading Simulator that takes a trading system’s rules and, applying them, calculates simulated paper-trades in a time interval. The purpose of its presence is speed, efficiency, and accuracy performing thousands of computations per millisecond.
Forex traders habitually receive MT4 for free when they open a trading account. Their MT4 will include a strategy tester which is available clicking on a magnifying glass icon at the top right of MT4’s main screen or Ctrl-R.
Fig 1 – Strategy Tester Icon and Shortcut
Below, a sample of the MT4 Strategy Tester Summary Report ( click on it to enlarge)
Fig 2 – Metatrader 4 Summary Report
MetaTrader has a summary report of average quality, but it’s widely used. So, let’s review its main components.
This summary report shows the overall statistical information needed to recognise if our strategy is profitable or junk. The main parameters are:
The amount of initial paper money account. It only matters as the initial reference for testing.
Total net profit
The difference between “Gross profit” and “Gross loss.”
The total of all profits which resulted from only the profitable trades
The total of all losses produced by only of the unprofitable trades
The ratio gross profit / gross loss: A very important metric.
The monetary expectancy of the tested strategy. The mean monetary value of each trade. One of the most important parameters. It should be greater than zero for a positive expectancy.
The largest monetary loss that is below the initial deposit value
The largest monetary drawdown starting from any local maximum of the balance. Very important. A good strategy might be worthless if it produces several huge drawdowns. You need to define your maximum allowed level you’re able to tolerate.
Even if the system’s results are below your mark, it might be optimum to perform Monte Carlo permutations (preferably more than 10.000) to study the probability of those drawdowns carefully. This value changes with position size. It will increase as you increase your position and, consequently your risk. Be aware of this crítical fact!
The maximum per cent account decline relative to the account balance at a local maximum. The same as Maximal Drawdown but percentwise.
The total number of trades executed. It is essential to get at least 100 trades to obtain a statistically sound approximation. This value is of interest, also, when comparing systems. When multiplied by the expected payoff it should return the total net profit value.
Short positions (won %)
The number and per cent winners in short trades. It shows how good the system is when trading short. You should observe if there is an asymmetry with long trades and look for possible reasons (and solutions).
Long positions (won %)
The number and per cent winners on long trades.
Profit trades (% of total)
The total number of winning trades and its per cent of total trades. Statistically, it’s not that necessary to obtain large per cent winners, if the profit factor is high. But this value is important from the psychological perspective. For instance, usually, trend-following systems have less than 40% winners but depict reward-to-risk ratios of up to 5. Therefore, you should decide if you’re able to accept just one winner out of three or you’re more comfortable with higher rates at the cost of less reward-to-risk ratios.
The % of Total figure enables us to find the probability of winners in a row.
The probability of a winning streak of length n is the %Profit to the power of n:
Prob of a WinStreak (PWn) = %Profit n.
Then, the expected profit on an n-streak of winners is
Expected profit_S on = n * average profit trade.
Below the probability curve of an n winning streak in a system with 58% profits. Worth noting is that this is the probabilistic curve on all systems showing 58% winners.
Fig 3 – Probability of a Winning Streak of Length n in a strategy with 58% winners
Loss trades (% of total)
The number and per cent of unprofitable trades. This value is computed subtracting 1– %Profits. This figure allows to directly compute the probability of a losing streak the same way we did before with winners.
Prob of an n Losing streak (PLn) = %Lossn
And its expected loss on that streak will be:
Expected loss_S = n * Average loss trade
Below the distribution on a system with 42% losers
Fig 4 – Probability of a Losing Streak of Length n in a strategy with 42 % losers
Therefore Using %Profit (and %Loss), we can create a distribution of run-up winners and drawdowns, as an alternative to a full Monte Carlo simulation. This way we can get a more in-depth insight into what to expect of the system in term of run-ups and drawdowns with just this parameter.
Fig 5 – Probability of a Winning Streak of Size N x meanProfit with 58 % winners
Fig 5 – Probability of a Losing Streak of Size N x meanLoss with 42 % losers
Above, the probability distributions of winning and losing dollar streaks of a system with 58% winners, normalized to the risk taken called R, that is similar to the average loss
These graphs were created by a very simple program using Python and plotted using matplotlib.
Example of Expected Max Drawdown and its Risk
As an example Let’s assume that the average loss of a certain trader is 500 € using this 58% winner system. Then, looking to fig 5, we can observe that there is about a 2.5% chance the trader will reach a 5R drawdown. It seems a small chance but a %R will surely be touched someday in the future.
Therefore, if his account balance is $10,000, there is a 2,5% chance that it will reach a 2500 € loss, or 25% drawdown.
If he decided to increase his risk to 1,000 € per trade, he’d end up someday with 50% drawdown in his account. That is fine and good, provided he is willing to accept it.
Also, maybe he is prudent, so did the risk computations shown in the above graph. Looking at it he decided he doesn’t like a 2.5% chance of a 25% max drawdown. He wanted no more than 15% drawdown. What should he do?
He should reduce the size of his trades so that 5XR = $1500, which is 15% of his account balance. therefore his risk N = 1500/5 = $300.
As we see, this kind of analysis is much richer than a mere maximum drawdown measure, because we know the actual probability of a drawdown of length n and its monetary figure, which is tightly connected to the maximum risk per trade.
Outliers and Averages
Largest profit trade: We should to examine large trades and evaluate if they are lucky outliers. We must determine their weight in the profit curve. If our profit is made by a small number of random outliers, and the rest of the profitable trades are just break-even, we should be careful about the future profitability of the system.
Largest loss trade
The Largest losing trade hints about the positioning of out stop loss levels. If we see occasional but extended losses, we need to verify if we suffer from gaps or spikes that needed to be corrected.
Average profit trade
Results from dividing the Gross profit by the number of profitable trades. A key metric to be used in combination with the Maximum Streak computational method described above.
Average loss trade
Results from the division of the Gross loss and the Number of losing trades. The average loss is a measure of the mean risk per trade. Traders need to be conscious of the connotations of this figure. They to be psychologically prepared to withstand between five to ten (some systems over twenty) consecutive losses, and its inherent risk, as previously explained.
Maximum consecutive wins (profit in money)
The longest streak of successful trades and its total monetary value.
Maximum consecutive losses (loss in money)
The longest streak of losing trades and its total monetary value. As in the previous point, this figure is better studied applying the statistical method described above.
Other convenient parameters might have been handy (but not included):
Standard Deviation of the Expected payoff
This value is only measurable if we export the results list and making the calculation on a spreadsheet or Python Jupyter notebook.
The ratio of the mean winner to the mean loser, easily computed since these two values are shown.
Sharpe ratio or similar quality metric
Obtained from Expected payoff and its Standard deviation.
T-statistics that may help determine if the system has some statistical validity or it’s close to a zero-mean random system.
Saving the strategy report, and, then, using Excel or Python, a Trader can perform additional evaluations such as those mentioned in the above paragraphs.
It will take a bit of effort the first time, to build the script, but it will reward us with a continuous stream of fine details that no simulator shows.
Building Winning Algorithmic Trading Systems, Kevin J. Davey
Encyclopedia of Trading Strategies, Jeffrey Owen Katz and Donna L. McCormick