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.
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.
The trend direction is determined by comparing the highest (hi) and lowest (lo) values with recent highs and lows:
trend = 1): occurs when the price reaches a new high within the defined period.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.
When the indicator detects a trend change, it draws arrows to mark these key points:
These signals allow traders to visually identify moments when the price may initiate a significant new movement.
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.
h1 (upper line): displayed in lime green.l1 (lower line): displayed in fuchsia.m1 (mid-line): displayed in gray with a dotted style.#h1#, #l1#, #m1#).length: The number of bars used to calculate highs and lows (default value: 30).//---------------------------------------------------//
//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)
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.