Indicator · Pine Script v5 · On the chart

MasterAlgo

by TamTH-Dev· code credited to tamth_

MasterAlgo is an overlay indicator that combines Ichimoku Kinko Hyo, session range highlights, and volume-based candle coloring into a single tool.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code241
Settings31inputs
LicenceNone statedfile: MPL-2.0
Last update5 weeks ago18 Sep 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

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

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

// @version=5
indicator(title = "MasterAlgo", shorttitle = "MasterAlgo", overlay = true, max_bars_back = 500, max_boxes_count = 500, max_lines_count = 500, max_labels_count = 500)


//-----------------------------------------------------------------------------*
//  Constants
//-----------------------------------------------------------------------------{
color TRANSPARENT_COLOR = #ffffff00
color WHITE_COLOR = #ffffff
color RED_COLOR = #e91e62
color AQUA_COLOR = #00bbf9
color LIGHT_GRAY_COLOR = #364156
color DARK_GRAY_COLOR = #212d40
color GREEN_COLOR = #A4F233
color YELLOW_COLOR = #F2CA63
color PURPLE_COLOR = #764AF1
color PINK_COLOR = #D557F2
color TXT_COLOR = #787b86
color BLOCK_COLOR = #5d606b19

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Common Functions
//-----------------------------------------------------------------------------{
debug(simple string txt) =>
    // Create label on the first bar
    var label = label.new(bar_index, na, txt, xloc.bar_index, yloc.price, color(na), label.style_none, WHITE_COLOR, size.large, text.align_left)
    // On next bars, update the label"s x and y position, and the text it displays
    label.set_xy(label, bar_index, ta.highest(10)[1])
    label.set_text(label, txt)

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Ichimoku Kinko Hyo
//-----------------------------------------------------------------------------*
// Settings
//-----------------------------------------------------------------------------{
string ikhGrp = "Ichimoku Kinko Hyo"
bool ikhShowed = input.bool(false, title = "Show", group = ikhGrp)
int tenkanLen = input.int(9, minval = 1, title = "Tenkan-Sen Length", group = ikhGrp)
int kijunLen = input.int(26, minval = 1, title = "Kijun-Sen Length", group = ikhGrp)
int senkouSpanBLen = input.int(52, minval = 1, title = "Senkou-Span B Length", group = ikhGrp)
int chikouSpanDisplacement = input.int(26, minval = 1, title = "Chikou-Span Displacement", group = ikhGrp)
int kumoCloudDisplacement = input.int(26, minval = 1, title = "Kumo Cloud Displacement", group = ikhGrp)


//------------------------------------------------------------------------------
// Get lines' value
//-----------------------------------------------------------------------------{
getDonchian(len) => math.avg(ta.lowest(len), ta.highest(len))

float tenkan = getDonchian(tenkanLen)
float kijun = getDonchian(kijunLen)
float senkouSpanA = math.avg(tenkan, kijun)
float senkouSpanB = getDonchian(senkouSpanBLen)


//------------------------------------------------------------------------------
// Set lines and kumo cloud
//-----------------------------------------------------------------------------{
plot(ikhShowed ? tenkan : na, color = AQUA_COLOR, title = "Tenkan-Sen", display = display.pane)
plot(ikhShowed ? kijun : na, color = RED_COLOR, title = "Kijun-Sen", display = display.pane)
plot(ikhShowed ? close : na, offset = -chikouSpanDisplacement + 1, color = PURPLE_COLOR, title = "Chikou-Span", display = display.pane)
senkouSpanAPlot = plot(ikhShowed ? senkouSpanA : na, offset = kumoCloudDisplacement - 1, color = LIGHT_GRAY_COLOR, title = "Senkou-Span A", display = display.pane)
senkouSpanBPlot = plot(ikhShowed ? senkouSpanB : na, offset = kumoCloudDisplacement - 1, color = LIGHT_GRAY_COLOR, title = "Senkou-Span B", display = display.pane)
fill(senkouSpanAPlot, senkouSpanBPlot, color = senkouSpanA > senkouSpanB ? color.new(DARK_GRAY_COLOR, 60) : color.new(LIGHT_GRAY_COLOR, 0))

//-----------------------------------------------------------------------------}





//-----------------------------------------------------------------------------*
// Sessions
//-----------------------------------------------------------------------------*
// Settings
//-----------------------------------------------------------------------------{
string sesGrp = "Sessions"
bool sesShowed = input.bool(false, 'Showed', group = sesGrp)

bool newYorkSesShowed = input.bool(true, '', inline = 'newYork', group = sesGrp)
string newYorkTxt = input.string('New York', '', inline = 'newYork', group = sesGrp)
var newYorkSesTime = input.session('1300-2200', '', inline = 'newYork', group = sesGrp)
color newYorkSesCss = input.color(RED_COLOR, '', inline = 'newYork', group = sesGrp)

