Trend Levels Indicator: A Dynamic Support, Resistance and Trend Indicator

Category: Indicators By: Iván González Created: January 10, 2025, 2:20 PM
January 10, 2025, 2:20 PM
Indicators
2 Comments

The Trend Levels is a technical indicator designed to identify and visually represent trend changes and dynamic support and resistance levels on price charts. This indicator helps traders detect key market moments through reference lines, labels, and arrows that clearly signal direction changes.
It is a valuable tool for both intraday traders and those who operate on higher timeframes.


How the Indicator Works

1. Key Value Calculations

The indicator calculates the highest (hi) and lowest (lo) values over a user-defined period using the length parameter.
These values serve as references to determine when a new high or low is reached, potentially indicating a trend reversal.

2. Trend Direction

The trend direction is determined by comparing the highest (hi) and lowest (lo) values with recent highs and lows:

  • Uptrend (trend = 1): occurs when the price reaches a new high within the defined period.
  • Downtrend (trend = -1): is triggered when the price hits a new low within the defined period.

This trend change is key to identifying significant turning points in the market.

3. Drawing Trend Change Arrows

When the indicator detects a trend change, it draws arrows to mark these key points:

  • Up arrow (lime green): signals the start of an uptrend.
  • Down arrow (fuchsia): marks the beginning of a downtrend.

These signals allow traders to visually identify moments when the price may initiate a significant new movement.

4. Dynamic Level Calculations

From the moment a trend change occurs, the indicator calculates the following levels:

  • h1 (upper level): the highest value since the trend began.
  • l1 (lower level): the lowest value since the trend began.
  • m1 (mid-level): the average between the h1 and l1 levels.

These levels help identify dynamic support and resistance zones on the chart, providing clear visual references for technical analysis.

Visual Interpretation on the Chart

  • Reference Lines
    The Trend Levels indicator draws three horizontal reference lines:

    • h1 (upper line): displayed in lime green.
    • l1 (lower line): displayed in fuchsia.
    • m1 (mid-line): displayed in gray with a dotted style.
  • Text and Labels
    Next to each line, in the lastbarindex, the indicator displays a label showing the value of each level (#h1##l1##m1#).

Indicator Configuration

Customizable Parameters

  • length: The number of bars used to calculate highs and lows (default value: 30).
    This parameter allows the analysis period to be adjusted for different timeframes, ranging from intraday charts to daily charts.

Code Trend Levels indicator

//---------------------------------------------------//
//PRC Trend Levels
//version = 0
//10.01.24
//Ivan Gonzalez @ www.prorealcode.com
//Sharing ProRealTime knowledge
//---------------------------------------------------//
// inputs
//---------------------------------------------------//
length=30
atr=averagetruerange[14](close)
//---------------------------------------------------//
// Highest and Lowest values
//---------------------------------------------------//
hi=highest[length](high)
lo=lowest[length](low)
//---------------------------------------------------//
// Trend direction calculation
//---------------------------------------------------//
if hi=high then
trend=1
elsif lo=low then
trend=-1
endif
//---------------------------------------------------//
// Indicator calculation
//---------------------------------------------------//
if trend <> trend[1] then
bars=1
a=0
if trend=1 then
drawarrowUp(barindex,low-atr)coloured("lime")
elsif trend=-1 then
drawarrowdown(barindex,high+atr)coloured("fuchsia")
endif
else
bars=bars+1
a=255
endif

if bars>0 then
h1=highest[bars](high)
l1=lowest[bars](low)
m1=(h1+l1)/2
endif
//---------------------------------------------------//
// Last levels
//---------------------------------------------------//
if islastbarupdate then
drawsegment(barindex,h1,barindex+10,h1)coloured("lime",a)
drawsegment(barindex,l1,barindex+10,l1)coloured("fuchsia",a)
drawsegment(barindex,m1,barindex+10,m1)coloured("grey",a)style(dottedline3)
drawtext("#h1#",barindex+10,h1+0.5*atr)coloured("lime",a)
drawtext("#l1#",barindex+10,l1+0.5*atr)coloured("fuchsia",a)
drawtext("#m1#",barindex+10,m1+0.5*atr)coloured("grey",a)
endif
//---------------------------------------------------//
return h1 coloured("lime",a), l1 coloured("fuchsia",a), m1 coloured("grey",a)style(dottedline3)

Conclusion

The Trend Levels Indicator is an effective tool for identifying key dynamic support and resistance zones and detecting trend changes in a visual and precise way. By combining reference lines and arrows that highlight market turning points, this indicator provides traders with a clear view of entry and exit opportunities.
It is recommended to adjust the length parameter according to the timeframe and asset being analyzed to maximize the indicator’s effectiveness in different market contexts.

Download
Filename: PRC-TrendLevels.itf
Downloads: 182
Iván González Master
I usually let my code do the talking, which explains why my bio is as empty as a newly created file. Bio to be initialized...
Author’s Profile

Comments

Logo Logo
Loading...