Let’s create a more sophisticated strategy now.
We are going to use two artificial neural networks to predict the relationship between the German largest 30 stocks (DE30EUR) and the u.s. top 30 stocks (US30USD) on the euro US dollar exchange rate (EURUSD). Once you’ve imported the three instruments into Algominr you can create a new strategy and set its name. Also make sure to change the trade hours of the strategy to when the market for the relevant instruments are actually open (for me this is 9:00 am to 5:00 pm).
For the strategy we will combine the predictions from two artificial neural networks by using a logistic regression node. So change the Linear regression node from the strategy template to a logistic regression node. Set the prediction shift to 90. This will make the strategy use the prediction to forecast price changes 90 minutes into the future.
The inputs to the logistic regression node are going to be the combined signals from two NNet nodes. To combine the outputs of two nodes, we use the Combine node type. So change the Indicators node from the original template to a Combine node.
You now can change both of these new Bar Price nodes to NNet nodes that will hold the artificial neural networks.
Set the first one to predict the price movement in the next 120 minutes (set the shift parameter to 120). As an input to this NNet node we will again chose a combine node that combines both the indicators for the German top 30 and the indicators for the US top 30.
So this first neural network predicts the bar price based on both the indicator sets (DE30EUR and US30USD) for the next 120 minutes.
Now change the second Bar Price node (which is an input to the combine node feeding the logistic regression) to a NNet as well and repeat the process. But instead of setting the prediction time (shift) to 120, set it to 60 minutes.
That’s it for the strategy logic. It creates two predictions, one for 120 minute price movements and one for 60 minute price movements. The logistic regression then combines both predictions and creates a signal for a 90 minute trade.
The next step is to train and test the strategy. Click on the Train/Test button and let it run the backtests. This may take a moment, depending on how many bars you have imported for all the symbols.
Once the process has finished, switch to the simulation tab to see how well it performs.
On the left hand side, you can see the results within the training sample period. The strategy seems to be performing quite well there. But we can see that it doesn’t work as well in the testing window. We have a slightly positive return including transaction costs actually, but it’s not that amazing.
So the rest of the work is to find the right parameters for all the nodes. The first thing you might want to try is to change how large of a price change will actually trigger a trade signal. Often transaction costs (or the spread), will eradicate most of the profits. To address this we can trade less frequently, focusing on larger price changes.
So change the threshold parameter in the logistic regression node to something like 0.0002
For the changes to show up in the simulation results, train and test the strategy once more.
Now we have a Sharpe ratio of 1.35 which isn’t too bad for 10 minutes of work. The total return of course is still very small. However, at the moment we’re only trading 10,000 units of EURUSD (1 lot). This of course will only lead to very small returns on an account with 100’000 USD (as set in the strategy settings). So for a last step, lets increase the trade size and train and test again.
If the order size is set to 100’000, the annual return becomes 15%. Now you can further improve on this strategy by selecting the right parameters, but I will leave that to you.
Before going live with such a strategy, you should of course test it on more data. Also start with a paper trading account, so that you can evaluate it’s performance with your own broker and spreads.