bool londonSesShowed = input.bool(true, '', inline = 'london', group = sesGrp)
string londonTxt = input.string('London', '', inline = 'london', group = sesGrp)
var londonSesTime = input.session('0800-1700', '', inline = 'london', group = sesGrp)
color londonSesCss = input.color(AQUA_COLOR, '', inline = 'london', group = sesGrp)

bool asiaSesShowed = input.bool(true, '', inline = 'asia', group = sesGrp)
string asiaTxt = input.string('Asia', '', inline = 'asia', group = sesGrp)
var asiaSesTime = input.session('2000-0900', '', inline = 'asia', group = sesGrp)
color asiaSesCss = input.color(YELLOW_COLOR, '', inline = 'asia', group = sesGrp)

bool sesOutlineShowed = input.bool(true, 'Range Outline', group = sesGrp)
bool sesTxtShowed = input.bool(true, 'Range Label', group = sesGrp)
bool sesExchangeUsed = input.bool(false, 'Use Exchange Timezone', group = sesGrp)
int sesTzIncr = input.int(0, 'UTC (+/-)', group = sesGrp)
float sesBgTransp = input.float(95, 'Range Area Transparency', group = sesGrp)

//-----------------------------------------------------------------------------}
// Functions
//-----------------------------------------------------------------------------{
showSessions(ses, sesName, sesCss)=>
    var t = 0 
    var max = high
    var min = low
    var box bx = na
    var label lbl = na 
    
    if ses > ses[1]
        t := time
        max := high
        min := low
        bx := box.new(bar_index, max, bar_index, min
          , bgcolor = color.new(sesCss, sesBgTransp)
          , border_color = sesOutlineShowed ? color.new(sesCss, 40) : na
          , border_style = line.style_dotted)

        if sesTxtShowed
            lbl := label.new(t, max, sesName
              , xloc = xloc.bar_time
              , textcolor = sesCss
              , style = label.style_label_down
              , color = color.new(color.white, 100)
              , size = size.tiny)

    if ses and ses == ses[1]
        max := math.max(high, max)
        min := math.min(low, min)
        box.set_top(bx, max)
        box.set_rightbottom(bx, bar_index, min)

        if sesTxtShowed
            label.set_xy(lbl, int(math.avg(t, time)), max)

//-----------------------------------------------------------------------------}
// Sessions
//-----------------------------------------------------------------------------{
string tf = timeframe.period
var tz = sesExchangeUsed ? syminfo.timezone : str.format('UTC{0}{1}', sesTzIncr >= 0 ? '+' : '-', math.abs(sesTzIncr))
isNewYorkSes = math.sign(nz(time(tf, newYorkSesTime, tz)))
isLondonSes = math.sign(nz(time(tf, londonSesTime, tz)))
isAsiaSes = math.sign(nz(time(tf, asiaSesTime, tz)))

//-----------------------------------------------------------------------------}
// Overlays
//-----------------------------------------------------------------------------{
if newYorkSesShowed and sesShowed
    showSessions(isNewYorkSes, newYorkTxt, newYorkSesCss)

if londonSesShowed and sesShowed
    showSessions(isLondonSes, londonTxt, londonSesCss)

if asiaSesShowed and sesShowed
    showSessions(isAsiaSes, asiaTxt, asiaSesCss)

//-----------------------------------------------------------------------------}





//-----------------------------------------------------------------------------*
// EMA 8
//-----------------------------------------------------------------------------*
series float ema8 = ta.ema(close, 8)
plot(ema8, title = "EMA 8", color = LIGHT_GRAY_COLOR, display = display.pane)

//-----------------------------------------------------------------------------}





//-----------------------------------------------------------------------------*
// Vector Candles
//-----------------------------------------------------------------------------*
// Settings
//-----------------------------------------------------------------------------{
string vcsGrp = "Vector Candles"
bool vcsShowed = input.bool(true, title = "Show", group = vcsGrp)
color lgVolUpCandleColor = input.color(GREEN_COLOR, title = "Large Volume Up Candle Color", group = vcsGrp)
color mdVolUpCandleColor = input.color(YELLOW_COLOR, title = "Medium Volume Up Candle Color", group = vcsGrp)
color lgVolDnCandleColor = input.color(PURPLE_COLOR, title = "Large Volume Down Candle Color", group = vcsGrp)
color mdVolDnCandleColor = input.color(PINK_COLOR, title = "Medium Volume Down Candle Color", group = vcsGrp)
string ncsGrp = "Normal Candles"
color norUpCandleColor = input.color(AQUA_COLOR, title = "Normal Up Candle Color", group = ncsGrp)
color norDnCandleColor = input.color(RED_COLOR, title = "Normal Down Candle Color", group = ncsGrp)

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Functions
//-----------------------------------------------------------------------------{
getVcsColor(series float _vol, series float _high, series float _low, series float _close, series float _open, simple color lgVolDnCandleColor, simple color lgVolUpCandleColor, simple color mdVolDnCandleColor, simple color mdVolUpCandleColor, simple color norDnCandleColor, simple color norUpCandleColor) =>
    float avgVol = math.sum(_vol[1], 10) / 10.0
    float volSpread = _vol * (_high - _low)
    float highestVolSpread = ta.highest(volSpread[1], 10)
    color vcsColor = na
    
    // Large volume
    if (_vol >= 2 * avgVol or volSpread >= highestVolSpread) and vcsShowed
        vcsColor := _close > _open ? lgVolUpCandleColor : lgVolDnCandleColor
    // Medium volume
    else if _vol >= 1.5 * avgVol and vcsShowed
        vcsColor := _close > _open ? mdVolUpCandleColor : mdVolDnCandleColor
    // Normal volume
    else
        vcsColor := _close > _open ? norUpCandleColor : norDnCandleColor

    vcsColor

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Get Values
//-----------------------------------------------------------------------------{
[_vol, _high, _low, _close, _open] = request.security(syminfo.tickerid, timeframe.period, [volume,high,low,close,open], barmerge.gaps_off, barmerge.lookahead_off)

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Render Vector Candles
//-----------------------------------------------------------------------------{
series color vcsColor = getVcsColor(_vol, _high, _low, _close, _open, lgVolDnCandleColor, lgVolUpCandleColor, mdVolDnCandleColor, mdVolUpCandleColor, norDnCandleColor, norUpCandleColor)
barcolor(vcsColor)

