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.
Skrip open-source

Dalam semangat TradingView, penulis dari skrip ini telah mempublikasikannya ke sumber-terbuka, maka trader dapat mengerti dan memverifikasinya. Semangat untuk penulis! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.

Inggin menggunakan skrip ini pada chart?