# Monte Carlo Simulation

A Monte Carlo simulation is a computational algorithm that repeatedly simulates an event. Each repeat or ‘simulation’ randomly samples certain variables to obtain a result. After multiple repetitions, the results are normally averaged to provide a probability or average result. Monte Carlo simulations are used in many fields such as engineering, science, and finance when other approaches are impossible to use due to the presence of random variables. Monte Carlo simulations can be used to better explain risk in financial forecasting models. The results should be interpreted as an estimate, based on past or simulated data. Monte Carlo simulations cannot predict the future but they can help us better understand or prepare for what might happen.

##### info

We are developing the backtesting engine with capabilities to simulate with the Monte Carlo method.

## A Crypto Monte Carlo Simulation Example

Let’s say, hypothetically, we want to evaluate the performance of an Ethereum trading signal that we have developed. For this evaluation we have 5 years of daily historical Ethereum prices, and know that our trading signal may output either buy or sell commands based on this pricing data. We therefore develop our Monte Carlo simulation to iterate through each day’s data and simulate either buying or selling Ethereum. At the end of the simulation we output a numerical result, in this case a total % profit.

### Random Variables to Simulate

In theory the Monte Carlo approach can be used to simulate almost anything, each time randomly selecting a different value(s) for a random variable(s). In this hypothetical case however, the most interesting random variables to simulate would be the start day of the simulation and the end day of the simulation. Crypto markets are extremely volatile and any potential trading or investment profits are very much affected by when one buys in or cashes out. A good marker for a robust trading signal would therefore be a trading signal that performs well over multiple different time frames within our five years of historical data. Therefore, we repeat each simulation, buying and selling Ethereum each day based on our imaginary trading signal and returning % profit, for ‘n’ different randomly selected time periods over the past five years. Typically, ‘n’ is a large number (> 10,000).

### Understanding the output of a Monte Carlo Simulation

After we have run ‘n’ simulations of our hypothetical trading strategy we are left with a list of ‘n’ total % profit values. Where each value is the total % profit returned by the simulation for a specific, randomly selected time period. In this example, as a final output we could return the mean value of total % profits achieved by the ‘n’ simulations. We could define this final output value as the expected average % profit for the trading signal we are testing.

### Understanding what our Monte Carlo Simulation tells us

The Monte Carlo simulation is now finished and we have our output value. However, we still have some work left with regards to thinking about how we want to interpret our output value. Is it a good output value? Is the trading signal a good signal? We might be tempted to answer these questions based simply on the size of the value, if it is a large positive number then we could just say assume that it’s a great signal! Normally though it would make sense to compare this value to another output from another Monte Carlo simulation where perhaps the trading signal itself is replaced by a random variable. This way we could compare the two values and better quantify how much useful information our trading signal is telling us compared to random noise. Paired sample T-testing could also be deployed at this point.