//-----------------------------------------------------------------------------}

Overview

MasterAlgo plots standard Ichimoku components—including Tenkan-Sen, Kijun-Sen, Chikou Span, and Kumo Cloud—and highlights customizable session ranges for London, New York, and Asia. Additionally, it recolors candles according to volume activity levels. Users can independently toggle each module, modify Ichimoku periods, adjust session hours and timezones, and set custom colors for different volume thresholds.

Details

Published by

TamTH-Dev on GitHub

Code credit

tamth_, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Sessions & time, Volume, Trend

Markets

Any symbol

Timeframes

M1-M5, 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
ShowboolfalseikhShowed
Tenkan-Sen Lengthint9tenkanLen
Kijun-Sen Lengthint26kijunLen
Senkou-Span B Lengthint52senkouSpanBLen
Chikou-Span Displacementint26chikouSpanDisplacement
Kumo Cloud Displacementint26kumoCloudDisplacement
ShowedboolfalsesesShowed
newYorkSesShowedbooltruenewYorkSesShowed
newYorkTxtstringNew YorknewYorkTxt
newYorkSesTimesession1300-2200newYorkSesTime
newYorkSesCsscolorRED_COLORnewYorkSesCss
londonSesShowedbooltruelondonSesShowed
Show all 31 settings
SettingTypeDefaultVariable
londonTxtstringLondonlondonTxt
londonSesTimesession0800-1700londonSesTime
londonSesCsscolorAQUA_COLORlondonSesCss
asiaSesShowedbooltrueasiaSesShowed
asiaTxtstringAsiaasiaTxt
asiaSesTimesession2000-0900asiaSesTime
asiaSesCsscolorYELLOW_COLORasiaSesCss
Range OutlinebooltruesesOutlineShowed
Range LabelbooltruesesTxtShowed
Use Exchange TimezoneboolfalsesesExchangeUsed
UTC (+/-)int0sesTzIncr
Range Area Transparencyfloat95sesBgTransp
ShowbooltruevcsShowed
Large Volume Up Candle ColorcolorGREEN_COLORlgVolUpCandleColor
Medium Volume Up Candle ColorcolorYELLOW_COLORmdVolUpCandleColor
Large Volume Down Candle ColorcolorPURPLE_COLORlgVolDnCandleColor
Medium Volume Down Candle ColorcolorPINK_COLORmdVolDnCandleColor
Normal Up Candle ColorcolorAQUA_COLORnorUpCandleColor
Normal Down Candle ColorcolorRED_COLORnorDnCandleColor
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

Equity Intraday Analyst

by chris-c-thomas
14 stars

Equity Intraday Analyst is a comprehensive intraday overlay indicator for US equities and ETFs. It evaluates multi-EMA ribbons, session-anchored VWAP bands, OBV trends, momentum oscillators, TTM Squeeze, and optional market breadth indicators like NYSE TICK an

Indicator v6 TrendVolume
Updated 6 months ago · MIT GitHub repository of Equity Intraday Analyst

SUMMARY

by ryangaraygay
2 stars

This indicator aggregates multiple technical signals into an on-chart summary table. It calculates a session-based VWAP, a triple-EMA-smoothed price-volume oscillator, an EMA 9/21 trend spread, multi-timeframe Donchian channel breakouts, and an opening range h

Indicator v6 Screeners & dashboardsSessions & time
Updated 1 year ago · MIT GitHub repository of SUMMARY

This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper
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
219 stars

An educational Pine Script v4 indicator demonstrating how to plot volume histograms on the main price chart using unscaled axes. The code includes examples and commented templates for creating vertical line markers at specific dates or time zones, such as mark

Indicator v4 Sessions & timeVolume
Updated 5 years ago · None stated GitHub repository of 教學-畫垂直線1

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