Indicator · Pine Script v4 · On the chart

TPCharts Asia Extensions

by TPCharts

TPCharts Asia Extensions calculates and identifies horizontal price extension levels based on the high and low range of the Asian trading session defined in GMT hours.

View on GitHub

GitHub stars10on the repository
Pine versionv4older, still runs
Lines of code193
Settings10inputs
LicenceGPL-3.0
Last update5 years ago1 Dec 2020

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

193 lines of Pine Script v4 from TPCharts-Asian-Extensions.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

TPCharts-Asian-Extensions.pine
//@version=4
study("TPCharts Asia Extensions", overlay=true)

//
// START TPCharts Utils
//
toPips(v) => syminfo.type == 'forex' ? v/syminfo.mintick/10 : v

getPrice(condition, ohlc) => 
    float ret = na
    if condition and na(ret[1])
        if ohlc == "o"
            ret := open
    else
        ret := ret[1]
    ret[0]

uVal(interval, amount) => 
    iDay = 86400000
    iWeek = iDay * 6 // Assuming Sunday not included in chart
    iHour = iDay / 24
    iMinute = iHour / 60

    multiplier = 0

    if interval=="W"
        multiplier := iWeek

    if interval=="D"
        multiplier := iDay
    
    if interval=="60"
        multiplier := iHour

    multiplier * amount

drawLine(price, timeStart, timeEnd) => 
    line.new(x1=timeStart, y1=price, x2=timeEnd, y2=price, extend=extend.none, xloc=xloc.bar_time, color=color.new(color.black, 50))

drawLineLabelAlign(line, text, alignment) =>
    align = timenow

    if alignment == "l"
        align := line.get_x1(line)

    if alignment == "r"
        align := line.get_x2(line)

    if alignment == "c"
        align := timenow < line.get_x2(line) ? timenow+uVal("60", 1) : line.get_x2(line)+uVal("60", 1)

    label.new(align, line.get_y1(line), text, style=label.style_none, color=color.black, xloc=xloc.bar_time, size=size.small)

drawLineLabel(line, text) => drawLineLabelAlign(line, text, "r")

getSValText(condition, text, value) => condition ? text + " (" + value + ")" : text

getValText(condition, text, value) => getSValText(condition, text, tostring(value))



//
//END TPCharts Utils
//

var hourSessionStart = input(0, "Asia session start hour (GMT)", minval=0, maxval=23)
var hourSessionStop  = input(5, "Asia session end hour (GMT)", minval=0, maxval=23)
var extend  = input(title="Extend?", type=input.bool, defval=false)
var extCount  = input(title="How Many Extensions?", type=input.integer, defval=10)
var showLower  = input(title="Show Lower?", type=input.bool, defval=false)
var showUpper  = input(title="Show Upper?", type=input.bool, defval=true)
var showExtLabels  = input(title="Show Labels?", type=input.bool, defval=true)
var showExtPrices = input(title="Show Prices?", type=input.bool, defval=true)
var showExtNumbers = input(title="Show Extension Numbers?", type=input.bool, defval=true)
var showExtDayofWeek = input(title="Show Extension Day of Week?", type=input.bool, defval=true)

// var showMo = input(title="Show Monday?", type=input.bool, defval=true)
// var showTu = input(title="Show Tuesday?", type=input.bool, defval=true)
// var showWe = input(title="Show Wednesday?", type=input.bool, defval=true)
// var showTh = input(title="Show Thursday?", type=input.bool, defval=true)
// var showFr = input(title="Show Friday?", type=input.bool, defval=true)
// var showSa = input(title="Show Saturday?", type=input.bool, defval=false)

var float hi              = na
var float lo              = na
var float plotHi          = na
var float plotLo          = na

var float extBase = na
var float ext1 = na
var float ext2 = na
var float ext3 = na
var float ext4 = na
var float ext5 = na
var float extn1 = na
var float extn2 = na
var float extn3 = na
var float extn4 = na
var float extn5 = na

var int   currentHourGMT  = na
var bool  inSession       = na
var bool  enteringSession = na
var bool  exitingSession  = na
var bool showLabel = false
var int startBI = na
var int exitBI = na

currentHourGMT  := hour(time, "GMT")

inSession       := (currentHourGMT >= hourSessionStart and currentHourGMT < hourSessionStop)
enteringSession := inSession and not inSession[1]
exitingSession  := not inSession and inSession[1]

extTextPrefix = "AR"

getHumanDate() =>
    ret = ""
    if dayofweek == dayofweek.sunday
        ret := "Su"
    if dayofweek == dayofweek.monday
        ret := "Mo"
    if dayofweek == dayofweek.tuesday
        ret := "Tu"
    if dayofweek == dayofweek.wednesday
        ret := "We"
    if dayofweek == dayofweek.thursday
        ret := "Th"
    if dayofweek == dayofweek.friday
        ret := "Fr"
    if dayofweek == dayofweek.saturday
        ret := "Sa"
    ret

