LRLR Indicator

Category: Indicators By: Iván González Created: February 7, 2025, 2:52 PM
February 7, 2025, 2:52 PM
Indicators
2 Comments

Introduction

The LRLR indicator was originally presented by its creator Lukapex in a post where he described it as a tool to identify Low Resistance Liquidity Runs (LRLR) by detecting zones where the price remains above or below a reference line for at least one hour. Based on this logic, the indicator generates “LRLR” text signals directly on the chart.

In this article, we will explore the details of the indicator, highlight some interesting technical aspects of the code, and present an additional perspective: its use in detecting divergences with price, which can be a key function for many technical traders.

Indicator Inspiration

According to the author’s post, the primary purpose of the indicator is to replicate low-resistance areas. To achieve this, it uses the slope of a moving average and verifies whether this slope remains positive or negative for a defined period of time (one hour, in the original example), which then triggers the visual “LRLR” signal.

Beyond the utility described by its original creator, I would like to highlight another potential application of the indicator: detecting divergences between price and the slope of the moving average. This approach allows traders to identify zones where the market’s momentum and price behavior could be disconnected, which could signal potential reversals.

Technical Highlight: Variable Assignment Based on Timeframe

Although the indicator’s code is simple, I decided to create this article because it includes an interesting feature that could be useful for other indicators: the dynamic assignment of variable values based on the chart’s timeframe. The following code snippet demonstrates this concept:

if gettimeframe=60 then
  barsPerHour=60
elsif gettimeframe=180 then
  barsPerHour=20
elsif gettimeframe=300 then
  barsPerHour=12
elsif gettimeframe=600 then
  barsPerHour=6
elsif gettimeframe=900 then
  barsPerHour=4
elsif gettimeframe=1800 then
  barsPerHour=2
else
  barsPerHour=undefined
endif

This method automatically adjusts the number of bars per hour according to the chart’s timeframe, which simplifies the development of flexible and scalable indicators. Other programmers can use this technique when building indicators or strategies that need to adapt dynamically without manual intervention.

How the LRLR Indicator Works

The indicator combines the slope of a moving average with market volatility (measured using the Average True Range) to generate visual signals when trend changes are detected. Here’s a breakdown of the main steps:

  1. Calculating the moving average slope:
    The typical price (Open+High+Low+Close)/4 is averaged over a user-defined period (default is 56).
  2. Normalizing with the ATR:
    The difference between the current and previous moving average values is divided by the ATR to get a relative slope.
  3. Detecting slope changes:
    The indicator detects when the slope switches from negative to positive (bullish change) or from positive to negative (bearish change).
  4. Generating the “LRLR” signal:
    If the slope remains positive or negative for the required number of bars, the indicator draws the “LRLR” signal on the chart.

Interpreting the Indicator: Divergence Detection with Price

Although the author initially designed the LRLR indicator to identify dynamic support and resistance zones, I believe its true power lies in its ability to help detect divergences. Divergences occur when the price moves in one direction while the slope of the moving average indicates the opposite direction, signaling a potential loss of market momentum and a possible trend reversal.

  • Bearish divergence: Price continues to rise, but the moving average slope starts to decline.
  • Bullish divergence: Price continues to fall, but the slope of the moving average turns positive.

These signals works in all timeframes charts.

Conclusion

The LRLR indicator not only provides an effective tool for detecting trend changes, but it also opens new possibilities for technical analysis through divergence detection. Additionally, the dynamic variable assignment feature showcased in the code is an excellent example for developers looking to create adaptable and flexible indicators.

//-------------------------------------------//
//PRC_LRLR
//version = 0
//06.02.2025
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-------------------------------------------//
// Inputs
//-------------------------------------------//
showLRLR=1
//Bars per hour
if gettimeframe=60 then
barsPerHour=60
elsif gettimeframe=180 then
barsPerHour=20
elsif gettimeframe=300 then
barsPerHour=12
elsif gettimeframe=600 then
barsPerHour=6
elsif gettimeframe=900 then
barsPerHour=4
elsif gettimeframe=1800 then
barsPerHour=2
else
barsPerHour=undefined
showLRLR=0
endif
//moving average
period=56
src=(open+high+low+close)/4
//-------------------------------------------//
// Determine Angle
//-------------------------------------------//
atr=averagetruerange[14](close)
ma=average[period,1](src)
maSlope=atan((ma-ma[1])/atr)
//-------------------------------------------//
// LRLR Detection
//-------------------------------------------//
changedAbove=maSlope>=0 and maSlope[1]<0
changedBelow=maSlope<=0 and maSlope[1]>0

countSinceChange=barssince(changedAbove or changedBelow)

if changedAbove then
isAbove=1
isBelow=0
r=75
g=125
b=255
elsif changedBelow then
isAbove=0
isBelow=1
r=255
g=0
b=100
endif

if showLRLR and countSinceChange=barsPerHour then
if isAbove then
drawtext("LRLR",barindex,highest[20](maSlope)*1.2)coloured(r,g,b)
drawpoint(barindex,maSlope,2)
else
drawtext("LRLR",barindex,lowest[20](maSlope)*1.2)coloured(r,g,b)
drawpoint(barindex,maSlope,2)
endif
endif

//-------------------------------------------//
return maSlope coloured(r,g,b)style(line,2),0 style(dottedline), maSlope style(histogram)coloured(r,g,b,100)

Download
Filename: PRC_LRLR.itf
Downloads: 113
Iván González Master
As an architect of digital worlds, my own description remains a mystery. Think of me as an undeclared variable, existing somewhere in the code.
Author’s Profile

Comments

Logo Logo
Loading...