Optimizing your Algo

You have created a trading algo. The Algo is profitable in the backtester. Before unleashing it with real money, you’ve got to first tighten the screws. That is, ensure your algo is fine-tuned so it can deliver optimal returns. There’s one major challenge ahead of you.

Firstly, your strategy is rather simple. You may go through the detailed process of building and optimizing a strategy, including curve fitting, correlation and so on. But you want a simpler process; something leaner, that will fit your modest needs.

Secondly, you may not yet have mastered the full technique of optimizing. You are still learning and want to try off with a simple process.

One technique I find especially simple in optimizing your algo is probability. The probability method, in essence, contains many components of a full optimization technique. However, it tends to rely more on common sense and logic to narrow the options and optimise the algo. That makes it a pretty good way to begin the entire concept of optimizing a strategy. Moreover, you will find it easier to digest.

The essence of the strategy—optimize by elimination.

Algo Case Study

The following Algo is a simple one. Let’s call it RSIMV which is RSI and Moving Average. Here is what RSIMV describes through conditioning:

If Open Positions = 0 then
If (MA(30)>MA(14)) and RSI= Open Buy (50,000) {It will buy 50 lots}
Set Stop Loss = Price – 50{Pips}
Set Limit= Price+ (50*2)
End

The strategy: If the moving average cross points on a bullish trend and the RSI is equal or below 60 it means that the rally has some length before reaching an oversold level (RSI above 80). That points to a good buying opportunity.

Looking at RSIMV, you can conclude there are four parameters to optimize: RSI and two Moving Averages.

Starting with the Moving Averages, we will look at the 14 and the 30 days. Seemingly, the options are endless, with many combinations of moving averages to test. In theory, that is correct, but that is where probability comes in.

OneSteo

When we look at the chart, we can see that the longer the averages (orange and red) the lesser the chance that there is a combination of a low RSI and a bullish momentum.

Moreover, a combination of a low RSI and a bullish signal only occurs when the two averages, the fast and the slow, have more or less a 2 to 1 ratio (such as a 30 and 14).

Those two conclusions help us narrow the parameters we are looking for.

The highest likelihood of finding a better set of averages is with faster averages, not slower, and those that have a ratio of 2 to 1. And let’s not forget we already know that 14 and 30 works. So we shouldn’t move too far up the scale.

We will use 25 and 12 as the first combination and 20 and 10 for the second. Both are faster than the original parameters, have a roughly 2 to 1 ratio, and are close to the original settings.

25,12
20,10

into the RSI parameter, narrowing the options is even simpler. We know the RSI cannot possibly be higher than 60, because then we will be left with insufficient upside before the pair turns oversold.

On the other hand, if we try an RSI below 40 it’s unlikely that it will occur while the moving average cross is bullish.

Since, as in the Moving Averages case we know the original setting worked, we know we only need a minor tweak. With no way to go but up we are left with two reliable options – RSI

Hence our options are:
C) (55)
D) (50)

As we can see from testing all the alternative parameters, what we needed was a better entry for the RSI. As we intended… minor tweaks.

OneStep2

Don’t Optimize Too Much

Ironic as it may sound, optimization sometimes has a downside. At times, we are tempted to over-optimize to such an extent that our newest strategy no longer resembles our original, pre-optimization plans. That can throw us into an eternal loop and waste precious time. Don’t be tempted! Don’t fall in love with the optimization process. After all, optimization is merely tightening the screws, not building the engine. If your strategy works, confine your optimization to minor tweaks. If it doesn’t, optimization won’t help and you’ll need to start from scratch.

And, finally, a practical tip; always keep records of the results of your original strategy and compare it to your current, post-optimization strategy. This way you can always make sure that you’ve really optimized your strategy.

The Bottom Line

Sure, the optimization technique isn’t perfect. But the take away here is that if you really understand your strategy, you can use logic to in order to find better settings. If you’re a beginner and lack the knowledge for advanced optimization techniques, optimizing through the logic of probability is a powerful tool to have.

2 Likes
1442 Views

You may also like

Leave A Comment

Please enter your name. Please enter an valid email address. Please enter message.

Sign-up






* = Required Field