if enteringSession
    plotLo := na
    plotHi := na
    startBI := bar_index

float exitLow = na
float lastLow = 99999999999
float lastHigh = 0

if inSession
    // label.new(bar_index, high, tostring(currentHourGMT))
    lo := min(low,  nz(lo, 1.0e23))
    hi := max(high, nz(hi))

    lastLow := lo < lastLow ? lo : lastLow
    lastHigh := hi > lastHigh ? hi : lastHigh

    extBase := hi - lo
    ext1 := hi + (extBase * 1)
    ext2 := hi + (extBase * 2)
    ext3 := hi + (extBase * 3)

if exitingSession
    plotLo := lo
    plotHi := hi
    lo     := na
    hi     := na
    exitBI := bar_index

    if weekofyear(timenow) == weekofyear(time) or (weekofyear(timenow)-1 == weekofyear(time) and dayofweek(time) == dayofweek.friday)
        arSpread = lastHigh[1] - lastLow[1]
        pips = tostring(arSpread/syminfo.mintick/10)

        for i=1 to extCount
            labelText = getSValText(showExtDayofWeek, "", getHumanDate())

            if showUpper
                extHigh = lastHigh[1]+(arSpread*i)
                line.new(x1=startBI, y1=extHigh, x2=exitBI, y2=extHigh, extend=extend ? extend.right : extend.none, color=color.new(color.black, 75))

                if showExtLabels
                    upperLabelText = getValText(showExtPrices, labelText, extHigh)
                    
                    if showExtNumbers
                        upperLabelText := "+" + extTextPrefix + tostring(i) + upperLabelText

                    label.new(startBI, extHigh, upperLabelText, style=label.style_none)

            if showLower
                extLow = lastLow[1]-(arSpread*i)
                line.new(x1=startBI, y1=extLow, x2=exitBI, y2=extLow, extend=extend ? extend.right : extend.none, color=color.new(color.black, 75))

                if showExtLabels
                    lowerLabelText = getValText(showExtPrices, labelText, extLow)
                    
                    if showExtNumbers
                        lowerLabelText := "-" + extTextPrefix + tostring(i) + lowerLabelText

                    label.new(startBI, extLow, lowerLabelText, style=label.style_none)

Overview

TPCharts Asia Extensions projects session levels and extended target lines directly onto the main price chart along with customizable labels. Inputs allow users to adjust the session start and stop hours, toggle upper or lower extensions, control extension count, and customize labels to display prices, extension numbers, and days of the week.

Details

Published by

TPCharts on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Sessions & time, Support & resistance

Markets

Forex

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
Asia session start hour (GMT)int0hourSessionStart
Asia session end hour (GMT)int5hourSessionStop
Extend?boolfalseextend
How Many Extensions?int10extCount
Show Lower?boolfalseshowLower
Show Upper?booltrueshowUpper
Show Labels?booltrueshowExtLabels
Show Prices?booltrueshowExtPrices
Show Extension Numbers?booltrueshowExtNumbers
Show Extension Day of Week?booltrueshowExtDayofWeek
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

575 stars

This indicator builds Market Profile Time Price Opportunity (TPO) structures across defined session timeframes directly on the main price chart. It visualizes the Point of Control (POC) and Value Area boundaries using dynamic box drawings. An integrated multi-

Indicator v5 Support & resistanceScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of Market Profile with Screener
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

This indicator plots reference levels for previous daily high and low prices directly on the price chart. It requests daily timeframe data using the security function and plots the offset values as continuous lines, displaying resistance in red and support in

Indicator v4 Support & resistanceSessions & time
Updated 5 years ago · None stated GitHub repository of 昨日高低點標示

Golden Bullet Strategy

by TradersPost
218 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

Moon Dev GEX Arrows

by moondevonyt
92 stars

This overlay indicator plots option strike walls and an optional session VWAP on the price chart for SPY or ES. It spaces major strikes by the selected instrument, draws a set number of strikes on each side, and marks wall-trap and sweep events after a cooldow

Indicator v5 Support & resistanceSessions & time
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev GEX Arrows

Key Levels

by cryptorife
75 stars

This indicator plots reference levels and session markers directly on the price chart. It calculates and draws lines for the daily open, weekly open, monthly open, previous day OHLC, and previous week extremes, along with a selectable day-of-week range and ini

Indicator v4 Support & resistanceSessions & time Repaints
Updated 3 years ago · GPL-3.0 GitHub repository of Key Levels

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