## A Switch, a Switch, My Kingdom for a Switch: Changing Trading Logic in Algorithmic Trading Strategies

If you have been reading my blog posts about adaptability and walk forward analysis (WFA) it may be clear that a fundamental characteristic for truly adaptive and successful WFA is the use of adversarial trading logic sets. By using adversarial logic sets, a trading system will be able to adapt to changing market conditions if – and only if – these conditions generate an inefficiency with the opposite conditioning and these conditions last enough for profit to be made. However the new implementation of adversarial logic sets generates a conflict – related to switching – as it becomes problematic to either trade one or another technique. Today I would like to expand on the topic of switches and why the most obvious choice – binary switching – is most likely the poorest way to decide which trading technique to use.

When you have a trading system with an option to trade an adversarial logic (to trade in the opposite way as it normally does) you face the problem of changing from this logic its opposite twin as market conditions start to change. The simplest way to implement this idea in WFA is to switch the trading logic by analysing optimization periods and deciding when the selection criteria points to the other trading technique. If you’re trading a breakout technique – for example – you will start to see a point where the fading technique generates a better profit than the breakout and this is going to be the time to change. This will work very well provided that the change develops in a fast and quasi-permanent manner. If you come to a point where market conditions change dramatically and you make the switch, you will only have a small draw down period – the part where the market changed – and you will then move into a new period of profitable trading.

This is however a special case but it is not even close to the best way in which the above can be implemented.  First of all it is important to consider that the market is not binary in nature, it is not true that if one technique doesn’t work the other will. From a statistical stand point we must remember that the reverse of a system without an edge does not necessarily grant an edge, due to the fact that trading costs (spread, slippage, etc) exist. Therefore it becomes fundamental to consider what happens when neither of both trading techniques work and how the system would behave under such circumstances. Under this scenario a system would be “split” in a dichotomy between both worlds, choosing either technique due to small differences.

A binary switch (simply on/off) is therefore a poor choice because either trading A or B makes the system take a very strong position although market conditions might not grant one. In essence the market may sometimes show that neither of both choices is a good one and that perhaps an intermediate point between the two is the most prudent thing. This introduces us to the notion of “fading” switches in which the trading logic of a system is not changed dramatically from one side to another but it is gradually changed in a way that – if the efficiency totally shifts – leads to an implementation of the adversarial trading technique. It is also important to keep in mind that doing this through lot sizing is NOT a good thing to do as this introduces granularity issues.

What we would want to do is to simply trade both techniques in a way that ensures proper distribution between the profit potential of both trading techniques. In my mind the best way to achieve this would be through a game theory approach – and yes, I am now deep into game theory ;o) – that would assign weights depending on the number of acceptable criteria outcomes in the parameter space, these weights would then determine whether individual trades can or cannot be executed. If  for example I was choosing profitability as a WFA criteria I would then assign weights depending on how the profitability of the best outcomes for both cases (although the nature of the exact form of the  functions used to assign weights is also a matter of discussion). After this I would then simultaneously track signals from both parameter sets and execute according to the weight probabilities of the strategies.

With this in mind you would have a fading switch that would completely shift to one criteria only when the profitability of the other one is non-existent. While the probability to achieve profits from an adversarial technique exists, there will be a probability to trade it. This concept can also be extended to larger logic spaces in which the choice of trading technique is not limited by a single adversary. A genetic based approach can have N trading techniques with N adversarial techniques and they can all be traded through their virtues as showed by the WFA analysis. In essence you would be trading a game theory portfolio within the WFA selection. I believe this might be the best way to carry out switching in WFA as this will enable simultaneous use of different techniques without the granularity issues posed by a lot size weighting approach (which is dramatically sub-optimal).

If you would like to learn more about trading system and how you too can learn to design and create trading strategies  please consider joining Asirikuy.com, a website filled with educational videos, trading systems, development and a sound, honest and transparent approach towards automated trading in general . I hope you enjoyed this article ! :o)

### 2 Responses to “A Switch, a Switch, My Kingdom for a Switch: Changing Trading Logic in Algorithmic Trading Strategies”

1. Chris says:

Daniel-

As long as lot size doesn’t fall below 0.01, I don’t see why varying lot sizes based on recent historical outcodes would not work.

In theory, we could trade opposing systems at same time (different instances) and (assuming either system is making money) when a system is winning, we up the lot size. When is not winning, we lower the lot size or stop trading it. I think this can be done easily in MT4 which is not the case for multi-period WFA analysis.

Granted, the recent past is not always a great indicator of the future, but I can’t think of any better ones since market conditions seem to persist over weeks and months from what I have seen.

We will clearly make less money during winning times than we would without this method, but it may help us to survive losing periods that would knock all but the most persistent of us out of the automated forex trading game. I’m working on some ideas and should have some comparative back-tests ready by the weekend.

Take care,

Chris