OPEN-SOURCE SCRIPT

Top-Down Trend and Key Levels with Swing Points

ที่อัปเดต:
//by antaryaami0

Overview

The “Top-Down Trend and Key Levels with Swing Points” indicator is a comprehensive tool designed to enhance your technical analysis by integrating multiple trading concepts into a single, easy-to-use script. It combines higher timeframe trend analysis, key price levels, swing point detection, and ranging market identification to provide a holistic view of market conditions. This indicator is particularly useful for traders who employ multi-timeframe analysis, support and resistance levels, and price action strategies.

Key Features

1. Higher Timeframe Trend Background Shading:
• Purpose: Identifies the prevailing trend on a higher timeframe to align lower timeframe trading decisions with the broader market direction.
• How it Works: The indicator compares the current higher timeframe close with the previous one to determine if the trend is up, down, or ranging.
• Customization:
• Trend Timeframe: Set your preferred higher timeframe (e.g., Daily, Weekly).
• Up Trend Color & Down Trend Color: Customize the background colors for uptrends and downtrends.
• Ranging Market Color: A separate color to indicate when the market is moving sideways.
2. Key Price Levels:
• Previous Day High (PDH) and Low (PDL):
• Purpose: Identifies key support and resistance levels from the previous trading day.
• Visualization: Plots horizontal lines at PDH and PDL with labels.
• Customization: Option to show or hide these levels and customize their colors.
• Pre-Market High (PMH) and Low (PML):
• Purpose: Highlights the price range during the pre-market session, which can indicate potential breakout levels.
• Visualization: Plots horizontal lines at PMH and PML with labels.
• Customization: Option to show or hide these levels and customize their colors.
3. First 5-Minute Marker (F5H/F5L):
• Purpose: Marks the high or low of the first 5 minutes after the market opens, which is significant for intraday momentum.
• How it Works:
• If the first 5-minute high is above the Pre-Market High (PMH), an “F5H” label is placed at the first 5-minute high.
• If the first 5-minute high is below the PMH, an “F5L” label is placed at the first 5-minute low.
• Visualization: Labels are placed at the 9:35 AM candle (closing of the first 5 minutes), colored in purple by default.
• Customization: Option to show or hide the marker and adjust the marker color.
4. Swing Points Detection:
• Purpose: Identifies significant pivot points in price action to help recognize trends and reversals.
• How it Works: Uses left and right bars to detect pivot highs and lows, then determines if they are Higher Highs (HH), Lower Highs (LH), Higher Lows (HL), or Lower Lows (LL).
• Visualization: Plots small markers (circles) with labels (HH, LH, HL, LL) at the corresponding swing points.
• Customization: Adjust the number of left and right bars for pivot detection and the size of the markers.
5. Ranging Market Detection:
• Purpose: Identifies periods when the market is consolidating (moving sideways) within a defined price range.
• How it Works: Calculates the highest high and lowest low over a specified period and determines if the price range is within a set percentage threshold.
• Visualization: Draws a gray box around the price action during the ranging period and labels the high and low prices at the end of the range.
• Customization: Adjust the range detection period and threshold, as well as the box color.
6. Trend Coloring on Chart:
• Purpose: Provides a visual cue for the short-term trend based on a moving average.
• How it Works: Colors the candles green if the price is above the moving average and red if below.
• Customization: Set the moving average length and customize the uptrend and downtrend colors.

How to Use the Indicator

1. Adding the Indicator to Your Chart:
• Copy the Pine Script code provided and paste it into the Pine Script Editor on TradingView.
• Click “Add to Chart” to apply the indicator.
2. Configuring Inputs and Settings:
• Access Inputs:
• Click on the gear icon next to the indicator’s name on your chart to open the settings.
• Customize Key Levels:
• Show Pre-Market High/Low: Toggle on/off.
• Show Previous Day High/Low: Toggle on/off.
• Show First 5-Minute Marker: Toggle on/off.
• Set Trend Parameters:
• Trend Timeframe for Background: Choose the higher timeframe for trend analysis.
• Moving Average Length for Bar Color: Set the period for the moving average used in bar coloring.
• Adjust Ranging Market Detection:
• Range Detection Period: Specify the number of bars to consider for range detection.
• Range Threshold (%): Set the maximum percentage range for the market to be considered ranging.
• Customize Visuals:
• Colors: Adjust colors for trends, levels, markers, and ranging market boxes.
• Label Font Size: Choose the size of labels displayed on the chart.
• Level Line Width: Set the thickness of the lines for key levels.
3. Interpreting the Indicator:
• Background Shading:
• Green Shade: Higher timeframe is in an uptrend.
• Red Shade: Higher timeframe is in a downtrend.
• Gray Box: Market is ranging (sideways movement).
• Key Levels and Markers:
• PDH and PDL Lines: Represent resistance and support from the previous day.
• PMH and PML Lines: Indicate potential breakout levels based on pre-market activity.
• F5H/F5L Labels: Early indication of intraday momentum after market open.
• Swing Point Markers:
• HH (Higher High): Suggests bullish momentum.
• LH (Lower High): May indicate a potential bearish reversal.
• HL (Higher Low): Supports bullish continuation.
• LL (Lower Low): Indicates bearish momentum.
• Ranging Market Box:
• Gray Box Around Price Action: Highlights consolidation periods where breakouts may occur.
• Range High and Low Labels: Provide the upper and lower bounds of the consolidation zone.
4. Applying the Indicator to Your Trading Strategy:
• Trend Alignment:
• Use the higher timeframe trend shading to align your trades with the broader market direction.
• Key Levels Trading:
• Watch for price reactions at PDH, PDL, PMH, and PML for potential entry and exit points.
• Swing Points Analysis:
• Identify trend continuations or reversals by observing the sequence of HH, HL, LH, and LL.
• Ranging Market Strategies:
• During ranging periods, consider range-bound trading strategies or prepare for breakout trades when the price exits the range.
• Intraday Momentum:
• Use the F5H/F5L marker to gauge early market sentiment and potential intraday trends.

