Indicator · Pine Script v6 · On the chart

Impulse Trend Arrows

by MeridianAlgo

Calculates an adaptive baseline using an EMA and constructs an ATR channel smoothed over a user-defined length.

View on GitHub

GitHub stars9on the repository
Pine versionv6current
Lines of code133
Settings9inputs
LicenceMIT
Last update4 months ago29 Jun 2026

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

133 lines of Pine Script v6 from examples/Impulse_Trend_Arrows.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

Impulse_Trend_Arrows.pine
//@version=6
indicator("Impulse Trend Arrows", shorttitle="Impulse Trend Arrows", overlay=true)

//------------------------
// User Inputs 
//------------------------
basisLen      = input.int(50, "Adaptive Baseline Length")
showBands     = input.bool(true, "Show ATR Bands")
showBg        = input.bool(true, "Background Shading")
showArrows    = input.bool(true, "Show Entry Arrows")

// Visual options
smoothLen     = input.int(8, "Channel Smoothing", minval=1) // chanel smotther, the more the smoother!
baseColorIn   = input.color(color.new(#5f5f5f, 0), "Baseline Color")
upColorIn     = input.color(color.new(#000000, 0), "Upper Band Color")
dnColorIn     = input.color(color.new(#000000, 0), "Lower Band Color")
fillColorIn   = input.color(color.new(color.blue, 75), "Channel Fill Color")


atrLen   = 14
atrMult  = 2.0
rsiLen   = 14
macdFast = 12
macdSlow = 26
macdSig  = 9

// Main Logic

basis   = ta.ema(close, basisLen)
atr     = ta.atr(atrLen)
upBand  = basis + atrMult * atr
dnBand  = basis - atrMult * atr

impulseUp = close > basis and close > upBand
impulseDn = close < basis and close < dnBand

rsi       = ta.rsi(close, rsiLen)
macdLine  = ta.ema(close, macdFast) - ta.ema(close, macdSlow)
macdSigLn = ta.ema(macdLine, macdSig)
macdHist  = macdLine - macdSigLn

momUp = rsi > 50 and macdHist > 0
momDn = rsi < 50 and macdHist < 0

longCond  = impulseUp and momUp
shortCond = impulseDn and momDn

var string lastSignal = "NONE"
newBuy  = longCond  and lastSignal != "BUY"
newSell = shortCond and lastSignal != "SELL"

if newBuy
    lastSignal := "BUY"
else if newSell
    lastSignal := "SELL"


basisSmoothed  = ta.ema(basis, smoothLen)
upBandSmoothed = ta.ema(upBand, smoothLen)
dnBandSmoothed = ta.ema(dnBand, smoothLen)

plot(basisSmoothed, "Baseline", baseColorIn, 3)

pUp = plot(showBands ? upBandSmoothed : na, "ATR Upper", upColorIn)
pDn = plot(showBands ? dnBandSmoothed : na, "ATR Lower", dnColorIn)

fill(pUp, pDn, fillColorIn)

//------------------------
// Arrows shifted OUTSIDE channel
//------------------------
arrowOffsetFactor = 2.0   // how far outside the channel (2x ATR below/above)
textOffsetFactor  = 0.8   // distance between arrow and text

buyArrowY  = dnBandSmoothed - atr * arrowOffsetFactor
buyTextY   = buyArrowY     - atr * textOffsetFactor

sellArrowY = upBandSmoothed + atr * arrowOffsetFactor
sellTextY  = sellArrowY    + atr * textOffsetFactor

if showArrows and newBuy
    // Arrow below channel
    label.new(
         bar_index, buyArrowY,
         text      = "",
         style     = label.style_triangleup,
         color     = color.new(color.green, 0),
         textcolor = color.white,
         size      = size.large)
    // BUY text under the arrow
    label.new(
         bar_index, buyTextY,
         text      = "BUY",
         style     = label.style_label_center,
         color     = color.new(color.green, 85),
         textcolor = color.new(#6186ff, 0),
         size      = size.small)

if showArrows and newSell
    // Arrow above channel
    label.new(
         bar_index, sellArrowY,
         text      = "",
         style     = label.style_triangledown,
         color     = color.new(color.red, 0),
         textcolor = color.white,
         size      = size.large)
    // SELL text above the arrow
    label.new(
         bar_index, sellTextY,
         text      = "SELL",
         style     = label.style_label_center,
         color     = color.new(color.red, 85),
         textcolor = color.new(#6186ff, 0),
         size      = size.small)

//------------------------
// Background + TOP panel
//------------------------
neutralColor = color.new(color.gray, 82)
bgColorUp    = color.new(color.green, 65)
bgColorDn    = color.new(color.red, 65)

bgcolor(showBg ? (lastSignal == "BUY" ? bgColorUp : lastSignal == "SELL" ? bgColorDn : neutralColor) : na)

var table panel = table.new(position.top_center, 1, 3, border_width=1)
trend = lastSignal == "BUY" ? 1 : lastSignal == "SELL" ? -1 : 0
trendText  = trend == 1 ? "UPTREND" : trend == -1 ? "DOWNTREND" : "NEUTRAL"
trendColor = trend == 1 ? color.rgb(1, 126, 66) : trend == -1 ? color.rgb(200, 0, 0) : color.gray

if barstate.islast
    table.cell(panel, 0, 0, "CURRENT TREND DIRECTION", text_color=color.white, bgcolor=color.black, width=27)
    table.cell(panel, 0, 1, trendText, text_color=color.white, bgcolor=trendColor, width=25)

Overview

Impulse Trend Arrows combines channel breakout conditions with RSI and MACD momentum agreement to generate buy and sell signals. Signals are displayed on the main price chart as directional arrow labels positioned outside the channel band. User settings allow toggling ATR bands, background shading, arrows, baseline lengths, and channel smoothing.

Details

Published by

MeridianAlgo on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Trend, Oscillators & momentum, Volatility & bands

Markets

Any symbol

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

code-converterconverterjavascriptpinescripttranspilercode-reviewmeridianalgocode-conversionpinescript-algorithms

Settings

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

SettingTypeDefaultVariable
Adaptive Baseline Lengthint50basisLen
Show ATR BandsbooltrueshowBands
Background ShadingbooltrueshowBg
Show Entry ArrowsbooltrueshowArrows
Channel Smoothingint8smoothLen
Baseline Colorcolorcolor.new(#5f5f5f, 0)baseColorIn
Upper Band Colorcolorcolor.new(#000000, 0)upColorIn
Lower Band Colorcolorcolor.new(#000000, 0)dnColorIn
Channel Fill Colorcolorcolor.new(color.blue, 75)fillColorIn
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

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

An overlay indicator that combines an ATR-based SuperTrend trailing stop with an integrated RSI-derived midline calculation on the price chart. The SuperTrend uses an ATR period and factor multiplier to plot dynamic green or red trend lines based on price dire

Indicator v5 TrendVolatility & bands
Updated 6 weeks ago · None stated GitHub repository of SuperTrend ATR + RSI
114 stars

ADX Strategy (original) is an overlay indicator that identifies trend-following trade signals using the Average Directional Index (ADX) combined with a Simple Moving Average filter. A long signal is generated when the ADX rises above a user-defined trend level

Indicator v4 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Strategy (original)

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev Lunar Sniper
56 stars

Double Screened Decision is a multi-timeframe trend and momentum indicator overlaid directly on the price chart. It dynamically selects a higher timeframe based on the active chart resolution to evaluate higher-timeframe MACD, Bollinger Bands, RSI, and Stochas

Indicator v5 TrendMoving averages Repaints
Updated 4 months ago · None stated GitHub repository of Double Screened Decision
55 stars

The VibeTrader Signal System is an overlay indicator that identifies trend direction and potential reversal conditions. It calculates a Supertrend line alongside Bollinger Bands and a 14-period RSI indicator. The script highlights bullish and bearish trends by

Indicator v6 TrendVolatility & bands
Updated 6 months ago · Apache-2.0 GitHub repository of VibeTrader Signal System

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