Indicator · Pine Script v5 · On the chart

TB: Main Indicators

by farias-hecdin

This indicator collects overlay tools for the price chart in one script.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code155
Settings28inputs
LicenceMIT
Last update1 year ago9 Feb 2025

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

155 lines of Pine Script v5 from tb-main-indicators.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

tb-main-indicators.pine
// @version=5
// Last update: 08-feb-2025

indicator(title="TB: Main-indicators", shorttitle="TB-M", overlay=true, scale = scale.none, max_lines_count=500)


// TS (Time separator ------------------------------------------------------

drawVLine(showLine, openHour, openMinute, lineColor) =>
    isHour = hour == openHour
    isMinute = minute == openMinute
    if (showLine and isHour and isMinute)
        line.new(bar_index, low - ta.tr, bar_index, high + ta.tr, xloc.bar_index, extend.both, lineColor, line.style_dashed, 1)

// TS 1
showLine1 = input.bool(defval = true, title = "Separator 1", group="Time separator")
openHour1 = input.int(defval = 23, title = "Hour: 0-23", minval = 0, maxval = 23, group="Time separator")
openMinute1 = input.int(defval = 0, title = "Minute: 0-30", minval = 0, maxval = 30, group="Time separator")
lineColor1 = input.color(defval = color.new(#00A5E3, 0), title = "Color", group="Time separator")
drawVLine(showLine1, openHour1, openMinute1, lineColor1)

// TS 2
showLine2 = input.bool(defval = true, title = "Separator 2", group="Time separator")
openHour2 = input.int(defval = 15, title = "Hour: 0-23", minval = 0, maxval = 23, group="Time separator")
openMinute2 = input.int(defval = 0, title = "Minute: 0-30", minval = 0, maxval = 30, group="Time separator")
lineColor2 = input.color(defval = color.new(#00A5E3, 0), title = "Color", group="Time separator")
drawVLine(showLine2, openHour2, openMinute2, lineColor2)


// DayOfWeek -----------------------------------------------------------------

color_sunday = color.new(#8DD7BF, 95)
color_monday = color.new(#FF5768, 95)
color_tuesday = color.new(#FFD700, 95)
color_wednesday = color.new(#8A2BE2, 95)
color_thursday = color.new(#FF6347, 95)
color_friday = color.new(#7CFC00, 95)
color_saturday = color.new(#1E90FF, 95)

bgcolor(dayofweek == 7 ? color_sunday :dayofweek == 1 ? color_monday : dayofweek == 2 ? color_tuesday : dayofweek == 3 ? color_wednesday : dayofweek == 4 ? color_thursday : dayofweek == 5 ? color_friday : dayofweek == 6 ? color_saturday : na,title="Days of the Week")


// EMA (Moving Average Exponential) ----------------------------------------

// EMA 1
lenEma_NjS = input.int(defval=100, minval=0, title="Length", group="EMA 1")
srcEma_NjS = input.source(close, title="Source", group="EMA 1")
ema_NjS = ta.ema(srcEma_NjS, lenEma_NjS)

plot(ema_NjS, color=color.new(#ffffff, 0), linewidth=1, title="EMA 1")

// EMA 2
lenEma_4NW = input.int(defval=50, minval=0, title="Length", group="EMA 2")
srcEma_4NW = input.source(close, title="Source", group="EMA 2")
ema_4NW = ta.ema(srcEma_4NW, lenEma_4NW)

plot(ema_4NW, color=color.new(#ffffff, 50), linewidth=1, title="EMA 2")


// S/R (Support and Resistance) --------------------------------------------

left = input.int(defval=3, title="Left bars", group="S/R")
right = input.int(defval=3, title="Right bars", group="S/R")
hih = ta.pivothigh(high, left, right)
lol = ta.pivotlow(low, left, right)
top = ta.valuewhen(hih, high[right], 0)
bot = ta.valuewhen(lol, low[right], 0)

plot(top, color=top != top[1] ? na : color.new(#0561f5, 0), offset=-left, title="S/R - resistance")
plot(bot, color=bot != bot[1] ? na : color.new(#0561f5, 0), offset=-left, title="S/R - support")


// DC (Donchian Channels) --------------------------------------------------

length = input.int(defval=20, minval=1, title="Length", group="DC")
lower = ta.lowest(length)
upper = ta.highest(length)
basis = math.avg(upper, lower)

p_basis = plot(basis, "DC - basis", color=color.new(color.teal, 0))
p_upper = plot(upper, "DC - upper", color=color.new(color.blue, 0))
p_lower = plot(lower, "DC - lower", color=color.new(color.orange, 0))
fill(p_upper, p_lower, color=color.rgb(33, 150, 243, 95), title="DC - background")


// ATR (Average True Range) ------------------------------------------------

lenATR = input.int(defval=14, minval=1, title="Period", group="ATR")
multiplier_4NW = input.float(defval=1.5, minval=0.1, step=0.1, title="Multiplier", group="ATR")
shortStopLoss = close + ta.atr(lenATR) * multiplier_4NW
longStopLoss = close - ta.atr(lenATR) * multiplier_4NW

plot(shortStopLoss, color=color.new(color.black, 0), style=plot.style_cross, title="ATR - short")
plot(longStopLoss, color=color.new(color.black, 0), style=plot.style_cross, title="ATR - long")


// HMA (Hull Moving Average) -----------------------------------------------

hmaLength = input.int(title="Length", defval=25, group="HMA")
tf = input.timeframe(title="Timeframe", defval="", group="HMA")
source = input(close, title="Source", group="HMA")

hullma = ta.wma(2 * ta.wma(source, hmaLength/2) - ta.wma(source, hmaLength), math.floor(math.sqrt(hmaLength)))
hma = request.security(syminfo.tickerid, timeframe=tf, expression=hullma, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)

plot(hma, title="HMA", color=color.orange, linewidth=1)


// ST (Supertrend) ---------------------------------------------------------

periods = input.int(title="ATR period", defval=10, group="Supertrend")
multiplier = input.float(title="ATR multiplier", step=0.1, defval=1.7, group="Supertrend")
changeATR = input.bool(title="Change ATR calculation method", defval=false, group="Supertrend")
src = input.source(hl2, title="Source", group="Supertrend")

atr = changeATR ? ta.atr(periods) : ta.sma(ta.tr, periods)

up = src - (multiplier * atr)
dn = src + (multiplier * atr)
up := close[1] > nz(up[1], up) ? math.max(up, nz(up[1], up)) : up
dn := close[1] < nz(dn[1], dn) ? math.min(dn, nz(dn[1], dn)) : dn

trend = 1
trend := nz(trend[1], 1)
trend := trend == -1 and close > nz(dn[1], dn) ? 1 : trend == 1 and close < nz(up[1], up) ? -1 : trend

upPlot = plot(trend == 1 ? up : na, title="ST - upTrend", style=plot.style_linebr, linewidth=2, color=color.new(color.blue, 0))
dnPlot = plot(trend == -1 ? dn : na, title="ST - downTrend", style=plot.style_linebr, linewidth=2, color=color.new(color.rgb(42, 46, 57, 0), 0))


// ICH (Ichimoku cloud) ----------------------------------------------------

// Parámetros de entrada
conversionPeriods = input.int(defval=10, minval=1, title="Conversion line (kijun-sen)", group="Ichimoku")
basePeriods = input.int(defval=30, minval=1, title="Base line (kijun-sen)", group="Ichimoku")
laggingSpan2Periods = input.int(defval=60, minval=1, title="Leading span B (senkou span B)", group="Ichimoku")
displacement = input.int(defval=30, minval=1, title="Displacement", group="Ichimoku")

donchian(len) =>
    math.avg(ta.lowest(len), ta.highest(len))

conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)

plot(conversionLine, color=color.yellow, title="ICH - conversion line")
plot(baseLine, color=color.red, title="ICH - base line")
plot(close, color=color.navy, title="ICH - lagging span", offset=-displacement + 1, linewidth=2)
plot(ta.cross(conversionLine, baseLine) ? conversionLine : na, color=color.white, style=plot.style_cross, linewidth=4, title="ICH - cross")

p1 = plot(leadLine1, offset=displacement - 1, color=color.green, title="ICH - leading span A")
p2 = plot(leadLine2, offset=displacement - 1, color=color.red, title="ICH - leading span B")

fill(p1, p2, color=leadLine1 > leadLine2 ? color.new(color.green, 50) : color.new(color.red, 50), title="ICH - kumo")

Overview

TB: Main Indicators draws two configurable vertical time separators, tints the background by day of week, and plots two EMAs of 100 and 50 periods. It also marks support and resistance from pivot highs and lows, a Donchian channel and an ATR-based band, a Hull moving average, a Supertrend and an Ichimoku cloud. Each part has its own length and source settings.

Details

Published by

farias-hecdin on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages, Support & resistance, Sessions & time

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

pinescript

Settings

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

SettingTypeDefaultVariable
Separator 1booltrueshowLine1
Hour: 0-23int23openHour1
Minute: 0-30int0openMinute1
Colorcolorcolor.new(#00A5E3, 0)lineColor1
Separator 2booltrueshowLine2
Hour: 0-23int15openHour2
Minute: 0-30int0openMinute2
Colorcolorcolor.new(#00A5E3, 0)lineColor2
Lengthint100lenEma_NjS
SourcesourceclosesrcEma_NjS
Lengthint50lenEma_4NW
SourcesourceclosesrcEma_4NW
Show all 28 settings
SettingTypeDefaultVariable
Left barsint3left
Right barsint3right
Lengthint20length
Periodint14lenATR
Multiplierfloat1.5multiplier_4NW
Lengthint25hmaLength
Timeframetimeframetf
Sourcesourceclosesource
ATR periodint10periods
ATR multiplierfloat1.7multiplier
Change ATR calculation methodboolfalsechangeATR
Sourcesourcehl2src
Conversion line (kijun-sen)int10conversionPeriods
Base line (kijun-sen)int30basePeriods
Leading span B (senkou span B)int60laggingSpan2Periods
Displacementint30displacement
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

Pivot Trendlines

by g-moe
3 stars

This indicator identifies pivot highs and lows using a swing lookback period and connects them with trendlines on the price chart. It generates long and short entry signals when price moves through predefined percentage thresholds in three steps for buy and se

Indicator v5 TrendSupport & resistance
Updated 5 months ago · None stated GitHub repository of Pivot Trendlines
2 stars

The Day Trading Strategy v1 indicator displays key intraday technical levels and signal markers on the main price chart. It plots standard 8 and 21 SMAs, multi-timeframe 200 SMAs (5m, 10m, 1h), session VWAP, pre-market high/low levels, and the initial 9:30–9:4

Indicator v6 TrendMoving averages
Updated 6 months ago · None stated GitHub repository of Day Trading Strategy v1
257 stars

This indicator plots auto trade signals for E-mini S&P 500 futures on the price chart. It computes an EMA200 filter along with day ETH RTH session levels and percentage-based entry zones. Signals trigger CALL or PUT cases when price crosses defined thresholds

Indicator v6 TrendSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of Auto Trade Futures ES

Ichimoku Cloud

by harryguiacorn
219 stars

This indicator plots Ichimoku Cloud elements on the price chart, including Tenkan-sen, Kijun-sen, Senkou Span A and B lines with optional Chikou Span. It signals trend changes via Tenkan-sen and Kijun-sen crosses and places arrows at Kijun-sen direction shifts

Indicator v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ichimoku Cloud

Midnight VWAP

by TradersPost
218 stars

The Midnight VWAP indicator calculates and overlays two distinct Volume Weighted Average Price (VWAP) lines on the price chart based on customizable session timeframes. It tracks an overnight or pre-market session alongside regular trading hours, resetting cal

Indicator v6 Moving averagesSessions & time
Updated 3 months ago · None stated GitHub repository of Midnight VWAP

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