Practical Tips

• Adjust Settings to Your Trading Style:
• Tailor the indicator’s inputs to match your preferred timeframes and trading instruments.
• Combine with Other Indicators:
• Use in conjunction with volume indicators, oscillators, or other technical tools for additional confirmation.
• Backtesting:
• Apply the indicator to historical data to observe how it performs and refine your settings accordingly.
• Stay Updated on Market Conditions:
• Be aware of news events or economic releases that may impact market behavior and the effectiveness of technical levels.

Customization Options

• Time Zone Adjustment:
• The script uses “America/New_York” time zone by default. Adjust the timezone variable in the script if your chart operates in a different time zone.




• Session Times:
• Modify the Regular Trading Session and Pre-Market Session times in the indicator settings to align with the trading hours of different markets or exchanges.
• Visual Preferences:
• Colors: Personalize the indicator’s colors to suit your visual preferences or to enhance visibility.
• Label Sizes: Adjust label sizes if you find them too intrusive or not prominent enough.
• Marker Sizes: Further reduce or enlarge the swing point markers by modifying the swing_marker_size variable.

Understanding the Indicator’s Logic

1. Higher Timeframe Trend Analysis:
• The indicator retrieves the closing prices of a higher timeframe using the request.security() function.
• It compares the current higher timeframe close with the previous one to determine the trend direction.
2. Key Level Calculation:
• Previous Day High/Low: Calculated by tracking the highest and lowest prices of the previous trading day.
• Pre-Market High/Low: Calculated by monitoring price action during the pre-market session.
3. First 5-Minute Marker Logic:
• At 9:35 AM (end of the first 5 minutes after market open), the indicator evaluates whether the first 5-minute high is above or below the PMH.
• It then places the appropriate label (F5H or F5L) on the chart.
4. Swing Points Detection:
• The script uses ta.pivothigh() and ta.pivotlow() functions to detect pivot points.
• It then determines the type of swing point based on comparisons with previous swings.
5. Ranging Market Detection:
• The indicator looks back over a specified number of bars to find the highest high and lowest low.
• It calculates the percentage difference between these two points.
• If the difference is below the set threshold, the market is considered to be ranging, and a box is drawn around the price action.

Limitations and Considerations

• Indicator Limitations:
• Maximum Boxes and Labels: Due to Pine Script limitations, there is a maximum number of boxes and labels that can be displayed simultaneously.
• Performance Impact: Adding multiple visual elements (boxes, labels, markers) can affect the performance of the script on lower-end devices or with large amounts of data.
• Market Conditions:
• False Signals: Like any technical tool, the indicator may produce false signals, especially during volatile or erratic market conditions.
• Not a Standalone Solution: This indicator should be used as part of a comprehensive trading strategy, including risk management and other forms of analysis.

Conclusion

The “Top-Down Trend and Key Levels with Swing Points” indicator is a versatile tool that integrates essential aspects of technical analysis into one script. By providing insights into higher timeframe trends, highlighting key price levels, detecting swing points, and identifying ranging markets, it equips traders with valuable information to make more informed trading decisions. Whether you are a day trader looking for intraday opportunities or a swing trader aiming to align with the broader trend, this indicator can enhance your chart analysis and trading strategy.

Disclaimer

Trading involves significant risk, and it’s important to understand that past performance is not indicative of future results. This indicator is a tool to assist in analysis and should not be solely relied upon for making trading decisions. Always conduct thorough research and consider seeking advice from financial professionals before engaging in trading activities.
เอกสารเผยแพร่
// Updates #001

Updated the script with color coding of Bullish and Bearish levels as marked by candle movement.
Candlestick AnalysismultitimeframePivot points and levels

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