Machine learning for Bitcoin trading

Bitcoin and other cryptocurrency markets are still a very recent development. Traditional traders have not yet fully exploited this new environment. This makes cryptocurrency markets a perfect application for machine learning trading strategies.

In this short post, I will show you how to apply Algominr to create a Bitcoin strategy.

Note that Algominr will not get access to your wallet, but you will rather trade through a broker of your choice.



At the current stage of development, Algominr requires Metatrader 4 (a trading client) to trade its machine learning strategies. There are several brokers which offer the Metatrader 4 client platform (short: MT4) in combination with cryptocurrencies. Additionally, most of them offer paper trading accounts, so that you can test your strategies without risking any real money. The following list provides a selection of brokers that support MT4:

There’s many more broker’s offering MT4 for crypto-trading. A more complete list can be found here.

Go to one of these brokers and download and install MT4 before continuing with this tutorial. When starting MT4 for the first time, you will be asked wheter you want to create a demo or a live account. Choose demo account for now. This will create a virtual trading account that let’s you try your strategies without risking any real money (or bitcoin).

That’s it for now in MT4. Next, please download and install the current version of Algominr.

Now it’s time to connect MT4 and Algominr. Just follow this short Tutorial:

Setup Algominr

Data Import

To import the bitcoin symbol into Algominr, add a new Instrument on the left hand side of the Algominr interface. Click on the button with the + sign

and select BTCUSD (or any of the other cryptocurrencies, for simplefx they are quite far down in the list)

Click on import to import the BTCUSD symbol.

Next we will want to create a strategy that trades Bitcoin. In the top left, you have a basic strategy created from a template:

First let’s change these settings to be more suitable for bitcoin. Set the Strategy Name to BTCUSD_S1 and hit enter.

Next, set the order size to 1and hit enter. This will make the strategy trade 1 Bitcoin per trading signal. Leave the rest of the settings as they are.

Strategy Logic

Now switch to the logic tab where you can see the strategy logic

Our first bitcoin strategy will be very simple, as we’re going to use a random forest (a popular machine learning method) to predict wether the price moves up or down in the next 60 minutes. To do this, we will change the Lin reg node to a RForest node. Click on the circle item on the Lin Reg node.

In the popup, click on the Predict category and choose RForest. Make sure to set the Num features parameter to 4, the threshold to 0.01, the shift parameter to 20 and activate the Balance train sample feature. This will predict the bitcoin price change 20 minutes into the future. When done, click add.


Next, make sure that the Market B/S node, the Indicators node, as well as the Bar Price node, all use the BTCUSD instrument. (Click on the circle icon of each of the nodes and check the settings)

Next we will need to train and test the strategy on historical data. So click the Train/Test button on the right hand side of the Strategy view.

This will activate the Simulation tab, where you can see how well your strategy works on historical data.

As you can see, with this very simple strategy and a little machine learning, we can create a profitable strategy with very little effort. You can now click Deploy to start trading the strategy with your MT4 demo account.

Let me know if you have any comments or questions. Also check out these youtube videos to learn more about Algominr and what strategies you can create:


Leave a comment

Your email address will not be published. Required fields are marked *