pooripro

MACD Higher TimeFrame

This Pine script is an indicator called "MACD Higher TimeFrame" that calculates and displays the Moving Average Convergence Divergence (MACD) on a higher timeframe. It is designed to be used on a lower timeframe chart but show the MACD values from a specified higher timeframe.

The indicator takes several inputs, including the fast length, slow length, source data, signal smoothing length, and the types of moving averages to be used for the MACD and signal lines. The default values are set to 12, 26, the closing price, 9, and exponential moving averages (EMA) for both lines, respectively. These inputs can be modified by the user.

The script calculates the MACD and signal lines based on the specified inputs and the source data. It uses the `init_ma` function to initialize the moving average calculation based on the selected moving average type (EMA or SMA) and length.

To display the MACD and signal lines from the higher timeframe, the script utilizes the `request.security` function, fetching the values of MACD and signal lines one bar ago on the higher timeframe. It handles any gaps in data and lookahead considerations.

The script also includes a function called `int_htf_fillna`, which handles the filling of `na` (not available) values for the higher timeframe indicators. It ensures that the indicator values are carried forward if they are not available for a particular bar.

To enhance the visualization, the script includes customizable colors for the MACD line, signal line, and histogram bars. The histogram bars are styled using the `plot.style_columns` option, and their color is determined by the `color_handle_ducplicate_value` function. This function checks for duplicate values and assigns colors based on whether the indicator is rising or falling, and whether it is above or below zero.

The script also includes a zero line (color #787B86) to provide a visual reference for the zero level.

Overall, this Pine script allows users to view the MACD indicator from a higher timeframe on a lower timeframe chart, providing insights into the broader market trend.
Open-source Skript

Ganz im Spirit von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es besser verstehen und überprüfen können. Herzlichen Glückwunsch an den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Veröffentlichung unterliegt den Hausregeln. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.

Möchten Sie dieses Skript auf einem Chart verwenden?