PROTECTED SOURCE SCRIPT

Multi-Timeframe MACD, Signal & Histogram Table

This Pine Script is designed for the TradingView platform to create a multi-timeframe MACD (Moving Average Convergence Divergence), Signal, and Histogram table that displays values for different timeframes. The script uses the MACD indicator to assess market trends across various timeframes and display the results in a table format on the chart. Here's a breakdown of its components and functionality:

1. User Inputs for Timeframes:
The script allows the user to input five different timeframes for the analysis. These are configured using input.string, which enables the user to select from a list of timeframes (from seconds to months).
tf1 to tf5 represent the different timeframes (for example, 5 minutes, 15 minutes, 60 minutes, 240 minutes, and daily).

2. MACD Settings:
The script provides adjustable settings for the MACD calculation:
macdShortLength (default 12): The length of the short-term moving average for the MACD.
macdLongLength (default 26): The length of the long-term moving average for the MACD.
macdSignalLength (default 9): The length of the signal line, which is an EMA (Exponential Moving Average) of the MACD line.

3. MACD Calculation Function (calc_macd):
This function calculates the MACD, Signal, and Histogram values:
MACD Line: Difference between the fast and slow exponential moving averages.
Signal Line: EMA of the MACD line.
Histogram: Difference between the MACD line and Signal line.

4. Requesting Multi-Timeframe Data:
The script calculates the MACD, Signal, and Histogram for the selected timeframes (tf1 to tf5) using request.security, which retrieves data for those timeframes:
macd_tf1, signal_tf1, hist_tf1 for Timeframe 1 (and similar variables for the other timeframes).

5. Rounding Values:
A helper function roundDecimal is used to round MACD, Signal, and Histogram values to two decimal places for readability.

6. Color Assignment Based on Value:
The colors of the values in the table cells are dynamically set based on whether the value is positive or negative:
MACD, Signal, and Histogram: The script uses conditional color assignments (green for positive values, red for negative values).
For example, if the MACD value is greater than or equal to 0, it is colored green, otherwise red. The same logic applies to the Signal and Histogram values.

7. Populating the Table:
For each timeframe (tf1 to tf5), the script populates the table with the following data:
Timeframe (e.g., "5 min")
Rounded MACD value
Rounded Signal value
Rounded Histogram value
The respective color is applied to each value based on whether it is positive or negative.

10. Table Update:
The table is updated dynamically with new data on each new bar. Each timeframe’s values are populated into the table starting from row 1 through row 5.
educationalMoving Average Convergence / Divergence (MACD)multi-timeframemultitimeframe

受保护脚本

该脚本是闭源发布的,您可以自由使用它。您可以收藏它以在图表上使用。您无法查看或修改其源代码。

想在图表上使用此脚本?


更多:

免责声明