OPEN-SOURCE SCRIPT

4 EMA with Two Timeframes and Supertrend by Natee L.

242
Key Features:
Customizable Timeframes:

The script has two inputs (timeframe_1 and timeframe_2) where you can select the timeframes for the two sets of EMAs. For example, you could choose:
timeframe_1 = "60" for 1-hour (60-minute) EMAs.
timeframe_2 = "240" for 4-hour (240-minute) EMAs.
Four EMAs for Each Timeframe:

It calculates 4 EMAs for both the first timeframe (timeframe_1) and the second timeframe (timeframe_2).
Plotting:

The EMAs for timeframe 1 are plotted in solid colors (blue, red, green, and purple).
The EMAs for timeframe 2 are plotted with a transparent effect (using color.new), so they are visually distinct but less dominant than the first timeframe's EMAs.
How to Use:
The timeframe_1 and timeframe_2 inputs allow you to select any timeframes you prefer (e.g., "15", "30", "60", "D", "W", etc.).
The EMAs for both selected timeframes will be plotted, allowing for easy comparison between the two timeframes on the same chart.

Explanation of the Updates:
Supertrend Calculation:

The Supertrend is calculated using the ta.supertrend function, which requires two parameters:
multiplier: The multiplier used for the Average True Range (ATR) calculation.
atr_period: The period for the ATR (usually set to 14).
The supertrend variable represents the value of the Supertrend, and direction is a boolean value indicating whether the trend is up (green) or down (red).
Supertrend Plot:

The Supertrend is plotted on the chart using the plot() function. The color is determined by the direction variable:
Green if the trend is up.
Red if the trend is down.
The Supertrend line is drawn with a linewidth of 2 for visibility.
Inputs:

atr_period: The period used for the ATR calculation, typically 14.
multiplier: The multiplier for the ATR to determine the offset for the Supertrend line.
How It Works:
The 4 EMAs are calculated for both timeframes (timeframe_1 and timeframe_2), just like before.
The Supertrend is calculated based on the ATR and the multiplier parameters, and it's plotted on the main chart.
The Supertrend changes color based on the trend direction (green for an uptrend, red for a downtrend).
Customization:
You can adjust the ATR period and multiplier as needed via the input fields.
You can also adjust the timeframes (timeframe_1 and timeframe_2) for the EMAs.
This script now combines the 4 EMAs and Supertrend indicators for two different timeframes, giving you a powerful tool for trend analysis and crossover strategies.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.