top of page

My second Expert Advisor: Wavelet-Touchdown

  • Autorenbild: Wissam
    Wissam
  • 30. Okt. 2022
  • 5 Min. Lesezeit

I would like to give you a detailed description of my second trading algorithm called "Wavelet-Touchdown". I have been working on this project for 2 months and it will take a few more months to complete it.


Here is the download link of the algorithm: <https://files.fm/u/awbbpmfq>

An include-file is attached, which provides the underlying classes and functions of the algorithm. This algorithm is compatible with hedging-accounts. To be able to use this algorithm for netting accounts as well, some small changes have to be made.

This algorithm follows a clear strategy based on three different indicators, which are individually generating a sell- or buy-signal. Here is the explicit conceptual design of this algorithm. First of all, here are the individual decision making processes of the used indicators:


1. On-balance-volume indicator (OBV).

This volume indicator puts the price and the trading volume in relation. A case distinction is necessary to determine the last OBV value t. Depending on whether the closing price of the current candle is larger, smaller or equal to the closing price of the immediately preceding candle, the following recursive calculation results: a) Current closing price> previous closing price, then OBV (t) = OBV (t-1) + Volume (t) b) Current closing price <previous closing price, then OBV (t) = OBV (t-1) - Volume (t) c) Current closing price = previous closing price, then OBV (t) = OBV (t-1).


Then a exponential moving average is placed on this indicator (period: 30). Let EMA(OBV,30,t) be the value of this exponential moving average on value t.


Now we have all the tools that contribute to signal generation:

Buy-signal: OBV(t) < EMA(OBV,30,t).

Sell-signal: OBV(t) > EMA(OBV,30,t).


This decision-making process is visualized again in the following figure.






















2. Average Directional Index-Indicator (ADX). The ADX is used to determine when the price is trending strongly. In other words, it is a indicator for the momentum. It comes with 3 lines. The main line (ADX itself) is calculated by the other two lines: directional strength of positive and negative momentum (+DI and -DI). The main line helps us identify the strength of the trend while +DI and -DI helps us determine the trend direction. "Wavelet-Touchdown" wants to find real momentum and reacts to the crossing of +DI and -DI. If the ADX is high enough, a signal is generated right after the above mentioned crossing:


Buy-signal: +DI and -DI cross each other, where +DI has a higher value than -DI after crossing. The ADX itself is higher than both lines.

Sell-signal: +DI and -DI cross each other, where -DI has a higher value than +DI after crossing. The ADX itself is higher than both lines.


The following figure shows this chart-attached indicator. The blue line is the ADX and +DI/-DI is displayed in green/red.

3. Bollinger Bands (BB). The Bollinger Band is one of the simplest and most effective trend-following indicator, which takes charge of the volatility. Based on the normal distribution, it is assumed that current prices are more likely to be near the simple moving average (middle line) of past prices than far away. If the Bollinger band has a deviation of sigma = 2 in a fixed period, than we have a ~98 percent chance that the incoming price is within the band. For sigma = 0.6 the chance is only ~73 percent.


Let BB(20, 2) be the Bollinger Band that has a period of 20 and a deviation of 2 and

BB(20, 0.6) the Bollinger Band that has a the same period and a smaller deviation of 0.6.

Now we have a probablity of (98%-73%) = 25% that a incoming price is in BB(20, 2) but not in BB(20, 0.6) based on the normal distribution assumption.

Order executions in these two touchdown areas can be used profitably by assuming that the price is evening out towards the average price, which is represented as the middle line in the figure above. Now we have the Signals of the Bollinger Bands.


Buy-signal: Close(t) ∈ "Buy-Touchdown-Area"

Sell-signal: Close(t) ∈ "Sell-Touchdown-Area"


All three indicator signals are re-evaluated at every tick and only if they all point in the same direction will an order be executed with the appearance of a new candle.

Here are all the important adjustments to this strategy that can be defined by input variables:

  • This algorithm risks 5 percent of the account balance on every trade (high risk).

  • Trades only on the appearance of a new bar (bool TradeOnNewBar = true).

  • The wider Bollinger Band defines the stop loss and take profit if the calculated stop loss of 125 points and calculated take profit of 300 points is further away from the opening price than the wider Bollinger Band.

  • This algorithm uses trailing stops. The trailing stop is set to 125points at a minimum profit of 80 points. A new trailing stop is calculated on every 10 point step.

  • The ADX-period is set to 10. This is resulting from a backtesting/forwardtesting optimization.

  • The trade allowing Timer is set to 8 a.m. - 6 p.m. (server time).

  • The allowed slippage is set to 3 points. This guarantees only 3-point-price differences between the order sending price and the actual executed order price.

  • Only one open position is allowed.


The following improvements will be made by me in the future:

  1. Applying wavelet analysis (see text below).

  2. Timer should be switched off X minutes before and X minutes after a news feed.

  3. Search the market for the currency pairs with the highest liquidity and then trade on these selected Instruments.

  4. Do not use the standard deviation for the Bollinger Bands, but the EMA deviation. That makes it faster in responding to market volatility.

The "Wavelet-Touchdown" algorithm is not yet done. One essential thing is missing, namely wavelet analysis. The following was noticed when testing the above touchdown strategy: Incorrect entry signals are often generated because local and high-frequency price changes lead to short-term misinterpretation of indicators. For example, the ADX-signal can have several shortterm crossings, which then lead to completely different signals. The Bollinger Bands can lead to misinterpreted signals in the event of strong short-term price changes (e.g. through relevant news) that lead to a new price level.


All of these short-term and high-frequency effects can lead to a trade loss in the above mentioned touchdown strategy. It is therefore of interest to eliminate such effects as much as possible (lets call it "noise reduction"). My way is to transform the price data and then use the indicators on this "manipulated" data. There are some mathematical tools that can do that, and one of these tools is the Wavelet transform, which is based on Fourier transforms.


I'm currently working on incorporating this noise reduction into the algorithm. There are some predefined functions in the Matlab software that perform this noise reduction:

The Matlab function cmddenoise determines the optimal number of intervals to denoise and denoise the price data. In this example, use the 'db3' wavelet and decompose the data down to level 3. For the experienced mathematican: 'db3' wavelets are orthogonal wavelet functions that have a compact carrier. This class of wavlets are among the most commonly used wavelets. Because of their easy implementation in Matlab - using the fast wavelet transform (FWT) - I have chhosen this class of wavelets.


There are several papers that confirm the efficiency of Wavelet-based algorithms. For example: "Bollinger Bands Trading Strategy Based on Wavelet Analysis" by Chen, Zhang, Zhou and Qin (<http://www.redfame.com/journal/index.php/aef/article/view/3079/3351>). They have shown that their Wavelet-based algorithm has greather returns, less risk and better applicability than the similar strategy without using any wavelet noise reduction (s, ca3, cd3, cd2, cd1) on the CSI300 stock index futures. The following figure summarizes the results of this paper:

RMB is the Chinese currency. One can clearly see that the profitability through wavelet noise reduction increases and the number of transactions decreases.



Best regards, Wissam
















 
 
 

Comments


Post: Blog2_Post

Subscribe Form

Thanks for submitting!

  • LinkedIn

©2020 Wissams FX-trading blog. Erstellt mit Wix.com

bottom of page