adridem

Smart Market Structure and Swing Points, version 1.0

Smart Market Structure and Swing Points, Version 1.0

Overview

The Smart Market Structure and Swing Points script is designed to provide advanced insights into market structure and key swing points. This script helps identify important highs and lows, trend direction changes (structure breaks), and swing points, enhancing decision-making for both trend-following and reversal strategies. See below for detail presentation and why it has unique features.

Unique Features of the New Script

  1. Market Structure Identification : Analyzes and marks key highs and lows to determine market structure, including higher highs, lower highs, higher lows, and lower lows.
  2. Customizable Detection Length : Allows users to set the length for detecting highs and lows, providing flexibility to adapt to different market conditions and timeframes. Default value is 5 bars, but can be changed if needed.
  3. Visual Signal Indicators (Labels) : Plots labels on the chart to indicate higher highs (HH), lower highs (LH), higher lows (HL), and lower lows (LL), along with corresponding RSI values, offering clear visual cues for market structure analysis. The indication of RSI values directly on high and low points enables to better judge whether the points are strong references (extreme RSI values) or weak references (middle RSI values)
  4. Dynamic Trend Lines : Draws solid and dotted lines to connect significant highs and lows, visually representing the current trend direction and potential trend changes. Dashed lines indicates structure breaks.
  5. Swing High and Swing Low Detection : Identifies and marks the most recent swing highs and swing lows, helping traders spot potential reversal points and key levels for setting stop losses or take profit targets.

Originality and Usefulness

This script combines market structure, trend breaks and RSI to provide a more robust view of market dynamic by indicating the strength or weakness of swing points, in that way the script is unique.

Signal Description

The script includes various signal features that highlight potential trading opportunities based on market structure:

  • Higher Highs (HH) and Higher Lows (HL) : These labels are plotted when new highs or lows are formed, indicating a continuation of an uptrend. The labels are positioned with consideration of the Average True Range (ATR) for better visibility.
  • Lower Highs (LH) and Lower Lows (LL) : These labels are plotted when new highs or lows are formed, indicating a continuation of a downtrend. The labels include RSI values to provide additional information on the strength or weakness of the points.
  • Trend Direction Change : Dotted lines are drawn to indicate potential trend direction changes when the script detects significant shifts in market structure.
  • Swing Highs and Swing Lows : These are identified based on a customizable swing length, marking recent significant highs and lows to highlight potential reversal points.

These signals help identify high-probability turning points and confirm trend direction by ensuring that the market structure aligns with the trading strategy.

Detailed Description

Input Variables

  • Length for High/Low Detection (`length`) : Defines the range to check for highs and lows. Default is 5.
  • RSI Length (`rsilength`) : The number of periods to calculate the RSI. Default is 14.

Functionality

  1. Market Structure Calculation : The script determines the highest high and lowest low within the specified range to identify key points in market structure.

    ```pine
    h = ta.highest(high, length * 2 + 1)
    l = ta.lowest(low, length * 2 + 1)
    ```


  2. Directional Logic : Variables and functions manage the state of the indicator, updating highs and lows based on the current trend direction.

    ```pine
    var bool dirUp = false
    var float lastLow = high * 100
    var float lastHigh = 0.0
    // Additional variables for tracking state
    ```


  3. Drawing Lines and Labels : Functions draw lines and labels on the chart to visualize market structure and trend changes.

    ```pine
    f_drawLine() =>
    _li_color = dirUp ? color.red : color.lime
    line.new(x1=timeHigh - length, y1=lastHigh, x2=timeLow - length, y2=lastLow, color=_li_color, width=3, style=line.style_solid, xloc=xloc.bar_index)

    f_drawLastLine() =>
    _li_color = dirUp ? color.blue : color.blue
    if timeHigh > timeLow
    line.new(x1=timeHigh - length, y1=lastHigh, x2=bar_index, y2=low, color=_li_color, width=2, style=line.style_dotted, xloc=xloc.bar_index)
    else
    line.new(x1=timeLow - length, y1=lastLow, x2=bar_index, y2=high, color=_li_color, width=2, style=line.style_dotted, xloc=xloc.bar_index)
    ```


  4. Updating Highs and Lows : The main logic updates highs and lows based on the current trend direction, adding labels for new higher highs, lower highs, higher lows, and lower lows.

    ```pine
    if dirUp
    if f_isMin(length)
    lastLow := low
    // Additional logic for updating lows and labels
    if f_isMax(length) and high > lastLow
    lastHigh := high
    // Additional logic for updating highs and labels
    dirUp := false
    li := f_drawLine()
    ```


  5. Swing Highs and Lows : The script identifies recent swing highs and swing lows based on a customizable swing length, drawing lines to mark these points.

    ```pine
    swingLength = 3 * length

    isSwingHigh = ta.highestbars(high, swingLength) == 0
    isSwingLow = ta.lowestbars(low, swingLength) == 0

    if (isSwingHigh)
    if (na(highLine))
    highLine := line.new(bar_index, high, bar_index, high, color=color.green, style=line.style_solid, width=1)
    else
    line.set_xy1(highLine, bar_index, high)
    line.set_xy2(highLine, bar_index + swingLength, high)

    if (isSwingLow)
    if (na(lowLine))
    lowLine := line.new(bar_index, low, bar_index, low, color=color.red, style=line.style_solid, width=1)
    else
    line.set_xy1(lowLine, bar_index, low)
    line.set_xy2(lowLine, bar_index + swingLength, low)
    ```


How to Use

  1. Configuring Inputs : Adjust the detection length and RSI length as needed. Modify the lookback periods to suit your trading strategy. The indicator is adaptable and can be used on any timeframe.
  2. Interpreting the Indicator : Use the labels and lines to gauge market structure and trend direction. Look for higher highs, lower highs, higher lows, and lower lows to confirm market structure.
  3. Signal Confirmation : Pay attention to the labels and lines that provide signals for potential trend changes and swing points. Use these signals to better time entries and exits.

This script provides a detailed view of market structure and swing points, helping make more informed decisions by considering key highs and lows, trend direction changes, and the strength or weakness of swing points.

Açık kaynak kodlu komut dosyası

Gerçek TradingView ruhuyla, bu betiğin yazarı, yatırımcının anlayabilmesi ve doğrulayabilmesi için onu açık kaynak olarak yayınladı. Yazarın eline sağlık! Bunu ücretsiz olarak kullanabilirsiniz, ancak bu kodun bir yayında yeniden kullanımı Kullanım Koşulları ile yönetilir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?