Indicator · Pine Script v5 · On the chart

Edge 59

by subos2008· code credited to bford

This indicator identifies trend-following breakout opportunities by combining directional movement, trend channels, and multi-period price extremes.

View on GitHub

GitHub stars6on the repository
Pine versionv5runs as is
Lines of code103
Settings11inputs
LicenceCustom licencefile: MPL-2.0
Last update2 years ago10 Apr 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

103 lines of Pine Script v5 from pinescript/edge59/e59-indicator.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

e59-indicator.pine
//@version=5

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bford

indicator(title="Edge 59", overlay=true)

// START of INDICATOR

// ADX
// OG: E59 was 14,14,17,10 - but first visual test I did was with defaults 14,14,18,34 - and this worked really well
lenadx = input.int(14, minval=1, title="DI Length")
lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
limadx = input.int(17, minval=1, title="ADX MA Active")
len = input.int(10, minval=1, title="Length")
up = ta.change(high)
down = -ta.change(low)
trur = ta.rma(ta.tr, lenadx) // TODO: what is 'tr' here?
plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, lenadx) / trur)
minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, lenadx) / trur)
sum = plus + minus 
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
macol = adx > limadx and plus > minus ? color.lime : adx > limadx and plus < minus ? color.red :color.black
src = input(close, title="Source")
out = ta.wma(src, len)
plot(out, color=macol, title="MA", linewidth= 3)
adx_long_filter = macol == color.lime 
adx_short_filter = macol == color.red

// Trend Follower
matype= 'EMA'
prd = input.int(20, title = "Period to Check Trend", minval = 5)
maprd = input.int(20, title = "MA Period", minval = 2)
rateinp = input.float(1, title = "Trend Channel Rate %", minval = 0.1, step = 0.1)
ulinreg = input.bool(true, title = "Use Linear Regression")
linprd = input.int(5, title = "Linear Regression Period", minval = 2)

rate = rateinp / 100
pricerange = ta.highest(280) - ta.lowest(280) // TODO: what are these hardcoded 280's?
chan = pricerange * rate
    
gettrend(len)=>
    masrc = matype == 'EMA' ? ta.ema(close, len) : matype == 'RMA' ? ta.rma(close, len) : matype == 'VWMA' ? ta.vwma(close, len) : matype == 'WMA' ? ta.wma(close, len) : ta.sma(close, len)
    ma = ulinreg ? ta.linreg(masrc, linprd, 0) : masrc
    
    hh = ta.highest(ma, prd)
    ll = ta.lowest(ma, prd)
    diff = math.abs(hh - ll)
    
    inner = ma < hh - chan ? -1 : 0
    middle = ma > ll + chan ? 1 : inner
    trend = diff > chan ? middle : 0
    _ret = trend * diff / chan
    _ret

trend = gettrend(maprd)

trandchanged = trend - nz(trend[1])
tcol =  trend > 0 ? trandchanged> 0 ? #00FF00ff : trandchanged <= 0 ? #00FF006f : #00FF00af :
  trend < 0 ? trandchanged < 0 ? #FF0000ff: trandchanged >= 0 ? #FF00006f : #FF0000af : na

trend_follower_long_filter = tcol == #00FF00ff
trend_follower_short_filter  = tcol == #FF0000ff

// 22 Days high/low body prices
num_breakout_days = input.int(22, minval=1, title="Number of Days (Close Breakout)")

lowest_low = ta.lowest(low, num_breakout_days)[1]
highest_high = ta.highest(high, num_breakout_days)[1]

long_entry_signal = high > highest_high
short_entry_signal = low < lowest_low

// debug
plot(lowest_low)
plot(highest_high)

// Combine Filters

long_filter = adx_long_filter and trend_follower_long_filter
short_filter = adx_short_filter and trend_follower_short_filter

long_entry = long_filter and long_entry_signal
short_entry = short_filter and short_entry_signal

// Plots

// DEBUG: New Price High Lows (unfiltered entry signals)
// plotarrow(long_entry_signal, colorup = color.green)
// plotarrow(-short_entry_signal, colordown = color.red)

// Filters
plotarrow(long_filter?1:0, colorup = color.green, transp= 60)
plotarrow(short_filter?-1:0, colordown = color.red, transp=60)

// Filtered Entry (actual edge signal)
plotarrow(long_entry?1:0, colorup = color.green)
plotarrow(short_entry?-1:0, colordown = color.red)
// Study exit API
// long_entry and short_entry: entry signal with filters applied
// long_filter and short_filter: entry/stay in position filters are active: close position whenever this is false

// END of INDICATOR

Overview

Edge 59 calculates an ADX-colored weighted moving average, a linear regression trend filter based on a volatility channel, and high/low breakout levels. Long and short entry signals trigger when price breaks outside the previous period range while both the ADX and trend follower filters align. Settings allow adjusting ADX smoothing, linear regression periods, channel rate percentages, and breakout lookback lengths.

Details

Published by

subos2008 on GitHub

Code credit

bford, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Breakout, Oscillators & momentum

Markets

Crypto

Timeframes

Any timeframe

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.

Topics

binancebinance-trading-botstrading-bot

Settings

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

SettingTypeDefaultVariable
DI Lengthint14lenadx
ADX Smoothingint14lensig
ADX MA Activeint17limadx
Lengthint10len
Sourcesourceclosesrc
Period to Check Trendint20prd
MA Periodint20maprd
Trend Channel Rate %float1rateinp
Use Linear Regressionbooltrueulinreg
Linear Regression Periodint5linprd
Number of Days (Close Breakout)int22num_breakout_days
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

Target Radar

by eddiebelaval
7 stars

Target Radar is a multi-factor forecasting indicator that plots projection bands, forward boxes, and dynamic target zones directly on the main price chart. It calculates a forecast score by combining z-scores for trend, momentum, volume pressure, and volatilit

Indicator v5 TrendOscillators & momentum
Updated 3 months ago · None stated GitHub repository of Target Radar

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

MACD Breakout

by jerryinyang
5 stars

Calculates multi-timeframe Moving Average Convergence Divergence (MACD) alongside a Money Flow filter to identify potential market breakouts. It evaluates higher-timeframe MACD calculations using exponential or simple moving averages combined with Money Flow o

Indicator v4 TrendOscillators & momentum Repaints
Updated 2 years ago · None stated GitHub repository of MACD Breakout

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
257 stars

This indicator uses a Lorentzian distance k-nearest neighbors classification algorithm to predict market direction based on up to five technical features, such as RSI, WaveTrend, CCI, and ADX. It compares current feature values against historical bar patterns

Indicator v5 AI / machine learningOscillators & momentum
Updated 6 weeks ago · None stated GitHub repository of Donald - Machine Learning Options

Raschke Patterns

by TradersPost
218 stars

This overlay indicator marks Linda Raschke short-term bar setups on the price chart. It flags Turtle Soup and Turtle Soup plus one false breakouts of a prior extreme, 80-20 bars, inside bars, failed inside-bar breakouts, outside up and down bars, NR4 and NR7 c

Indicator v6 Candlestick patternsBreakout Repaints
Updated 3 months ago · None stated GitHub repository of Raschke Patterns

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