Crypto Trading Backtest

Test your strategies with historical data

Trading Strategy: uses predefined indicator rules (for example moving averages, RSI, or momentum) to generate buy/sell signals directly from prices and then backtest their performance.

Machine Learning Model: trains a model on historical data to predict the direction of returns and then backtests trades based on those predictions.

Weights describe how much of your total capital you allocate to each asset. For example, BTC= 0.6 and ETH= 0.4 means 60% of capital is traded in BTC and 40% in ETH.

Total weight: 1.00
BTC=
ETH=
XRP=
LTC=
BCH=

Strategy Settings

Moving Average Crossover: compares a short-term and long-term average of the price. When the short-term average is above the long-term average the strategy stays long; when it is below, the strategy goes short.

Number of days for the fast moving average (reacts quickly to price changes). Default is 5 days, a short horizon for recent price moves.

Number of days for the slow moving average (defines the overall trend). Default is 20 days, a common choice for a slower trend signal.

Trading rule (Moving Average):

  • We first compute two moving averages of the closing price: the short MA is the average of the last Short Window days, and the long MA is the average of the last Long Window days.
  • Each day we compare the short-term and long-term moving averages of the price.
  • If the short moving average is above the long moving average, the strategy sets the signal to +1 (target long position).
  • If the short moving average is below the long moving average, the strategy sets the signal to -1 (target short position).
  • If there is not enough data yet, or they are equal, the signal stays 0 (no position).

In this backtest, the chosen strategy generates a daily trading signal for each asset: +1 means a long position, -1 means a short position, and 0 means no position. The portfolio backtester then uses these signals together with your asset weights, stop loss, and initial capital to open, close, or reverse positions over time and compute performance metrics.

Fraction of loss from the entry price that will close the position. For example, 0.05 means the trade is closed if it loses 5% of its value. This demo only implements a stop loss; there is no separate profit-taking level.

Total cash used for the backtest. Asset weights determine how this capital is split across different assets when trades are opened.

If a stop loss is never hit, the position stays open until the strategy generates an opposite signal (for example when the moving averages cross in the other direction). There is currently no explicit profit-taking threshold.