Indicator · Pine Script v5 · On the chart

MicroQuant Trend

by g-moe· code credited to goodgains

MicroQuant Trend is a Supertrend-based indicator that calculates dynamic bands using EMA of high and low prices adjusted by ATR.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code53
Settings4inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 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

53 lines of Pine Script v5 from Tradingview/microquant-trend.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

microquant-trend.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator("MicroQuant Trend", overlay = true, max_labels_count = 500)

// @keywords: microquant-trend, custom-supertrend, atr-bands, ema-high-low, trend-direction, up-trend-plot, down-trend-plot, trend-flip-alert, buy-alert, sell-alert, background-flip, traders-post-signal, hull-atr-variant, band-ratcheting, direction-state, overlay-circles, trend-reversal, factor-multiplier, sma-true-range, position-change


price = input.source(close, title = 'Price')
length = input.int(21, title = 'Length')
atrPeriod = input.int(21, "ATR Length")
factor = input.float(4.0, "Factor", step = 0.1)

// The same on Pine Script™
pine_supertrend() =>
    atr = ta.sma(ta.tr, atrPeriod)
    lowerBand = ta.highest(ta.ema(high, length), length) - atr * factor
    upperBand = ta.lowest(ta.ema(low, length), length) + atr * factor
    prevLowerBand = nz(lowerBand[1])
    prevUpperBand = nz(upperBand[1])

    lowerBand := lowerBand > prevLowerBand or price[1] < prevLowerBand ? lowerBand : prevLowerBand
    upperBand := upperBand < prevUpperBand or price[1] > prevUpperBand ? upperBand : prevUpperBand
    int direction = na
    float superTrend = na
    prevSuperTrend = superTrend[1]
    if na(atr[1])
        direction := 1
    else if prevSuperTrend == prevUpperBand
        direction := price > upperBand ? -1 : 1
    else
        direction := price < lowerBand ? 1 : -1
    superTrend := direction == -1 ? lowerBand : upperBand
    [superTrend, direction]

[pineSupertrend, pineDirection] = pine_supertrend()
plot(pineDirection < 0 ? pineSupertrend : na, "Up direction", color = color.green, style=plot.style_circles)
plot(pineDirection > 0 ? pineSupertrend : na, "Down direction", color = color.red, style=plot.style_circles)


var bool tradersPostBuy = na
var bool tradersPostSell = na
tradersPostBuy := pineDirection < 0 and pineDirection[1] >= 0
tradersPostSell := pineDirection > 0 and pineDirection[1] <= 0

alertcondition(tradersPostBuy, title="MicroQuant Trend Buy")
alertcondition(tradersPostSell, title="MicroQuant Trend Sell")



bgcolor(tradersPostBuy ? color.green : tradersPostSell ? color.red : na)

Overview

MicroQuant Trend plots green circles for uptrend direction and red for downtrend. Background colors change to green or red when the trend flips. Buy alerts occur on direction reversal from up to down, sell on down to up. Settings allow customization of price source, band length, ATR period, and factor. It overlays on the price chart.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages, 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.

Settings

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

SettingTypeDefaultVariable
Pricesourcecloseprice
Lengthint21length
ATR Lengthint21atrPeriod
Factorfloat4.0factor
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

318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon

Bollinger Bands Force

by harryguiacorn
219 stars

This indicator modifies standard Bollinger Bands to measure directional trend force based on line alignment. It calculates a simple moving average basis along with upper and lower volatility bands. When all three lines move upward or downward simultaneously, i

Indicator v5 Volatility & bandsTrend
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Force

Adaptive MA Slope

by capissimo
114 stars

This indicator calculates Kaufman's Adaptive Moving Average (KAMA) on a chosen price source and determines trend direction based on the slope across a configurable lookback window. Signals can be filtered by short-term volatility expansion using ATR comparison

Indicator v4 Moving averagesTrend
Updated 1 year ago · None stated GitHub repository of Adaptive MA Slope

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