Rolling MACD

chervolino Zaktualizowano   
This indicator displays a Rolling Moving Average Convergence Divergence . Contrary to MACD indicators which use a fix time segment, RMACD calculates using a moving window defined by a time period (not a simple number of bars), so it shows better results.

This indicator is inspired by and use the Close & Inventory Bar Retracement Price Line to create an MACD in different timeframes.


If you are not already familiar with ​MACD, so look at Help Center will get you started

The typical MACD, short for moving average convergence/divergence, is a trading indicator used in technical analysis of stock prices, created by Gerald Appel in the late 1970s. It is designed to reveal changes in the strength, direction, momentum, and duration of a trend in a stock's price.

The MACD indicator(or "oscillator") is a collection of three time series calculated from historical price data, most often the closing price. These three series are: the MACD series proper, the "signal" or "average" series, and the "divergence" series which is the difference between the two. The MACD series is the difference between a "fast" (short period) exponential moving average (EMA), and a "slow" (longer period) EMA of the price series. The average series is an EMA of the MACD series itself.

Because RMACD uses a moving window, it does not exhibit the jumpiness of MACD plots. You can see the more jagged MACD on the chart above. I think both can be useful to traders; up to you to decide which flavor works for you.


Load the indicator on an active chart (see the Help Center if you don't know how).

Time period

By default, the script uses an auto-stepping mechanism to adjust the time period of its moving window to the chart's timeframe. The following table shows chart timeframes and the corresponding time period used by the script. When the chart's timeframe is less than or equal to the timeframe in the first column, the second column's time period is used to calculate RMACD:

Chart Time
timeframe period

1min 🠆 1H
5min 🠆 4H
1H 🠆 1D
4H 🠆 3D
12H 🠆 1W
1D 🠆 1M
1W 🠆 ​3M

You can use the script's inputs to specify a fixed time period, which you can express in any combination of days, hours and minutes.

By default, the time period currently used is displayed in the lower-right corner of the chart. The script's inputs allow you to hide the display or change its size and location.

Minimum Window Size

This input field determines the minimum number of values to keep in the moving window, even if these values are outside the prescribed time period. This mitigates situations where a large time gap between two bars would cause the time window to be empty, which can occur in non-24x7 markets where large time gaps may separate contiguous chart bars, namely across holidays or trading sessions. For example, if you were using a 1D time period and there is a two-day gap between two bars, then no chart bars would fit in the moving window after the gap. The default value is 10 bars.

This indicator should make trading easier and improve analysis. Nothing is worse than indicators that give confusingly different signals.

I hope you enjoy my new ideas

best regards

Informacje o Wersji:
v1.1 Add Long / Short - Bull / Bear to the Infobox
Informacje o Wersji:
Corrected a smal bug
Skrypt open-source

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz użyć tego skryptu na wykresie?