Indicator · Pine Script v4 · Own pane

LeMan Trend Indicator

by capissimo

LeMan Trend Indicator calculates buy and sell values using normalized differences between current and highest/lowest highs and lows over adjustable lookback periods.

View on GitHub

GitHub stars114on the repository
Pine versionv4older, still runs
Lines of code59
Settings4inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago7 Nov 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

59 lines of Pine Script v4 from scripts/091-LeMan-Trend-Indicator.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

091-LeMan-Trend-Indicator.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © capissimo

//@version=4
study("LeMan Trend Indicator", '', false)

// LeMan Trend Indicator (Euro and Pound)
// Description: This is a sample Trend Trading indicator, best used as a support to a main indicator or as a signal filter. 
// Style tags:  Trend Following, Trend Analysis
// Asset class: Equities, Futures, ETFs, Currencies and Commodities
// Dataset:     FX Minutes/Hours

// Nov, 17, 2020 - Minor fix. Added normalization and approximate equality

//-------------------- Inputs 

Min    = input(13,    'Min Lookback',        minval=1)
Middle = input(21,    'Middle Lookback',     minval=1) 
Max    = input(34,    'Max Lookback',        minval=1)
tol    = input(0.0015,'Tolerance',           minval=0.0001, step=.0001)

//-------------------- DynArrays 

buy      = 0.0    
sell     = 0.0

//-------------------- Custom Functions 

cGreen(g) => g>9 ? #006400 : g>8 ? #1A741A : g>7 ? #338333 : g>6 ? #4D934D : g>5 ? #66A266 : g>4 ? #80B280 : g>3 ? #99C199 : g>2 ? #B3D1B3 : g>1?  #CCE0CC : #E6F0E6
cRed(g)   => g>9 ? #E00000 : g>8 ? #E31A1A : g>7 ? #E63333 : g>6 ? #E94D4D : g>5 ? #EC6666 : g>4 ? #F08080 : g>3 ? #F39999 : g>2 ? #F6B3B3 : g>1?  #F9CCCC : #FCE6E6

isZero(val, eps) => abs(val) <= eps

mean(x)  => cum(x) / bar_index
varnc(x) => cum(pow(x - mean(x), 2)) / (bar_index-1)
std(x)   => sqrt(varnc(x))
znorm(x) => (x - mean(x)) / std(x)

//-------------------- Logic 

high1 = high[-highestbars(high[1], Min)]
high2 = high[-highestbars(high[1], Middle)]
high3 = high[-highestbars(high[1], Max)]

low1  = low[-lowestbars(low[1], Min)]
low2  = low[-lowestbars(low[1], Middle)]
low3  = low[-lowestbars(low[1], Max)]

buy  := (low1 - low)   + (low2 - low)   + (low3 - low)
sell := (high - high1) + (high - high2) + (high - high3)

zero = isZero(buy-sell, tol)

//-------------------- Rendering 
        
plot(0, color=color.gray, linewidth=1, transp=0)
plot(zero ? buy-sell : na,  color=color.yellow, style=plot.style_linebr, linewidth=6)
plot(znorm(buy),  color=zero ? color.new(color.black,60) : cRed(10))
plot(znorm(sell), color=zero ? color.new(color.black,60) : cGreen(10))

Overview

LeMan Trend Indicator plots a zero line signal in a separate pane and normalized buy and sell lines in colors. Main inputs adjust Min, Middle and Max lookbacks as well as tolerance for the zero signal. It functions as a trend analysis tool for FX currencies, equities, futures, ETFs, commodities and indices, drawing exclusively in a separate pane.

Details

Published by

capissimo on GitHub

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Trend, Oscillators & momentum

Markets

Forex, Stocks, Indices, Oil & commodities

Timeframes

M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Min Lookbackint13Min
Middle Lookbackint21Middle
Max Lookbackint34Max
Tolerancefloat0.0015tol
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Schaff Trend Cycle

by everget
948 stars

This indicator plots the Schaff Trend Cycle in a separate pane. It subtracts a slow exponential moving average from a fast one, applies a stochastic cycle twice, and smooths each result to form a 0–100 oscillator. Line color follows the slope, or the upper and

Indicator v4 Oscillators & momentumTrend
Updated 10 days ago · GPL-3.0 GitHub repository of Schaff Trend Cycle

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

[RS]Standardized Trend Map

by ricardosantos79
261 stars

Standardized Trend Map calculates series momentum relative to active price range across 40 distinct lookback periods ranging from 2 to 80 bars on an exponential moving average source. Each standardized calculation rounds to an integer values of -1, 0, or 1 to

Indicator v4 TrendOscillators & momentum
Updated 4 years ago · None stated GitHub repository of [RS]Standardized Trend Map

ADX Histogram

by harryguiacorn
219 stars

This indicator calculates and displays the Average Directional Index (ADX) as a column histogram in a separate pane. It evaluates market trend strength by calculating directional movement metrics based on specified smoothing and DI length inputs. When the ADX

Indicator v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Histogram
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers