If you enjoyed this content, I’m launching a new algorithmic finance newsletter, called Algo Fin, that you might be interested in. This newsletter will explore the connection between data science and finance, with an initial focus on the currency markets, but I hope to build many more avenues in the future. The newsletter is free to join currently as I am still planning a launch for paid subscribers, so if this sounds like something you might be interested in, its definitely worth checking out here!.

In the fourth article of this series, we will continue to summarise a collection of commonly used technical analysis trading models that will steadily increase in mathematical and computational complexity. Typically, these models are likely to be most effective around fluctuating or periodic instruments, such as forex pairs or commodities, which is what I have backtested them on. The aim behind each of these models is that they should be objective and systematic i.e. we should be able to translate them into a trading bot that will check some conditions at the start of each time period and make a decision if a buy or sell order should be posted or whether an already open trade should be closed.

Please note that not all of these trading models are successful. In fact, a large number of them were unsuccessful. This summaries series has the sole objective of describing the theory behind different types of trading models and is not financial advice as to how you should trade. If you do take some inspiration from these articles, however, and do decide to build a trading bot of your own, make sure that you properly backtest your strategies, on both in and out of sample data and also in dummy accounts with live data. I will cover these definitions and my testing strategies in a later article.

TheoryIn signal processing, a filter is a device that removes “unwanted” components from a signal. It removes certain frequencies from the signal that are considered background noise in order to paint a clearer picture of the true underlying signal.The are four broad types of filters and they are defined by the types of frequencies they allow to pass through and those that they therefore exclude.

  • low pass filter will, as the name suggests, allow low frequencies to pass through and reduce the significance of the higher frequenciesA high pass filter will do the opposite, allowing high frequencies to pass through and reducing low-frequency impactA bandpass filter will allow frequencies to pass through that are within a pre-defined band. We supply a minimum and maximum frequency value to our filter and it will only keep those values that fall withinA band stop filter also requires a minimum and maximum value, but will pass all frequencies that are either greater than the maximum or lower than the minimum, essentially all the frequencies a bandpass filter would not allow

_There are, of course, more sophisticated types such as notch filters (filters than reject a specific frequency) or comb filters (a series of regularly spaced band filters), but for the purpose of introducing this topic, we will stick to the fundamental concepts._ApplicationThe Butterworth filter was first introduced by the physicist Stephen Butterworth in 1930. I won’t go into all the technicals of how this filter works, but the most important feature about it is that it is a low pass filter. The Butterworth filter aims to produce an output that is as flat as possible, ignoring the high frequencies and returning the lower ones. It has been found that this filter is an ideal one for use in the world of forex trading because we want to see the general underlying “low frequency” cycles. We want to remove the high-frequency movements, as this is what we might consider as just noise.

_When we look at a chart, we start to see the scope for where this might have an application. As you can see, in the GBP/USD closing prices for the last 18 years, we see a lot of minor fluctuations around general price trends. If we were long or medium-term traders, we wouldn’t be interested in these fluctuations occurring around the trend, but we want the trend itself. One method to see the underlying trend is to use a moving average, which is useful, but is also a lagging indicator. The benefit of a filter is that it removes frequencies in real-time. We can see trend continuations and reversals immediately, making it easier for us to make trading decisions as close to these changes as possible.Python’s SciPy package has an option for us to easily run a Butterworth filter. You can find the documentation _here, but if you don’t come from a Physics background, you can look at the unknown values as parameters that we have the option to tune.

Naturally, our frequency cutoff must be less than our frequency value, but it is these two values and the order of the filter (the first argument to the signal.butter() method) that we have the opportunity to tweak. To find the best set of frequencies, cutoffs and order is simply a case of testing different values and finding the one that best follows our data. Plotting the output against the closing price will our visual measurement for how well our model performs. If we wanted a more mathematical evaluation, we could look at the correlation or R² value between our two variables.

#algorithms #forex #algorithmic-trading

Algorithmic Trading Models — Cyclical Methods
1.30 GEEK