Moving averages crossover simulator on bitcoin
Choose the averages, run the backtest in the last 365 days of BTC and compare with simply buying and holding.
Waiting for dataIn short: This simulator pulls the daily bitcoin history of the last 365 days at CoinGecko, applies the classic moving average crossing strategy (buy when the fast average crosses the slow upwards, sells when crossing down), and compares the result with the buy and hold, including Drawdown, costs and the list of trades. It serves to learn, not to predict.
How to use the simulator
- Choose average typeSimple Average (MMS) gives the same weight every day. Exponential Average (MME) gives more weight to recent days and reacts faster.
- Set fast and slow averageThe quick one needs to have fewer days than the slow one. Combinations known as 9 and 21, 20 and 50 or 50 and 200 are in the shortcut menu.
- Inform the cost per operationPut the fee you would pay for each purchase and every sale. Consult your broker's table; When in doubt, test different values to see the effect.
- Rotate and read the cardsCompare return, drawdown and purchased strategy time with Buy and Hold. Then look at the trades table and triangles on the chart.
If CoinGecko is down or blocking access for excess orders, a field appears for you to paste your own closing prices, one per line. So you can test the same logic with data exported from the TradingView, from a spreadsheet or another asset.

How the calculation works
The tool asks CoinGecko's public API for the 365-day history of Bitcoin in dollars. According to CoinGecko's documentation, when the requested interval exceeds 90 days, the API returns one point per day, referring to 00:00 UTC. The simulator saves a price per date and discards duplicates, such as the last point, which is usually the price of the moment.
With this series, it calculates the two averages. The simple average is the sum of the last n closures divided by N. The exponential average starts with a simple average and, from there, each new value is the price of the day multiplied by k plus the previous average multiplied by (1 minus k), where k is 2 divided by (n plus 1). It is the standard formula described in Wikipedia's entry of moving averages and used by most platforms.
The operating rule is simple. The test only starts when the slow average has enough days to exist. From then on, if the day before the fast average was below or equal to the slow one and today it is above, the simulator buys with all the capital at the end of the day. If the opposite happens, it sells everything. There is no short sale: outside the position, the money is stopped in dollars, without income.
Costs, Buy and Hold and Drawdown
The cost informed is deducted from each purchase and every sale. The Comparison Buy and Hold buys only once on the first day of the test, pays the same entry cost and secure until the end. So the two start from the same point and the comparison is fair.
The maximum drawdown is the biggest drop in capital from an earlier top, measured day by day. A strategy that yields a little less than the Buy and Hold, but falls much less along the way, can be easier to follow in real life. To study this number in depth, use the drawdown calculator.
| Metrics | What shows | How to read |
|---|---|---|
| Strategy return | Capital variation from start to finish | Always compare to the buy and hold of the same period |
| Maximum drawdown | Worst fall from a top | How much would you have to bear without giving up |
| Trades closed with profit | Percentage of winning operations | Trend strategies tend to get a little right and earn a lot in the hits |
| Time purchased | Days positioned above the total | Less time exposed means less risk, but also less participation in high |
Simple or exponential average?
MME reacts faster to price changes, so it tends to generate signals earlier and also more false signals on the side market. MMS is slower and more stable. None is better in all scenarios. Rotate the two with the same periods and see how the number of trades and the drawdown change. the guide of moving averages Explains the differences with examples.
How to interpret the result without being fooled
- Few trades, little confidence. In a year, long averages generate few crosses. With three or four operations, a single good or bad trade decides everything.
- Test period shortens with long averages. With a slow average of 200 days, there are only about 165 days of testing left within 365. The simulator shows the exact dates.
- The chosen year weighs heavily. Trending strategies shine through years of strong trends and suffer in the lateral market, when the price crosses the averages several times.
- Execution at closing is optimistic. In practice you would see the signal at the closing and run later, with spread and slippage. So the real result tends to be worse.
A common mistake is to test dozens of combinations and choose the one that made the most money. this is excessive adjustment to the data, the famous Overfitting in Trading. The one-year champion combination usually disappoints in the next. Prefer simple rules that work reasonably in various periods and assets, and validate outside the sample, as explained in the backtest.
What the simulator does not consider
- Slippage, spread and difference between CoinGecko's reference price and your brokerage's price.
- Taxes, which in Brazil can focus on earnings from crypto, as explained by the Cryptocurrency Income Tax.
- Operations sold and leverage. With leverage, a drawdown here seems tolerable can settle the position.
- Cash income stopped in periods outside the market.
- Regime changes: Bitcoin's behavior in one year does not necessarily repeat itself in the next.
From Simulator to TradingView
If the rule makes sense to you, the next step is to test it with more history and other deadlines. The Strategy Generator in Pine Script Assembles the average crossing code with stop and target, ready to paste in TradingView and run on Strategy Tester. If you want to understand each line of the code, follow the Pine Script Tutorial.
Those who already have a validated strategy can transform the TradingView alerts into automatic orders, carefully redoubled with position size. The step by step is in BingX Signal Trading with TradingView, and risk control per operation is in the Risk Management in Trading.
Automate only after validatingAt BingX you connect TradingView alerts to orders, but start small and with a stop set.Start nowTransparency: The Boletim Bitcoin can receive commission for registrations made through BingX's links, at no extra cost for you. That doesn't change what we write about risks and costs.
Frequently asked questions
Does the simulator use real bitcoin data?
Yes. He searches CoinGecko's public API for the daily price of bitcoin in dollars over the last 365 days. If the API fails, you can paste your own prices.
What is the best combination of moving averages?
There is no better combination in all periods. The one that wins in one year usually loses the next. Test few combinations and prefer those that work reasonably in various scenarios.
Why did the strategy lost from Buy and Hold?
In years of strong high, leaving the market at each bearish cross makes you lose part of the climb. The advantage of the averages usually appears in the reduction of drawdown in long falls, not in the return.
Does the simulator do sold operations?
No. He only buys and sells what he bought. Outside the position, the capital is stopped in dollars, without income and without leverage.
Can I use the result to operate?
Use as study. One-year backtest does not guarantee future results and ignores slippage and taxes. Validate in more periods and operate small if you decide to test live.
References
This content is informative and is not an investment recommendation. found an error? Write to contato@boletimbitcoin.com.