Buhalich Flat Filter
Essence of the Idea
There are two ways to trade by trend. First is to determine the real trend direction by any means. Second is to use the simplest trend indicator (for example MACD), but not to trade when there is flat.
Buhalich Flat Filter is a powerful indicator for flat filtering at a price chart. It is based on idea of using several different algorithms of filtering in order to gain the best result. Four algorithms of flat filtering are combined in the indicator. First two may appear to be obvious when other are more interesting.
The Algorithm of the Indicator
Algorithm 1. The frequency of direction change of several moving averages of different periods is measured on some interim. The more often MA change their direction the more probable that there is a flat.
Algorithm 2. The inclination of several moving averages of different periods is measured on some interim. The less incline of MA the more probable that there is a flat.
Algorithm 3. The ratio between MA inclination and channel width is calculated. Indeed good trend usually described by big MA inclination concurrently with rather narrow channel. Small MA inclination concurrently with wide channel is customary for flat of high volatility.
Algorithm 4. This algorithm is used for big price oscillations filtering. The ratio between channels of different period is calculated. If you plot Bollinger Bands of small and big period on one chart when there is trend you will see that the small period channel is much more narrow than the channel of big period. When there is flat of high volatility the small period channel becomes wider up to big period channel. However width of channel of small period may rapidly becomes wider at the start of strong trend. The dynamic change of channel width is taken into account in this case in order to reduce delay of the filter.
The contribution of each algorithm in a final result and the common strength of the filter are controlled in presets of the indicator.
- BarsCount – the number of colored bars on a chart.
- UseChanges – to use the first algorithm (change MA direction).
- UseTg – to use the second algorithm (MА inclination).
- UseMABB – to use the third algorithm (ratio between МА inclination and channel width).
- UseBBBB – to use the fourth algorithm (ratio between different channels width).
- ChangesPeriod – the period to count MA changes.
- MaPeriod1(2,3,4,5) – MA periods.
- TgPeriod – the period to measure the average MA inclination.
- TgMaPeriod1(2,3,4,5) – MA periods.
- MaBBPeriod - MA period.
- BBPeriod – channel period.
- SmallBBPeriod – small channel period.
- BigBBPeriod – big channel period.
- BBRelationPeriod – the period to measure the ratio between channels widths.
- SmallBBComparisonPeriod – the period to measure the dynamic broadening of a small channel width.
- BigBBComparisonPeriod – the period to measure the dynamic broadening of a big channel width.
- MinCurrentRelation – the minimal ratio between channels widths at the first bar.
- MaxBigBRIncreasing – the maximal broadening of a big channel.
- MaxSmallBRIncreasing - the maximal broadening of a small channel.
- MaxBBBBMATg – the maximal generalized inclination of a current trend.
- Koeff… – weight factors for all strategies.
- FilterStrength – the common strength of filtering.
Trade instruments – any.
I strictly recommend to set each algorithm independently. When you get satisfactory results for each strategy you may turn on all strategies reducing the strength of filtering.
Filtering may takes up to few minutes depending on presets and PC performance.