Sunday, December 7, 2014

OmiCronFX Mandelbrot algorithmic software development (Pt 3) | The trade trigger

We needed a methodology for triggering trades, even though we were and remain convinced that this is not the most critical part of designing the strategy. That distinction belongs to the risk reduction and capital retention aspects of it. One reason for this is that price movement can very often be counter-intuitive, even for an algorithm. Example: The RBNZ (New Zealand central bank) made an announcement in July 2014 to the effect that it was raising interest rates, which had been expected. This should have been a positive for the Kiwi (New Zealand dollar), and in fact it had been strengthening in anticipation. However, at the very moment of the announcement the rate for the currency against the US dollar plunged instead. We found out soon enough that the authorities in NZ wanted a lower exchange rate, and had gone into the markets to sell $NZ in order to make this happen. The best algorithm in the world, barring the possession of insider knowledge on the part of its developers, would not be able to envisage this type of circumstance. There are many other examples of a similar nature in the Forex trading business.

Notwithstanding the above, we needed a trigger for Mandelbrot. In our opinion a good place to start looking for this was in the area of moving averages of price over time. A great number of the popular Technical Analysis indicators already make use of these. Examples include MACD (Moving Average Convergence Divergence), Moving Average Envelope indicator, Bollinger Bands, Ichimoko Cloud, and Moving Average Crossover indicators. There are others, and even those that do not have MA as their primary base use it anyway. Stochastics, for example, uses it to smooth the results of the bar highs and lows it is based on, in order to make its triggers less volatile.

However, there is one problem with all of these: they are lagging indicators. This means that, very often, the information they give comes after the time at which it would have been beneficial to place a trade.

Acceleration: the rate of change of a rate of change

The objective of trading Forex at our level of investment is to be able to synchronise our buying and selling decisions with those of the larger institutions that actually move the market (Trillions of dollars are traded each day and moving the market is something we cannot do at this point in our development). Exchange rates wander about all the time, going up a little and then down a little. We are looking for trends, or relatively large movements in one or other direction.

It seemed to make sense, therefore, to try to distinguish between the rate changes during those quiet periods and their own rate-of-change when buying or selling picks up, which might have a better probability of signalling the start of a trend. In relation to determinate non-linear functions mathematicians call this the second derivative. For engineers it is the definition of acceleration in bodies that move relative to a reference point. It was developed by Isaac Newton and is notated as follows:



Where E (in our case) is the exchange rate and t is the time over which it changes. The letters d in each case indicate an infinitesimal change (a change in the limit).

The only issue here is that price action in Forex is not the smooth, continuous process that lends itself to Newtonian principles of mathematics and mechanics. While it might approximate these, there are also elements involved that manifest as sheer apparent randomness. One way to resolve this problem might be, we thought, to overlay Newtonian principles with chaos theory, which had been developed by Edward N. Lorenz for use in weather forecasting. We adopted the acceleration idea and to deal with the chaos strove all times to make sure that probability was well and truly on our side. This meant designing the trades so that there was always a positive expectation: a typical loss had to be considerably less in value than a typical win, and wins had to, ideally, outnumber losses. Each trading day must be meticulously analysed to determine if the trading software parameters, or even the software itself, should be adjusted or modified. Included here is the aspect of timing. For optimum position sizing we were guided by the Kelly Criterion. This was developed by J. L. Kelly in the 1950s for use in probability theory, and has been applied largely to gambling scenarios.

All of the above might seem like a lot of work, and indeed it is. All those adverts you see promising the ability to learn to trade Forex in a short time and by only devoting a few hours per day to it, in between doing something else, are making a false claim.

Benoit Mandelbrot was a scientist who did much work on the theory of fractals. His ideas have been used too, in order to move our trading from higher level time frames (4-hour and daily) where trades were few and far between, to lower level time frames (hourly and down to 10 minutes) so that we could have a larger number of trades. We have named the Mandelbrot routine in his honour.

As developed, the Mandelbrot strategy will not give a signal to buy or sell while the exchange rate is moving at a normal, uneventful pace. It is only when it accelerates from the casual rate that a trade will be considered. It uses a series of exponential moving averages to anchor what is regarded as normal behaviour. In practice, price can move up or down as much as it likes when going at a pedestrian pace, and it is only when its velocity moves outside of the norm that action will be triggered. A trade is likely to be terminated when the activity diminishes (although not in all cases), a condition that is classified as reversion to the mean. In the meantime the algorithm has a built in ability to reposition a dominant stop loss (there is normally more than one – recall our commitment to risk mitigation) so that it moves relatively closer to price over time as profits build. This gives it the best chance to get the maximum benefit from each trade. Mandelbrot also takes off some profit as a profitable trade progresses, and moves the trade into a break-even position as soon as possible, in accordance with our capital retention policies.

To be continued.

Coming soon:

Defining the trading strategy

·           Give the trade enough space to become successful but ensure that if this is ultimately not to be the case, the loss will be the smallest that it is possible for it to be

·           Risk control

                        * Eliminate the danger of taking on too much risk
                        * Lock in some profit as soon as it is worthwhile to do so, and move the main stop loss order to break even.
                        * Control of Stop Loss levels at the start of the trade and as it progresses

Coding and debugging the strategy

·           Some programmable platforms are better than others, but this is still a new industry outside of the major banks and hedge funds

Optimising the parameters

·           Historical research on the price action of different currency pairs
·           Simulated trading with historical data, and real-time trading
·           The place of Fundamental and Technical Analysis


No comments:

Post a Comment