OPEN-SOURCE SCRIPT

Repulsion Moving Average - Least Crosses MA

A Moving Average With Less Whipsaws Signals

The cross of the price with a moving average is one of the easiest strategy in technical analysis and could have worked if market price wasn't so noisy (In general periods of 1 to 20 produces the most whipsaws). So it is possible to create a moving average who can manage to escape those noisy periods and produce 0 whipsaws ?

This question was asked by one of my work colleagues and i responded : "well...almost 0".


The Motion Of A Moving Average

Moving Average estimate the Trend and will always have phase shift, they will still follow the price and cross it during high volatility or low volatility periods, and when a moving average cross the price during a low volatility period you can expect lot of crosses.

In order to fix this behaviour a simple calculation exist :

FixMa = LongPeriodMA + MediumPeriodMA - ShortPeriodMA

We can see things in that way, the medium term MA is high pass filtered (subtracted) with a short term MA and the result is summed to a long term MA. We give more reactivity to our long term MA and thus creating some kind of repulsion motion with the price. Of course this can sometimes make the filter kinda zero-lag to some price periods (when the long term MA is near the price).


Comparison

In red a simple moving average of period 100 and in blue our repulsion moving average :

снимок

In the image the short term moving average period is 100, since the long term period of the moving average is equal to short term x 3 you could be interested to look at the comparison of our moving average with the actual long term moving average :

снимок

Less crosses, i think you can see it.

Something to notice is that its always a tradeoff between Signal Speed and Signal Numbers, a classic moving average create faster signals but also a high numbers of them, a classic trailing stop create less signals but slowest ones, our moving average is some kind of average between those indicators.


Improvement Methods - Choice of The Filter/More Terms

A bad behaviour of our filter can be fixed by using filters who tend to create less crosses with the price or by developing the formula of our filter by adding more terms as follow :

fixma = ma(Price,a) + ma(Price,b) + ma(Price,c) - ma(Price,d) - ma(Price,e)

where a > b > c > d > e. The number of subtractive terms is equal to the number of summing terms - 1.

Way To Use

This indicator can be used like any moving average with cross strategy. Can also be used as a trailing stop.
No tests have been made proving that this indicator provide support and resistance levels, such signals come from more centered indicators.


Hope you enjoy

For any questions/demands feel free to pm me, i would be happy to help you :)
crosscrossingcrossovercrossunderfilterMoving AveragestrendTrend Analysiswhipsaw

Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Хотите использовать этот скрипт на графике?


Check out the indicators we are making at luxalgo: tradingview.com/u/LuxAlgo/
Мои профили:

Отказ от ответственности