Combineur de 2 sources (S1 op S2)Combineur de 2 sources (S1 op S2)
Permet de comparer 2 sources possibles de tous les indicateurs
Breadth Indicators
BTFD 5 Break-Out indyThe "BTFD 5 Break-Out indy" indicator uses background colors and buy/sell triangles to visually represent trading signals and position status based on its logic. Here's a brief explanation of the logic behind the green/red background and buy/sell triangles:
- **Green/Red Background**:
- **Green Background**: Displayed when the indicator is in a "long" position, meaning a buy signal has been triggered and the position is active. This indicates the market is in a favorable state for holding a long trade, based on conditions like an oversold breakout or strong momentum.
- **Red Background**: Shown when not in a long position, either before entering a trade or after exiting due to a sell signal (e.g., trend reversal, overbought conditions, or stop-loss hit). It signals a neutral or unfavorable state for buying.
- **Buy/Sell Triangles**:
- **Buy Triangles (Green, Below Bar)**: Plotted when a buy signal is triggered, indicating a high-probability entry point. This occurs when the market shows signs of recovery from an oversold state (e.g., a significant upward shift in the smoothed Z-score) or strong momentum (e.g., a rapid change in the rate-of-change metric). The triangle marks the exact bar where the long position is initiated.
- **Sell Triangles (Red, Above Bar)**: Plotted when an exit condition is met, signaling the close of a long position. Exits are triggered by a trend reversal (e.g., a trailing moving average turning bearish), a shift to overbought conditions, or a stop-loss breach. The triangle marks the bar where the position is closed.
In summary, the green background reflects an active long trade, while red indicates no position. Buy triangles signal entry points based on oversold breakouts or momentum, and sell triangles mark exits due to trend changes, reversals, or losses, aligning with institutional dip-buying strategies.
Whaley Thrust — ADT / UDT / SPT (2010) + EDT (EMA) + Info BoxDescription
Implements Wayne Whaley’s 2010 Dow Award breadth-thrust framework on daily data, with a practical extension:
• ADT (Advances Thrust) — 5-day ratio of advances to (adv+dec). Triggers: > 73.66% (thrust), < 19.05% (capitulation).
• UDT (Up-Volume Thrust) — 5-day ratio of up-volume to (up+down). Triggers: > 77.88%, < 16.41%. Defaults to USI:UVOL / USI:DVOL (edit if your feed differs).
• SPT (Price Thrust) — 5-day % change of a benchmark (default SPY, toggle to use chart symbol). Triggers: > +10.05%, < −13.85%.
• EDT (EMA extension) — Declines-share thrust derived from WBT logic (not in Whaley’s paper): EMA/SMA of Declines / (Adv+Decl). Triggers: > 0.8095 (declines thrust), < 0.2634 (declines abating).
• All-Clear — Prints when ADT+ and UDT+ occur within N days (default 10); marks the second event and shades brighter green.
Visuals & Controls
• Shape markers for each event; toggle text labels on/off.
• Optional background shading (green for thrusts, red for capitulations; brighter green for All-Clear).
• Compact info box showing live ADT / UDT / SPT (white by default; turns green/red at thresholds).
• Min-spacing filter to prevent duplicate prints.
Tips
• Use on Daily charts (paper uses 5 trading days). Weekly views can miss mid-week crosses.
• If UDT shows 100%, verify your Down Volume symbol; the script requires both UVOL and DVOL to be > 0.
• Best use: treat capitulations (−) as setup context; act on thrusts (+)—especially when ADT+ & UDT+ cluster (All-Clear).
Credit
Core method from Wayne Whaley (2010), Planes, Trains and Automobiles (Dow Award). EDT is an added, complementary interpretation using WBT-style smoothing.
ETH Perp-Spot PremiumETH Perp–Spot Premium (Composite)
Tracks the percentage premium or discount of ETH perpetual futures versus a composite spot basket across major exchanges (Binance, Bybit, OKX, Bitfinex, Bitstamp, Coinbase, Kraken).
The histogram plots the current premium %, with a Basis MA for trend reference. EMA crossovers are marked on-chart and can trigger alerts, helping to spot momentum shifts between contango and backwardation. A built-in table shows live composite perp and spot prices along with the current basis.
Use it to:
• Monitor changes in ETH perp–spot price relationship
• Identify shifts from discount to premium (and vice versa)
• Support directional or mean-reversion strategies
Educational purposes only.
Lux Algo Signals & Overlays [6.3]//@version=5
//text inputs
textVPosition = 'middle'
textHPosition = 'center'
symVPosition = 'top'
symHPosition = 'left'
width = 0
height = 0
c_title = #b2b5be80
s_title = 'large'
a_title = 'center'
c_subtitle = #b2b5be80
s_subtitle = 'normal'
a_subtitle = 'center'
c_bg = color.new(color.blue, 100)
indicator("Lux Algo Signals & Overlays ", "Lux Algo Signals & Overlays ", overlay = true, max_labels_count = 500)
//Import libraries
import ayvaliktrading/EyopsTelegram/1 as LAF
import ayvaliktrading/JoinUsEyopsTelegram/1 as kernels
// # ============================ ============================ #
groupBasic = "BASIC SETTINGS"
showSignals = input(true, "Show Signals", inline = "1", group = groupBasic, tooltip = "Enables or disables the signals")
signalPresets = input.string("None", "Presets / Filters", ["None", "Trend Trader ","Scalper ", "Swing Trader ", "Contrarian Trader ", "Smart Trail ", "Trend Tracer ", "Trend Strength ", "Trend Catcher ", "Neo Cloud "],tooltip = "Automatically sets settings or filters for a given category", group= groupBasic)
signalMode = input.string("Confirmation + Exits", "Signal Mode", ,tooltip = "Changes the Mode of the signals" ,group = groupBasic)
signalClassifier = input(true,"AI Signal Classifer",tooltip = "Shows signal quality from 1-4 on signals" ,group = groupBasic)
sensitivity = input.float(5, "Signal Sensitivity ", minval = 1, maxval = 26,step=0.1, tooltip = "Changes the sensetivity of the signals, the lower this setting the more short term signals you will get, while a higher number will result in longer term signals.",group = groupBasic)
atrLength = input.int(10, "Signal Tuner ", minval = 1, maxval = 25,step=1,tooltip = "Alows you to tune your signals, the higher the number the more refined but laggier the signal" ,group = groupBasic)
candleColorType = input.string("Confirmation Simple", "Candle Coloring", ,tooltip = "Changes the type of signal coloring", group = groupBasic)
// Indicator Overlay Settings
groupOverlay = "INDICATOR OVERLAY"
smartTrail = input(true, "Smart Trail", inline = "1", group = groupOverlay)
trendCatcher = input(false, "Trend Catcher", inline = "2", group = groupOverlay)
neoCloud = input(false, "Neo Cloud", inline = "3", group = groupOverlay)
reversalZone = input(true, "Reversal Zones", inline = "1", group = groupOverlay)
trendTracer = input(false, "Trend Tracer", inline = "2", group = groupOverlay)
showDashboard = input(true, "Dashboard", inline = "3", group = groupOverlay)
showTrailingStoploss = input(false, "Trailing Stoploss", inline = "4", group = groupOverlay)
showMovingAverage = input(false, "AI Moving Average", inline = "4", group = groupOverlay)
showSessions = input(false, "Sessions", inline = "5", group = groupOverlay)
// Advanced Settings
groupAdvanced = "ADVANCED SETTINGS"
takeProfitBoxes = input.string("Off", "TP/SL Points", options= , inline = "2", tooltip = "Shows Take Profit and Stop Loss areas",group = groupAdvanced)
takeProfitStopLossDistance = input.int(5,"", minval = 1, maxval = 10, inline = "2", group=groupAdvanced)
autopilotMode = input.string("Off", "Autopilot Sensivity", ,tooltip = "Sets automatic settings for signals and improves their quality" ,inline = "3", group = groupAdvanced)
dashboardLocation = input.string("Bottom Right","Dashboard Location", , inline = "4",tooltip = "Changes dashboard positions" ,group = groupAdvanced)
dashboardSize = input.string("Normal","Dashboard Size", , inline = "5",tooltip = "Changes the size of the dashboard" ,group = groupAdvanced)
if (signalPresets == "Trend Trader ")
smartTrail := true
trendCatcher := true
neoCloud := true
trendTracer := true
smartTrail := true
if (signalPresets == "Scalper ")
sensitivity := 4
smartTrail := true
trendTracer := true
candleColorType := "Confirmation Gradient"
if (signalPresets == "Swing Trader ")
sensitivity := 18
neoCloud := true
candleColorType := "Confirmation Simple"
if (signalPresets == "Contrarian Trader ")
reversalZone := true
smartTrail := true
candleColorType := "Contrarian Gradient"
n = bar_index
// # ============================ ============================ #
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
//-----------------------------------------------------------------------------}
// # ============================ ============================ #
show_sesa = true
sesa_txt = 'New York'
sesa_ses = '1300-2200'
sesa_css = #ff5d00
sesa_range = true
sesa_tl = false
sesa_avg = false
sesa_vwap = false
sesa_maxmin = false
//Session B
show_sesb = true
sesb_txt = 'London'
sesb_ses = '0700-1600'
sesb_css = #2157f3
sesb_range = true
sesb_tl = false
sesb_avg = false
sesb_vwap = false
sesb_maxmin = false
//Timezones
tz_incr = 0
use_exchange = false
//Ranges Options
bg_transp = 90
show_outline = true
show_txt = true
//Dashboard
show_ses_div = false
show_day_div = false
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
//Get session average
get_avg(session)=>
var len = 1
var float csma = na
var float sma = na
if session > session
len := 1
csma := close
if session and session == session and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
len += 1
csma += close
sma := csma / len
sma
//Get trendline coordinates
get_linreg(session)=>
var len = 1
var float cwma = na
var float csma = na
var float csma2 = na
var float y1 = na
var float y2 = na
var float stdev = na
var float r2 = na
if session > session
len := 1
cwma := close
csma := close
csma2 := close * close
if session and session == session and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
len += 1
csma += close
csma2 += close * close
cwma += close * len
sma = csma / len
wma = cwma / (len * (len + 1) / 2)
cov = (wma - sma) * (len+1)/2
stdev := math.sqrt(csma2 / len - sma * sma)
r2 := cov / (stdev * (math.sqrt(len*len - 1) / (2 * math.sqrt(3))))
y1 := 4 * sma - 3 * wma
y2 := 3 * wma - 2 * sma
//Session Vwap
get_vwap(session) =>
var float num = na
var float den = na
if session > session and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
num := close * volume
den := volume
else if session and session == session and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
num += close * volume
den += volume
else
num := na
//Set line
set_line(session, y1, y2, session_css)=>
var line tl = na
if session > session and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
tl := line.new(n, close, n, close, color = session_css)
if session and session == session and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
line.set_y1(tl, y1)
line.set_xy2(tl, n, y2)
//Set session range
get_range(session, session_name, session_css)=>
var t = 0
var max = high
var min = low
var box bx = na
var label lbl = na
if session > session and showSessions and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
t := time
max := high
min := low
bx := box.new(n, max, n, min
, bgcolor = color.new(session_css, bg_transp)
, border_color = show_outline ? session_css : na
, border_style = line.style_dotted)
if show_txt and showSessions and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
lbl := label.new(t, max, session_name
, xloc = xloc.bar_time
, textcolor = session_css
, style = label.style_label_down
, color = color.new(color.white, 100)
, size = size.tiny)
if session and session == session and showSessions and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
max := math.max(high, max)
min := math.min(low, min)
box.set_top(bx, max)
box.set_rightbottom(bx, n, min)
if show_txt
label.set_xy(lbl, int(math.avg(t, time)), max)
//-----------------------------------------------------------------------------}
//Sessions
//-----------------------------------------------------------------------------{
tf = timeframe.period
var tz = use_exchange ? syminfo.timezone :
str.format('UTC{0}{1}', tz_incr >= 0 ? '+' : '-', math.abs(tz_incr))
is_sesa = math.sign(nz(time(tf, sesa_ses, tz)))
is_sesb = math.sign(nz(time(tf, sesb_ses, tz)))
//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
var float max_sesa = na
var float min_sesa = na
var float max_sesb = na
var float min_sesb = na
var float max_sesc = na
var float min_sesc = na
var float max_sesd = na
var float min_sesd = na
//Ranges
if show_sesa and sesa_range and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
= get_range(is_sesa, sesa_txt, sesa_css)
max_sesa := max
min_sesa := min
if show_sesb and sesb_range and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
= get_range(is_sesb, sesb_txt, sesb_css)
max_sesb := max
min_sesb := min
//Trendlines
//Mean
if show_sesa and sesa_avg and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
avg = get_avg(is_sesa)
set_line(is_sesa, avg, avg, sesa_css)
if show_sesb and sesb_avg and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
avg = get_avg(is_sesb)
set_line(is_sesb, avg, avg, sesb_css)
//VWAP
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
//Plot max/min
plot(showSessions and sesa_maxmin and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ? max_sesa : na, 'Session A Maximum', sesa_css, 1, plot.style_linebr, editable = false)
plot(showSessions and sesa_maxmin and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ? min_sesa : na, 'Session A Minimum', sesa_css, 1, plot.style_linebr, editable = false)
plot(showSessions and sesb_maxmin and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ? max_sesb : na, 'Session B Maximum', sesb_css, 1, plot.style_linebr, editable = false)
plot(showSessions and sesb_maxmin and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ? min_sesb : na, 'Session B Minimum', sesb_css, 1, plot.style_linebr, editable = false)
//Plot Divider A
plotshape(is_sesa and show_ses_div and show_sesa and showSessions, "·"
, shape.square
, location.bottom
, na
, text = "."
, textcolor = sesa_css
, size = size.tiny
, display = display.all - display.status_line
, editable = false)
plotshape(is_sesa != is_sesa and show_ses_div and show_sesa and showSessions, "NYE"
, shape.labelup
, location.bottom
, na
, text = "❚"
, textcolor = sesa_css
, size = size.tiny
, display = display.all - display.status_line
, editable = false)
//Plot Divider B
plotshape(is_sesb and show_ses_div and show_sesb and showSessions, "·"
, shape.labelup
, location.bottom
, na
, text = "."
, textcolor = sesb_css
, size = size.tiny
, display = display.all - display.status_line
, editable = false)
plotshape(is_sesb != is_sesb and show_ses_div and show_sesb and showSessions, "LDN"
, shape.labelup
, location.bottom
, na
, text = "❚"
, textcolor = sesb_css
, size = size.tiny
, display = display.all - display.status_line
, editable = false)
// # ============================ ============================ #
type bar
float o = open
float h = high
float l = low
float c = close
float v = volume
int i = bar_index
bar b = bar.new()
nzV = nz(b.v)
f_calcV() =>
uV = 0.0
dV = 0.0
switch
(b.c - b.l) > (b.h - b.c) => uV := nzV
(b.c - b.l) < (b.h - b.c) => dV := -nzV
b.c > b.o => uV := nzV
b.c < b.o => dV := -nzV
b.c > nz(b.c ) => uV := nzV
b.c < nz(b.c ) => dV := -nzV
nz(uV ) > 0 => uV := uV + nzV
nz(dV ) < 0 => dV := dV - nzV
// # ============================ ============================ #
sma4 = ta.sma(close, 4)
sma5 = ta.sma(close, 5)
sma9 = ta.sma(close, 9)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
bullishSignalColor = #59e08a
bearishSignalColor = #ff5959
dashboardRedText = #ee787d
dashboardGreenText = #42bda8
dashboardGreenBackground = #284444
dashboardRedBackground = #49343e
// # ============================ ============================ #
macdFastLength = 12
macdSlowLength = 26
macdSignalLength = 9
if (candleColorType != 'Confirmation Simple')
macdFastLength := 10
macdSlowLength := 25
macdSignalLength:=8
= ta.macd(close, macdFastLength, macdSlowLength, macdSignalLength)
//candle color scheme
greenHigh = #4ce653
greenMidHigh =#4ce653
greenMidLow =#4ce653
greenLow = #56328f
// Yellow
yellowLow = #56328f
// 4 level of red
redHigh = #ff0000
redMidHigh = #ff0000
redMidLow = #ff0000
redLow = #56328f
if (candleColorType == 'Confirmation Gradient')
greenHigh := #01d70c
greenMidHigh := #269444
greenMidLow :=#4f966c
greenLow := #425970
// Yellow
yellowLow := #513a88
// 4 level of red
redHigh := #ff0000
redMidHigh := #c21637
redMidLow := #c33252
redLow := #8e215f
if (candleColorType == 'Contrarian Gradient')
redHigh := #01d70c
redMidHigh := #269444
redMidLow :=#4f966c
redLow := #425970
// Yellow
yellowLow := #513a88
// 4 level of red
greenHigh := #ff0000
greenMidHigh := #c21637
greenMidLow := #c33252
greenLow := #8e215f
// Default color
candleBody = yellowLow
if histX > 0
if histX > histX and histX > 0 and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
candleBody := greenLow
if histX < 0
if histX < histX and histX < 0 and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
candleBody := redLow
// Bullish trend
if MacdX > 0 and histX > 0
candleBody := greenMidLow
if histX > histX and MacdX > 0 and histX > 0 and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
candleBody := greenMidHigh
if histX > histX and MacdX > 0 and histX > 0 and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
candleBody := greenHigh
// Bearish trend
if MacdX < 0 and histX < 0
candleBody := redMidLow
if histX < histX and MacdX < 0 and histX < 0 and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
candleBody := redMidHigh
if histX < histX and MacdX < 0 and histX < 0 and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
candleBody := redHigh
barcolor(candleColorType == 'None' ? na : candleBody, editable = false)
// # ============================ ============================ #
= LAF.getSmartTrail(10, 4, 8)
smartTrail1 = plot(smartTrail and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ? smartTrailLine : na, "Smart Trail", style = plot.style_line, color = smartTrailDirection== 'long' ? color.new(#2157f9, 0) : smartTrailDirection == 'short' ? color.new(#ff1100, 0) : na, editable = false)
smartTrail2 = plot(smartTrail and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ? fillerLine : na, "Fib 2", style = plot.style_line, transp = 100, editable = false)
fill(smartTrail1, smartTrail2, color = smartTrailDirection == 'long' ? color.new(#2157f9, 80) : smartTrailDirection == 'short' ? color.new(#ff1100, 80) : na, editable = false)
// # ============================ ============================ #
= LAF.getTrendCatcher()
newTrendCatcherColor = trendCatcherColor == color.blue ? #02ff65 : #ff1100
plot(trendCatcher and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ? trendCatcherLine : na, title='Trend Catcher', linewidth=2, color=newTrendCatcherColor, editable = false)
// # ============================ ============================ #
// # ============================ ============================ #
// # ============================ ============================ #
= LAF.getTrendTracer()
plot(trendTracer and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ? trendTracerLine : na, title='Trend Tracer', linewidth=2, style=plot.style_cross, color = trendTracerDirection, editable = false)
// # ============================ ============================ #
trendStrengthMetric = math.abs(LAF.getTrendStrengthMetric(14, 'RMA', 21, 'EMA'))
trendStrengthMetric := trendStrengthMetric*2.5
trendIndication = trendStrengthMetric > 30 and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ? "🔥" : "❄️"
trendStrengthCellColor = newTrendCatcherColor == #02ff65 ? dashboardGreenBackground : dashboardRedBackground
trendStrengthTextColor = trendStrengthCellColor == dashboardGreenBackground ? dashboardGreenText : dashboardRedText
volatilityMetric = LAF.getVolatilityMetric()
volatilityMetric2 = ta.sma(LAF.getVolatilityMetric(), 8)
volatilityText = volatilityMetric < 30 ? 'Stable' : volatilityMetric < 80 ? 'Moderate' : 'Volatile'
volatilityEmoji = volatilityMetric2 > volatilityMetric ? '📉' : '📈'
volatilityCellColor = newTrendCatcherColor == #02ff65 ? dashboardGreenBackground : dashboardRedBackground
VolatilityTextColor = trendStrengthCellColor == dashboardGreenBackground ? dashboardGreenText : dashboardRedText
squeezeMetric = LAF.getSqueezeMetric(45, 20)
squeezeIsHigh = squeezeMetric >= 80 ? true : false
squeezeCellColor = trendTracerDirection == #02ff65 ? #1a3a3e : #482632
squeezeTextColor = trendTracerDirection != #02ff65 ? #ed3544 : #0a907a
// and textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
//
= f_calcV()
totalVolume = uV + math.abs(dV)
//volumecolor = totalVolume >= 50 ? bullish : bearish
volumeCellColor = dashboardRedBackground
volumeTextColor = totalVolume >= 50 ? dashboardGreenText : dashboardRedText
if (totalVolume >= 50)
totalVolume := totalVolume*2
volumeCellColor := dashboardGreenBackground
else
totalVolume := totalVolume*-2
volumeSentiment = totalVolume
table_position = dashboardLocation == 'Bottom Left' ? position.bottom_left
: dashboardLocation == 'Top Right' ? position.top_right
: position.bottom_right
table_size = dashboardSize == 'Tiny' ? size.tiny
: dashboardSize == 'Small' ? size.small
: size.normal
tb = table.new(table_position, 7, 7
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if showDashboard
if barstate.islast
tb.cell(0, 2, autopilotMode == 'Off' ? "🔎 Optimal Sensivity" : "✈️ Autopilot Enabled", text_color = color.white, text_size = table_size, text_halign = text.align_left)
tb.cell(0, 3, str.tostring(trendIndication) + "Trend Strength", text_color = color.white, text_size = table_size, text_halign = text.align_left)
tb.cell(0, 4, volatilityEmoji+ " Lux Volatility", text_color = color.white, text_size = table_size, text_halign = text.align_left)
tb.cell(0, 5, "🔃 Squeeze", text_color = color.white, text_size = table_size, text_halign = text.align_left)
tb.cell(0, 6, "💧 Volume Sentiment", text_color = color.white, text_size = table_size, text_halign = text.align_left)
tb.cell(1, 2, autopilotMode, text_color = color.white, text_size = table_size)
tb.cell(1, 3, str.tostring(trendStrengthMetric, format.percent), text_color=trendStrengthTextColor, text_size=table_size, bgcolor = trendStrengthCellColor)
tb.cell(1, 4, volatilityText, text_color = VolatilityTextColor, text_size = table_size, bgcolor = volatilityCellColor)
tb.cell(1, 5, str.tostring(squeezeMetric, format.percent), text_color= squeezeTextColor, text_size=table_size, bgcolor = squeezeCellColor)
tb.cell(1, 6, str.tostring(math.min(volumeSentiment, 100.), format.percent), text_color = volumeTextColor, text_size = table_size, bgcolor = volumeCellColor)
//************************************************************************************************************
// REV ZONES
//************************************************************************************************************
indiSet = false
source = hlc3
type = 'SuperSmoother'
length = 100
innermult = 1.0
outermult = 2.415
ChartSet = false
drawchannel = true
displayzone = true
zonetransp = 60
displayline = true
MTFSet = false
enable_mtf = true
mtf_disp_typ = 'On Hover'
mtf_typ = 'Auto'
mtf_lvl1 = 'D'
mtf_lvl2 = 'W'
//************************************************************************************************************
// Functions Start {
//************************************************************************************************************
var pi = 2 * math.asin(1)
var mult = pi * innermult
var mult2 = pi * outermult
var gradsize = 0.5
var gradtransp = zonetransp
//-----------------------
// Ehler SwissArmyKnife Function
//-----------------------
SAK_smoothing(_type, _src, _length) =>
c0 = 1.0
c1 = 0.0
b0 = 1.0
b1 = 0.0
b2 = 0.0
a1 = 0.0
a2 = 0.0
alpha = 0.0
beta = 0.0
gamma = 0.0
cycle = 2 * pi / _length
if _type == 'Ehlers EMA'
alpha := (math.cos(cycle) + math.sin(cycle) - 1) / math.cos(cycle)
b0 := alpha
a1 := 1 - alpha
a1
if _type == 'Gaussian'
beta := 2.415 * (1 - math.cos(cycle))
alpha := -beta + math.sqrt(beta * beta + 2 * beta)
c0 := alpha * alpha
a1 := 2 * (1 - alpha)
a2 := -(1 - alpha) * (1 - alpha)
a2
if _type == 'Butterworth'
beta := 2.415 * (1 - math.cos(cycle))
alpha := -beta + math.sqrt(beta * beta + 2 * beta)
c0 := alpha * alpha / 4
b1 := 2
b2 := 1
a1 := 2 * (1 - alpha)
a2 := -(1 - alpha) * (1 - alpha)
a2
if _type == 'BandStop'
beta := math.cos(cycle)
gamma := 1 / math.cos(cycle * 2 * 0.1) // delta default to 0.1. Acceptable delta -- 0.05
s_a1 = math.exp(-math.sqrt(2) * pi / _length)
s_b1 = 2 * s_a1 * math.cos(math.sqrt(2) * pi / _length)
s_c3 = -math.pow(s_a1, 2)
s_c2 = s_b1
s_c1 = 1 - s_c2 - s_c3
ss = 0.0
ss := s_c1 * _src + s_c2 * nz(ss , _src ) + s_c3 * nz(ss , _src )
ss
//-----------------------
// Auto TimeFrame Function
//-----------------------
// ————— Converts current chart resolution into a float minutes value.
f_resInMinutes() =>
_resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
_resInMinutes
get_tf(_lvl) =>
y = f_resInMinutes()
z = timeframe.period
if mtf_typ == 'Auto'
if y < 1
z := _lvl == 1 ? '1' : _lvl == 2 ? '5' : z
z
else if y <= 3
z := _lvl == 1 ? '5' : _lvl == 2 ? '15' : z
z
else if y <= 10
z := _lvl == 1 ? '15' : _lvl == 2 ? '60' : z
z
else if y <= 30
z := _lvl == 1 ? '60' : _lvl == 2 ? '240' : z
z
else if y <= 120
z := _lvl == 1 ? '240' : _lvl == 2 ? 'D' : z
z
else if y <= 240
z := _lvl == 1 ? 'D' : _lvl == 2 ? 'W' : z
z
else if y <= 1440
z := _lvl == 1 ? 'W' : _lvl == 2 ? 'M' : z
z
else if y <= 10080
z := _lvl == 1 ? 'M' : z
z
else
z := z
z
else
z := _lvl == 1 ? mtf_lvl1 : _lvl == 2 ? mtf_lvl2 : z
z
z
//-----------------------
// Mean Reversion Channel Function
//-----------------------
get_mrc() =>
v_condition = 0
v_meanline = source
v_meanrange = supersmoother(ta.tr, length)
//-- Get Line value
if type == 'SuperSmoother'
v_meanline := supersmoother(source, length)
v_meanline
if type != 'SuperSmoother'
v_meanline := SAK_smoothing(type, source, length)
v_meanline
v_upband1 = v_meanline + v_meanrange * mult
v_loband1 = v_meanline - v_meanrange * mult
v_upband2 = v_meanline + v_meanrange * mult2
v_loband2 = v_meanline - v_meanrange * mult2
//-- Check Condition
if close > v_meanline
v_upband2_1 = v_upband2 + v_meanrange * gradsize * 4
v_upband2_9 = v_upband2 + v_meanrange * gradsize * -4
if high >= v_upband2_9 and high < v_upband2
v_condition := 1
v_condition
else if high >= v_upband2 and high < v_upband2_1
v_condition := 2
v_condition
else if high >= v_upband2_1
v_condition := 3
v_condition
else if close <= v_meanline + v_meanrange
v_condition := 4
v_condition
else
v_condition := 5
v_condition
if close < v_meanline
v_loband2_1 = v_loband2 - v_meanrange * gradsize * 4
v_loband2_9 = v_loband2 - v_meanrange * gradsize * -4
if low <= v_loband2_9 and low > v_loband2
v_condition := -1
v_condition
else if low <= v_loband2 and low > v_loband2_1
v_condition := -2
v_condition
else if low <= v_loband2_1
v_condition := -3
v_condition
else if close >= v_meanline + v_meanrange
v_condition := -4
v_condition
else
v_condition := -5
v_condition
//-----------------------
// MTF Analysis
//-----------------------
get_stat(_cond) =>
ret = 'Price at Mean Line '
if _cond == 1
ret := 'Overbought (Weak) '
ret
else if _cond == 2
ret := 'Overbought '
ret
else if _cond == 3
ret := 'Overbought (Strong) '
ret
else if _cond == 4
ret := 'Price Near Mean '
ret
else if _cond == 5
ret := 'Price Above Mean '
ret
else if _cond == -1
ret := 'Oversold (Weak) '
ret
else if _cond == -2
ret := 'Oversold '
ret
else if _cond == -3
ret := 'Oversold (Strong) '
ret
else if _cond == -4
ret := 'Price Near Mean '
ret
else if _cond == -5
ret := 'Price Below Mean '
ret
ret
//-----------------------
// Chart Drawing Function
//-----------------------
format_price(x) =>
y = str.tostring(x, '0.00000')
if x > 10
y := str.tostring(x, '0.000')
y
if x > 1000
y := str.tostring(x, '0.00')
y
y
f_PriceLine(_ref, linecol) =>
line.new(x1=bar_index, x2=bar_index - 1, y1=_ref, y2=_ref, extend=extend.left, color=linecol)
f_MTFLabel(_txt, _yloc) =>
label.new(x=time + math.round(ta.change(time) * 20), y=_yloc, xloc=xloc.bar_time, text=mtf_disp_typ == 'Always Display' ? _txt : 'Check MTF', tooltip=mtf_disp_typ == 'Always Display' ? '' : _txt, color=color.black, textcolor=color.white, size=size.normal, style=mtf_disp_typ == 'On Hover' and displayline ? label.style_label_lower_left : label.style_label_left, textalign=text.align_left)
//} Function End
//************************************************************************************************************
// Calculate Channel
//************************************************************************************************************
var tf_0 = timeframe.period
var tf_1 = get_tf(1)
var tf_2 = get_tf(2)
textstylist = table.new(textVPosition + '_' + textHPosition, 1, 3)
= get_mrc()
= request.security(syminfo.tickerid, tf_1, get_mrc())
= request.security(syminfo.tickerid, tf_2, get_mrc())
//************************************************************************************************************
// Drawing Start {
//************************************************************************************************************
float p_meanline = drawchannel ? meanline : na
float p_upband1 = drawchannel ? upband1 : na
float p_loband1 = drawchannel ? loband1 : na
float p_upband2 = drawchannel ? upband2 : na
float p_loband2 = drawchannel ? loband2 : na
//z = plot(p_meanline, color=color.new(#FFCD00, 0), style=plot.style_line, title=' Mean', linewidth=2)
//x1 = plot(p_upband1, color=color.new(color.green, 50), style=plot.style_circles, title=' R1', linewidth=1)
//x2 = plot(p_loband1, color=color.new(color.green, 50), style=plot.style_circles, title=' S1', linewidth=1)
//y1 = plot(p_upband2, color=color.new(color.red, 50), style=plot.style_line, title=' R2', linewidth=1)
//y2 = plot(p_loband2, color=color.new(color.red, 50), style=plot.style_line, title=' S2', linewidth=1)
//-----------------------
// Draw zone
//-----------------------
//---
var color1 = #FF0000
var color2 = #FF4200
var color3 = #FF5D00
var color4 = #FF7400
var color5 = #FF9700
var color6 = #FFAE00
var color7 = #FFC500
var color8 = #FFCD00
//---
float upband2_1 = drawchannel and displayzone ? upband2 + meanrange * gradsize * 4 : na
float loband2_1 = drawchannel and displayzone ? loband2 - meanrange * gradsize * 4 : na
float upband2_2 = drawchannel and displayzone ? upband2 + meanrange * gradsize * 3 : na
float loband2_2 = drawchannel and displayzone ? loband2 - meanrange * gradsize * 3 : na
float upband2_3 = drawchannel and displayzone ? upband2 + meanrange * gradsize * 2 : na
float loband2_3 = drawchannel and displayzone ? loband2 - meanrange * gradsize * 2 : na
float upband2_4 = drawchannel and displayzone ? upband2 + meanrange * gradsize * 1 : na
float loband2_4 = drawchannel and displayzone ? loband2 - meanrange * gradsize * 1 : na
float upband2_5 = drawchannel and displayzone ? upband2 + meanrange * gradsize * 0 : na
float loband2_5 = drawchannel and displayzone ? loband2 - meanrange * gradsize * 0 : na
float upband2_6 = drawchannel and displayzone ? upband2 + meanrange * gradsize * -1 : na
float loband2_6 = drawchannel and displayzone ? loband2 - meanrange * gradsize * -1 : na
float upband2_7 = drawchannel and displayzone ? upband2 + meanrange * gradsize * -2 : na
float loband2_7 = drawchannel and displayzone ? loband2 - meanrange * gradsize * -2 : na
float upband2_8 = drawchannel and displayzone ? upband2 + meanrange * gradsize * -3 : na
float loband2_8 = drawchannel and displayzone ? loband2 - meanrange * gradsize * -3 : na
float upband2_9 = drawchannel and displayzone ? upband2 + meanrange * gradsize * -4 : na
float loband2_9 = drawchannel and displayzone ? loband2 - meanrange * gradsize * -4 : na
up1 = plot(reversalZone ? upband2_1 : na, color = color.black, transp = 100, editable = false)
up2 = plot(reversalZone ?upband2_5:na, color = color.black, transp = 100, editable = false)
up3 = plot(reversalZone ?upband2_9:na, color = color.black, transp = 100, editable = false)
dp1 = plot(reversalZone ?loband2_1:na, color = color.black, transp = 100, editable = false)
dp2 = plot(reversalZone ?loband2_5:na, color = color.black, transp = 100, editable = false)
dp3 = plot(reversalZone ?loband2_9:na, color = color.black, transp = 100, editable = false)
fill(up1, up2, color = #56202d, transp = 20, editable = false)
fill(up2, up3, color = #3f1d29, transp = 60, editable = false)
fill(dp1, dp2, color = #0f3e3f, transp = 20, editable = false)
fill(dp2, dp3, color = #113135, transp = 60, editable = false)
//
tenkan_len = 365
tenkan_mult = 3
kijun_len = 365
kijun_mult = 7
spanB_len = 365
spanB_mult = 15
offset = 2
//------------------------------------------------------------------------------
avg(src,length,mult)=>
atr = ta.atr(length)*mult
up = hl2 + atr
dn = hl2 - atr
upper = 0.,lower = 0.
upper := src < upper ? math.min(up,upper ) : up
lower := src > lower ? math.max(dn,lower ) : dn
os = 0,max = 0.,min = 0.
os := src > upper ? 1 : src < lower ? 0 : os
spt = os == 1 ? lower : upper
max := ta.cross(src,spt) ? math.max(src,max ) : os == 1 ? math.max(src,max ) : spt
min := ta.cross(src,spt) ? math.min(src,min ) : os == 0 ? math.min(src,min ) : spt
math.avg(max,min)
//------------------------------------------------------------------------------
tenkan = avg(close,tenkan_len,tenkan_mult)
kijun = avg(close,kijun_len,kijun_mult)
senkouA = math.avg(kijun,tenkan)
senkouB = avg(close,spanB_len,spanB_mult)
//------------------------------------------------------------------------------
tenkan_css = #2156f300
kijun_css = #ff5e0000
cloud_a = color.new(#006989, 47)
cloud_b = color.new(#ff5252, 66)
chikou_css = #7b1fa2
plot(neoCloud ? tenkan : na,'Tenkan-Sen',tenkan_css, editable = false)
plot(neoCloud ? kijun : na,'Kijun-Sen',kijun_css, editable = false)
plot(neoCloud and ta.crossover(tenkan,kijun) ? kijun : na,'Crossover',#2156f300,3,plot.style_circles, editable = false)
plot(neoCloud and ta.crossunder(tenkan,kijun) ? kijun : na,'Crossunder',#ff5e0000,3,plot.style_circles, editable = false)
A = plot(neoCloud ? senkouA: na,'Senkou Span A',na,offset=offset-1, editable = false)
B = plot(neoCloud ? senkouB : na,'Senkou Span B',na,offset=offset-1, editable = false)
fill(A,B,senkouA > senkouB ? cloud_a : cloud_b)
lastNeo = int(senkouA + senkouB)
last5Neo = ta.sma(lastNeo, 2)
plot(close,'Chikou',chikou_css,offset=-offset+1,display=display.none, editable = false)
// Wylicz pozycję kwadratu
ltp1 = bar_index
rtp1 = bar_index + 40
= LAF.getTPSLBoxes(6.0)
// Stwórz rzeczywisty kwadrat
//tp1box = box.new(left=ltp1, top=ttp1, right=rtp1, bottom=btp1, border_color=#3666f5, border_width=2, border_style=line.style_solid, bgcolor=color.new(#3666f5, 53), text="TP1 : " + str.tostring(close), text_size=size.large, text_color=color.new(#3666f5, 0), text_wrap=text.wrap_auto)
//var boxes = array.new()
//boxes.push(box.new(left = ltp1, top = close+highBound, right = rtp1, bottom = close + midBound, border_color=#3666f5, border_width=2, border_style=line.style_solid, bgcolor=color.new(#3666f5, 70), text="TP/SL 2 : " + str.tostring(close), text_size=size.large, text_color=color.new(#3666f5, 0), text_wrap=text.wrap_auto))
//boxes.push(box.new(left = ltp1, top = close+midBound, right = rtp1, bottom = close + lowBound, border_color=#3666f5, border_width=2, border_style=line.style_solid, bgcolor=color.new(#3666f5, 40), text="TP/SL 1 : " + str.tostring(close), text_size=size.large, text_color=color.new(#3666f5, 0), text_wrap=text.wrap_auto))
//SL1 = box.new(left = ltp1, top = close-highBound, right = rtp1, bottom = close - midBound, border_color=#3666f5, border_width=2, border_style=line.style_solid, bgcolor=color.new(#3666f5, 70), text="TP/SL 2 : " + str.tostring(close), text_size=size.large, text_color=color.new(#3666f5, 0), text_wrap=text.wrap_auto)
//SL2 = box.new(left = ltp1, top = close-midBound, right = rtp1, bottom = close - lowBound, border_color=#3666f5, border_width=2, border_style=line.style_solid, bgcolor=color.new(#3666f5, 40), text="TP/SL 1 : " + str.tostring(close), text_size=size.large, text_color=color.new(#3666f5, 0), text_wrap=text.wrap_auto)
// Usuń poprzednie ramki
//box.delete(boxes.shift())
//box.delete(SL1 )
//box.delete(SL2 )
//box.delete(boxes.shift())
// ==== Overview ====
// ==================
// WaveTrend 3D (WT3D) is a novel implementation of the famous WaveTrend (WT) indicator and has been completely redesigned from the ground up to address some
// of the inherent shortcomings associated with the traditional WT algorithm, including:
// (1) unbounded extremes
// (2) susceptibility to whipsaw
// (3) lack of insight into other timeframes
// Furthermore, WT3D expands upon the original functionality of WT by providing:
// (1) first-class support for multi-timeframe (MTF) analysis
// (2) kernel-based regression for trend reversal confirmation
// (3) various options for signal smoothing and transformation
// (4) a unique mode for visualizing an input series as a symmetrical, three-dimensional waveform useful for pattern identification and cycle-related analysis
// Fundamental Assumptions:
// (1) There exists a probability density function that describes the relative likelihood for a price to visit a given value.
// (2) The probability density function for price is a function of time.
// (3) The probability density function can approximate a Gaussian distribution (shown below).
// ___
// .::~!:.. |
// :ΞΞΞΞ~!ΞΞΞ!. |
// .ΞJΞΞΞΞ~!ΞΞΞ?J^ |
// :J?ΞΞΞΞΞ~!ΞΞΞΞΞJ^ |
// :J?ΞΞΞΞΞΞ~!ΞΞΞΞΞΞ??. |
// :JΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞ?J^ |
// :JΞΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞΞ?J^
// .:~ΞΞΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞΞΞ!!~ |
// :?~^ΞΞΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞΞΞ!^Ξ! |
// ~:^^^ΞΞΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞΞΞ!^^!Ξ. |
// .Ξ!^^^^ΞΞΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞΞΞ!^^^~Ξ~ |
// .~Ξ~^^^^^ΞΞΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞΞΞ!^^^^^!Ξ: |
// .~Ξ~^^^^^^^ΞΞΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞΞΞ!^^^^^^~!!^. |
// ....::^^!~~^^^^^^^^^ΞΞΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞΞΞ!^^^^^^^^^~!^^::...... |
// ..:::^^^^^^^::::::::::::::ΞΞΞΞΞΞΞΞΞΞ~!ΞΞΞΞΞΞΞΞΞ!::::::::::::^^^^^^^^:::.. |
//
// -------------------------------- -------------------------------|
// How to use this indicator:
// - The basic usage of WT3D is similar to how one would use the traditional WT indicator.
// - Divergences can be spotted by finding "trigger waves", which are small waves that immediately follow a larger wave. These can also be thought of as Lower-Highs and Higher-Lows in the oscillator.
// - Instead of the SMA-cross in the original WT, the primary mechanism for identifying potential pivots are the crossovers of the fast/normal speed oscillators, denoted by the small red/green circles.
// - The larger red/green circles represent points where there could be a potential trigger wave for a Divergence. Settings related to Divergence detection can be configured in the "Divergence" section.
// - For overbought/oversold conditions, the 0.5 and -0.5 levels are convenient since the normal-speed oscillator will only exceed this level ~25% of the time.
// - For less experienced users, focusing on the three oscillators is recommended since they give critical information from multiple timeframes that can help to identify trends and spot potential divergences.
// - For more experienced users, this indicator also has many other valuable features, such as Center of Gravity (CoG) smoothing, Kernel Estimate Crossovers, a mirrored mode for cycle analysis, and more.
// - Note: Additional resources for learning/using the more advanced features of this indicator are a work in progress, but in the meantime, I am happy to answer any questions.
// ================
// ==== Inputs ====
// ================
// Signal Settings
src = close
useMirror = false
useEma = false
emaLength = 3
useCog = false
cogLength = 6
oscillatorLookback =20
quadraticMeanLength = 50
src := useEma ? ta.ema(src, emaLength) : src
src := useCog ? ta.cog(src, cogLength) : src
speedToEmphasize = 'Normal'
emphasisWidth = 2
useKernelMA = false
useKernelEmphasis = false
// Oscillator Settings
offset := 0
showOsc = true
showOsc := showOsc
float f_length = 0.75
float f_smoothing = 0.45
float n_length = 1.0
float n_smoothing = 1.0
float s_length = 1.75
float s_smoothing = 2.5
// Divergence Detection
divThreshold = 30
sizePercent = 40
// Overbought/Oversold Zones (Reversal Zones)
showObOs = false
invertObOsColors = false
// Transparencies and Gradients
areaBackgroundTrans = 128.
areaForegroundTrans = 64.
lineBackgroundTrans = 2.6
lineForegroundTrans = 2.
customTransparency = 30
maxStepsForGradient = 8
// The defaults are colors that Google uses for its Data Science libraries (e.g. TensorFlow). They are considered to be colorblind-safe.
var color fastBullishColor = color.black
var color normalBullishColor = color.black
var color slowBullishColor = color.black
var color fastBearishColor = color.black
var color normalBearishColor = color.black
var color slowBearishColor =color.black
var color c_bullish = color.black
var color c_bearish = color.black
lineBackgroundTrans := lineBackgroundTrans * customTransparency
areaBackgroundTrans := areaBackgroundTrans * customTransparency
lineForegroundTrans := lineForegroundTrans * customTransparency
areaForegroundTrans := areaForegroundTrans * customTransparency
areaFastTrans = areaBackgroundTrans
lineFastTrans = lineBackgroundTrans
areaNormalTrans = areaBackgroundTrans
lineNormalTrans = lineBackgroundTrans
areaSlowTrans = areaForegroundTrans
lineSlowTrans = lineForegroundTrans
switch speedToEmphasize
"Slow" =>
areaFastTrans := areaBackgroundTrans
lineFastTrans := lineBackgroundTrans
areaNormalTrans := areaBackgroundTrans
lineNormalTrans := lineBackgroundTrans
areaSlowTrans := areaForegroundTrans
lineSlowTrans := lineForegroundTrans
"Normal" =>
areaFastTrans := areaBackgroundTrans
lineFastTrans := lineBackgroundTrans
areaNormalTrans := areaForegroundTrans
lineNormalTrans := lineForegroundTrans
areaSlowTrans := areaBackgroundTrans
lineSlowTrans := lineBackgroundTrans
"Fast" =>
areaFastTrans := areaForegroundTrans
lineFastTrans := lineForegroundTrans
areaNormalTrans := areaBackgroundTrans
lineNormalTrans := lineBackgroundTrans
areaSlowTrans := areaBackgroundTrans
lineSlowTrans := lineBackgroundTrans
"None" =>
areaFastTrans := areaBackgroundTrans
lineFastTrans := lineBackgroundTrans
areaNormalTrans := areaBackgroundTrans
lineNormalTrans := lineBackgroundTrans
areaSlowTrans := areaBackgroundTrans
lineSlowTrans := lineBackgroundTrans
// =================================
// ==== Color Helper Functions =====
// =================================
getPlotColor(signal, bullColor, bearColor) =>
signal >= 0.0 ? bullColor : bearColor
getAreaColor(signal, useMomentum, bullColor, bearColor) =>
if useMomentum
ta.rising(signal, 1) ? bullColor : bearColor
else
signal >= 0.0 ? bullColor : bearColor
getColorGradientFromSteps(_source, _center, _steps, weakColor, strongColor) =>
var float _qtyAdvDec = 0.
var float _maxSteps = math.max(1, _steps)
bool _xUp = ta.crossover(_source, _center)
bool _xDn = ta.crossunder(_source, _center)
float _chg = ta.change(_source)
bool _up = _chg > 0
bool _dn = _chg < 0
bool _srcBull = _source > _center
bool _srcBear = _source < _center
_qtyAdvDec := _srcBull ? _xUp ? 1 : _up ? math.min(_maxSteps, _qtyAdvDec + 1) : _dn ? math.max(1, _qtyAdvDec - 1) : _qtyAdvDec : _srcBear ? _xDn ? 1 : _dn ? math.min(_maxSteps, _qtyAdvDec + 1) : _up ? math.max(1, _qtyAdvDec - 1) : _qtyAdvDec : _qtyAdvDec
color colorGradient = color.from_gradient(_qtyAdvDec, 1, _maxSteps, weakColor, strongColor)
colorGradient
getColorGradientFromSource(series, _min, _max, weakColor, strongColor) =>
var float baseLineSeries = _min + (_max - _min) / 2
color colorGradient = series >= baseLineSeries ? color.from_gradient(value=series, bottom_value=baseLineSeries, top_value=_max, bottom_color=weakColor, top_color=strongColor) : color.from_gradient(series, _min, baseLineSeries, strongColor, weakColor)
colorGradient
// ================================
// ==== Main Helper Functions =====
// ================================
normalizeDeriv(_src, _quadraticMeanLength) =>
float derivative = _src - _src
quadraticMean = math.sqrt(nz(math.sum(math.pow(derivative, 2), _quadraticMeanLength) / _quadraticMeanLength))
derivative/quadraticMean
tanh(series float _src) =>
-1 + 2/(1 + math.exp(-2*_src))
dualPoleFilter(float _src, float _lookback) =>
float _omega = -99 * math.pi / (70 * _lookback)
float _alpha = math.exp(_omega)
float _beta = -math.pow(_alpha, 2)
float _gamma = math.cos(_omega) * 2 * _alpha
float _delta = 1 - _gamma - _beta
float _slidingAvg = 0.5 * (_src + nz(_src , _src))
float _filter = na
_filter := (_delta*_slidingAvg) + _gamma*nz(_filter ) + _beta*nz(_filter )
_filter
getOscillator(float src, float smoothingFrequency, int quadraticMeanLength) =>
nDeriv = normalizeDeriv(src, quadraticMeanLength)
hyperbolicTangent = tanh(nDeriv)
result = dualPoleFilter(hyperbolicTangent, smoothingFrequency)
// =================================
// ==== Oscillator Calculations ====
// =================================
// Fast Oscillator + Mirror
offsetFast = offset
f_lookback = f_smoothing * oscillatorLookback
signalFast = getOscillator(src, f_lookback, quadraticMeanLength)
seriesFast = f_length*signalFast+offsetFast
seriesFastMirror = useMirror ? -seriesFast + 2*offsetFast : na
// Normal Oscillator + Mirror
offsetNormal = 0
n_lookback = n_smoothing * oscillatorLookback
signalNormal = getOscillator(src, n_lookback, quadraticMeanLength)
seriesNormal = n_length*signalNormal+offsetNormal
seriesNormalMirror = useMirror ? -seriesNormal + 2*offsetNormal : na
// Slow Oscillator + Mirror
offsetSlow = -offset
s_lookback = s_smoothing * oscillatorLookback
signalSlow = getOscillator(src, s_lookback, quadraticMeanLength)
seriesSlow = s_length*signalSlow+offsetSlow
seriesSlowMirror = useMirror ? -seriesSlow + 2*offsetSlow : na
// =====================================
// ==== Color Gradient Calculations ====
// =====================================
// Fast Color Gradients (Areas and Lines)
fastBaseColor = getPlotColor(signalFast, fastBullishColor, fastBearishColor)
fastBaseColorInverse = getPlotColor(signalFast, fastBearishColor, fastBullishColor)
fastAreaGradientFromSource = getColorGradientFromSource(seriesFast, -1.+offsetFast, 1+offsetFast, color.new(fastBaseColor, areaFastTrans), fastBaseColor)
fastAreaGradientFromSteps = getColorGradientFromSteps(seriesFast, offsetFast, maxStepsForGradient, color.new(fastBaseColor, areaFastTrans), fastBaseColor)
fastLineGradientFromSource = getColorGradientFromSource(seriesFast, -1+offsetFast, 1+offsetFast, color.new(fastBaseColor, lineFastTrans), fastBaseColor)
fastLineGradientFromSteps = getColorGradientFromSteps(seriesFast, offsetFast, maxStepsForGradient, color.new(fastBaseColor, lineFastTrans), fastBaseColor)
fastAreaGradientFromSourceInverse = getColorGradientFromSource(seriesFast, -1.+offsetFast, 1+offsetFast, color.new(fastBaseColorInverse, areaFastTrans), fastBaseColorInverse)
fastAreaGradientFromStepsInverse = getColorGradientFromSteps(seriesFast, offsetFast, maxStepsForGradient, color.new(fastBaseColorInverse, areaFastTrans), fastBaseColorInverse)
// Normal Color Gradients (Areas and Lines)
normalBaseColor = getPlotColor(signalNormal, normalBullishColor, normalBearishColor)
normalBaseColorInverse = getPlotColor(signalNormal, normalBearishColor, normalBullishColor)
normalAreaGradientFromSource = getColorGradientFromSource(seriesNormal, -1.+offsetNormal, 1.+offsetNormal, color.new(normalBaseColor, areaNormalTrans), normalBaseColor)
normalAreaGradientFromSteps = getColorGradientFromSteps(seriesNormal, offsetNormal, maxStepsForGradient, color.new(normalBaseColor, areaNormalTrans), normalBaseColor)
normalLineGradientFromSource = getColorGradientFromSource(seriesNormal, -1+offsetNormal, 1+offsetNormal, color.new(normalBaseColor, lineNormalTrans), normalBaseColor)
normalLineGradientFromSteps = getColorGradientFromSteps(seriesNormal, offsetNormal, maxStepsForGradient, color.new(normalBaseColor, lineNormalTrans), normalBaseColor)
normalAreaGradientFromSourceInverse = getColorGradientFromSource(seriesNormal, -1.+offsetNormal, 1.+offsetNormal, color.new(normalBaseColorInverse, areaNormalTrans), normalBaseColorInverse)
normalAreaGradientFromStepsInverse = getColorGradientFromSteps(seriesNormal, offsetNormal, maxStepsForGradient, color.new(normalBaseColorInverse, areaNormalTrans), normalBaseColorInverse)
// Slow Color Gradients (Areas and Lines)
slowBaseColor = getPlotColor(signalSlow, slowBullishColor, slowBearishColor)
slowBaseColorInverse = getPlotColor(signalSlow, slowBearishColor, slowBullishColor)
slowAreaGradientFromSource = getColorGradientFromSource(seriesSlow, -1.75+offsetSlow, 1.75+offsetSlow, color.new(slowBaseColor, areaSlowTrans), slowBaseColor)
slowAreaGradientFromSteps = getColorGradientFromSteps(seriesSlow, offsetSlow, maxStepsForGradient, color.new(slowBaseColor, areaSlowTrans), slowBaseColor)
slowLineGradientFromSource = getColorGradientFromSource(seriesSlow, -1.75+offsetSlow, 1.75+offsetSlow, color.new(slowBaseColor, lineSlowTrans), slowBaseColor)
slowLineGradientFromSteps = getColorGradientFromSteps(seriesSlow, offsetSlow, maxStepsForGradient, color.new(slowBaseColor, lineSlowTrans), slowBaseColor)
slowAreaGradientFromSourceInverse = getColorGradientFromSource(seriesSlow, -1.75+offsetSlow, 1.75+offsetSlow, color.new(slowBaseColorInverse, areaSlowTrans), slowBaseColorInverse)
slowAreaGradientFromStepsInverse = getColorGradientFromSteps(seriesSlow, offsetSlow, maxStepsForGradient, color.new(slowBaseColorInverse, areaSlowTrans), slowBaseColorInverse)
// =========================================
// ==== Plot Parameters and Logic Gates ====
// =========================================
// Speed Booleans
isSlow = speedToEmphasize == "Slow"
isNormal = speedToEmphasize == "Normal"
isFast = speedToEmphasize == "Fast"
// Series Colors
seriesSlowColor = showOsc or isSlow ? color.new(slowLineGradientFromSource, lineSlowTrans) : na
seriesNormalColor = showOsc or isNormal ? color.new(normalLineGradientFromSource, lineNormalTrans) : na
seriesFastColor = showOsc or isFast ? color.new(fastLineGradientFromSource, lineFastTrans) : na
seriesSlowMirrorColor = useMirror ? seriesSlowColor : na
seriesNormalMirrorColor = useMirror ? seriesNormalColor : na
seriesFastMirrorColor = useMirror ? seriesFastColor : na
// Series Line Widths
seriesSlowWidth = isSlow ? emphasisWidth : 1
seriesNormalWidth = isNormal ? emphasisWidth : 1
seriesFastWidth = isFast ? emphasisWidth : 1
seriesSlowMirrorWidth = useMirror ? seriesSlowWidth : na
seriesNormalMirrorWidth = useMirror ? seriesNormalWidth : na
seriesFastMirrorWidth = useMirror ? seriesFastWidth : na
// Speed Related Switches
seriesEmphasis = switch
isFast => seriesFast
isNormal => seriesNormal
isSlow => seriesSlow
=> na
//
colorLineEmphasis = switch
isFast => fastLineGradientFromSource
isNormal => normalLineGradientFromSource
isSlow => slowLineGradientFromSource
=> na
colorAreaEmphasis = switch
isFast => fastAreaGradientFromSource
isNormal => normalAreaGradientFromSource
isSlow => slowAreaGradientFromSource
=> na
// Crossover Signals
bearishCross = ta.crossunder(seriesFast, seriesNormal) and seriesNormal > 0
bullishCross = ta.crossover(seriesFast, seriesNormal) and seriesNormal < 0
slowBearishMedianCross = ta.crossunder(seriesSlow, 0)
slowBullishMedianCross = ta.crossover(seriesSlow, 0)
normalBearishMedianCross = ta.crossunder(seriesNormal, 0)
normalBullishMedianCross = ta.crossover(seriesNormal, 0)
fastBearishMedianCross = ta.crossunder(seriesFast, 0)
fastBullishMedianCross = ta.crossover(seriesFast, 0)
// Last Crossover Values
lastBearishCrossValue = ta.valuewhen(condition=bearishCross, source=seriesNormal, occurrence=1)
lastBullishCrossValue = ta.valuewhen(condition=bullishCross , source=seriesNormal, occurrence=1)
// Trigger Wave Size Comparison
triggerWaveFactor = sizePercent/100
isSmallerBearishCross = bearishCross and seriesNormal < lastBearishCrossValue * triggerWaveFactor
isSmallerBullishCross = bullishCross and seriesNormal > lastBullishCrossValue * triggerWaveFactor
// ===========================
// ==== Kernel Estimators ====
// ===========================
// The following kernel estimators are based on the Gaussian Kernel.
// They are used for:
// (1) Confirming directional changes in the slow oscillator (i.e. a type of trend filter)
// (2) Visualizing directional changes as a dynamic ribbon (i.e. an additional oscillator that can crossover with the user specified oscillator of interest)
// (3) Visualizing transient directional changes while in the midst of a larger uptrend or downtrend (i.e. via color changes on the ribbon)
// Gaussian Kernel with a lookback of 6 bars, starting on bar 6 of the chart (medium fit)
yhat0 = kernels.gaussian(seriesEmphasis, 6, 6)
// Gaussian Kernel with a lookback of 3 bars, starting on bar 2 of the chart (tight fit)
yhat1 = kernels.gaussian(seriesEmphasis, 3, 2)
// Trend Assessment based on the relative position of the medium fit kernel to the slow oscillator
isBearishKernelTrend = yhat0 < seriesSlow
isBullishKernelTrend = yhat0 > seriesSlow
// Divergence Signals
isBearishDivZone = ta.barssince(bearishCross ) < divThreshold
isBullishDivZone = ta.barssince(bullishCross ) < divThreshold
// Crossover Detection
isBearishTriggerWave = isSmallerBearishCross and isBearishDivZone and isBearishKernelTrend
isBullishTriggerWave = isSmallerBullishCross and isBullishDivZone and isBullishKernelTrend
// =======================
// ==== Plots & Fills ====
var position = 0
length := atrLength
minMult = math.max(sensitivity-4, 1)
maxMult = math.min(sensitivity, 26)
if (autopilotMode == "Short Term")
minMult:=1
maxMult := 4
if (autopilotMode == 'Mid Term')
minMult := 5
maxMult := 10
if (autopilotMode == 'Long-Term')
minMult :=8
maxMult :=13
float step = .5
//Trigger error
if minMult > maxMult
runtime.error('Minimum factor is greater than maximum factor in the range')
float perfAlpha = 10
fromCluster = 'Best'
//Optimization
maxIter = 250
maxData = 2500
//Style
bearCss = color.red
bullCss = color.teal
amaBearCss = color.new(color.red, 50)
amaBullCss = color.new(color.teal, 50)
showGradient = true
//Dashboard
showDash = true
//dashboardLocation = input.string('Top Right', 'Location', options = , group = 'Dashboard')
textSize = 'Small'
//-----------------------------------------------------------------------------}
//UDT's
//-----------------------------------------------------------------------------{
type supertrend
float upper = hl2
float lower = hl2
float output
float perf = 0
float factor
int trend = 0
type vector
array out
//-----------------------------------------------------------------------------}
//Supertrend
//-----------------------------------------------------------------------------{
var holder = array.new(0)
var factors = array.new(0)
//Populate supertrend type array
if barstate.isfirst
for i = 0 to int((maxMult - minMult) / step)
factors.push(minMult + i * step)
holder.push(supertrend.new())
atr = ta.atr(length)
//Compute Supertrend for multiple factors
k = 0
for factor in factors
get_spt = holder.get(k)
up = hl2 + atr * factor
dn = hl2 - atr * factor
get_spt.trend := close > get_spt.upper ? 1 : close < get_spt.lower ? 0 : get_spt.trend
get_spt.upper := close < get_spt.upper ? math.min(up, get_spt.upper) : up
get_spt.lower := close > get_spt.lower ? math.max(dn, get_spt.lower) : dn
diff = nz(math.sign(close - get_spt.output))
get_spt.perf += 2/(perfAlpha+1) * (nz(close - close ) * diff - get_spt.perf)
get_spt.output := get_spt.trend == 1 ? get_spt.lower : get_spt.upper
get_spt.factor := factor
k += 1
//-----------------------------------------------------------------------------}
//K-means clustering
//-----------------------------------------------------------------------------{
factor_array = array.new(0)
data = array.new(0)
//Populate data arrays
if last_bar_index - bar_index <= maxData
for element in holder
data.push(element.perf)
factor_array.push(element.factor)
//Intitalize centroids using quartiles
centroids = array.new(0)
centroids.push(data.percentile_linear_interpolation(25))
centroids.push(data.percentile_linear_interpolation(50))
centroids.push(data.percentile_linear_interpolation(75))
//Intialize clusters
var array factors_clusters = na
var array perfclusters = na
if last_bar_index - bar_index <= maxData
for _ = 0 to maxIter
factors_clusters := array.from(vector.new(array.new(0)), vector.new(array.new(0)), vector.new(array.new(0)))
perfclusters := array.from(vector.new(array.new(0)), vector.new(array.new(0)), vector.new(array.new(0)))
//Assign value to cluster
i = 0
for value in data
dist = array.new(0)
for centroid in centroids
dist.push(math.abs(value - centroid))
idx = dist.indexof(dist.min())
perfclusters.get(idx).out.push(value)
factors_clusters.get(idx).out.push(factor_array.get(i))
i += 1
//Update centroids
new_centroids = array.new(0)
for cluster_ in perfclusters
new_centroids.push(cluster_.out.avg())
//Test if centroid changed
if new_centroids.get(0) == centroids.get(0) and new_centroids.get(1) == centroids.get(1) and new_centroids.get(2) == centroids.get(2)
break
centroids := new_centroids
//-----------------------------------------------------------------------------}
//Signals and trailing stop
//-----------------------------------------------------------------------------{
//Get associated supertrend
var float target_factor = na
var float perf_idx = na
var float perf_ama = na
var from = switch fromCluster
'Best' => 2
'Average' => 1
'Worst' => 0
//Performance index denominator
den = ta.ema(math.abs(close - close ), int(perfAlpha))
if not na(perfclusters)
//Get average factors within target cluster
target_factor := nz(factors_clusters.get(from).out.avg(), target_factor)
//Get performance index of target cluster
perf_idx := math.max(nz(perfclusters.get(from).out.avg()), 0) / den
//Get new supertrend
var upper = hl2
var lower = hl2
var os = 0
up = hl2 + atr * target_factor
dn = hl2 - atr * target_factor
upper := close < upper ? math.min(up, upper) : up
lower := close > lower ? math.max(dn, lower) : dn
os := close > upper ? 1 : close < lower ? 0 : os
ts = os ? lower : upper
//Get trailing stop adaptive MA
if na(ts ) and not na(ts)
perf_ama := ts
else
perf_ama += perf_idx * (ts - perf_ama)
//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
//-----------------------------------------------------------------------------{
css = os ? bullCss : bearCss
plot(showTrailingStoploss ? ts : na, 'Trailing Stop', os != os ? na : css, editable = false)
plot(showMovingAverage? perf_ama:na, 'Trailing Stop AMA',
ta.cross(close, perf_ama) ? na
: close > perf_ama ? amaBullCss : amaBearCss, editable = false)
//Candle coloring
//barcolor(showGradient ? color.from_gradient(perf_idx, 0, 1, color.new(css, 80), css) : na)
//Signals
if showSignals
if os > os and (signalPresets != "Smart Trail " or smartTrailDirection == 'long') and (signalPresets != "Trend Tracer " or trendTracerDirection==#02ff65) and (signalPresets != "Trend Strength " or trendStrengthMetric >= 25) and (signalPresets != "Trend Catcher " or newTrendCatcherColor == #02ff65) and (signalPresets != "Neo Cloud " or int(lastNeo) >= last5Neo)
int signalStrength = int(perf_idx*10) < 2 ? 1 : int(perf_idx*10) < 4 ? 2 : int(perf_idx*10) < 5 ? 3 : 4
label.new(n, low-ta.atr(30)/2, signalClassifier ? str.tostring(signalStrength) : ema50 > ema200 ? "▲+" : "▲"
, color = bullCss
, style = label.style_label_up
, textcolor = color.white
, yloc=yloc.belowbar
, size = size.small)
position := 1
if os < os and (signalPresets != "Smart Trail " or smartTrailDirection == 'short') and (signalPresets != "Trend Tracer " or trendTracerDirection!=#02ff65) and (signalPresets != "Trend Strength " or trendStrengthMetric >= 25)and (signalPresets != "Trend Catcher " or newTrendCatcherColor != #02ff65) and (signalPresets != "Neo Cloud " or int(lastNeo) <=last5Neo)
int signalStrength = int(perf_idx*10) < 2 ? 1 : int(perf_idx*10) < 4 ? 2 : int(perf_idx*10) < 5 ? 3 : 4
label.new(n, high+ta.atr(30)/2, signalClassifier ? str.tostring(signalStrength) : ema50 < ema200 ? "▼+" : "▼"
, color = bearCss
, style = label.style_label_down
, textcolor = color.white
, yloc=yloc.abovebar
, size = size.small)
position := -1
// =======================
// Signal Plots
//plot(position == 1 and bearishCross ? high+5 : na, title="Bearish Cross", style=plot.style_cross, linewidth=2, color=c_bearish, offset=-1)
//plot(position == -1 and bearishCross ? high+5 : na, title="Bearish Cross", style=plot.style_circles, linewidth=2, color=c_bearish, offset=-1)
//plot(position == 1 and isBearishTriggerWave ? high+5 : na, title="Bearish Trigger Cross", style=plot.style_cross, linewidth=3, color=c_bearish, offset=-1)
//plot(position == -1 and isBearishTriggerWave ? high+5 : na, title="Bearish Trigger Cross", style=plot.style_circles, linewidth=3, color=c_bearish, offset=-1)
//plotchar(bearishCross and position == 1, "Long", "✖", location.abovebar, color = #4774f5, size = size.tiny, editable = false)
//plotchar(bearishCross and position == -1, "Long", "▼", location.abovebar, color = c_bearish, size = size.tiny)
plotchar(isBearishTriggerWave and position == 1, "Long", "✖", location.abovebar, color=#4774f5, size = size.tiny, editable = false)
//plotchar(isBearishTriggerWave and position == -1, "Long", "▼", location.abovebar, color=c_bearish, size = size.small)
//plot(position == 1 and bullishCross ? low -5: na, title="Bullish Cross", style= plot.style_circles, linewidth=2, color=c_bullish, offset=-1)
//plot(position == -1 and bullishCross ? low -5: na, title="Bullish Cross", style= pl
Dynamic Trend Bands (DTB)Description:
Dynamic Trend Bands (DTB) is a volatility-based range filter combined with multiple trend confirmation tools to detect and visualize market direction and possible reversals.
Features:
Range Filter: Identifies potential highs/lows and filters out market noise.
Trend Strength: Integrated ADX to validate trend momentum.
VIDYA Bands + ATR: Detects breakout conditions using variable adaptive moving averages and volatility bands.
EMA 200 Filter: Determines long-term trend direction.
Auto Buy/Sell Labels: Generates clear entry and exit signals.
Alerts: Ready-to-use alert conditions for automated notifications.
Recommended Use:
Timeframe: 4H (works on other timeframes as well)
Markets: BTC, ETH, major altcoins, and traditional assets.
Advantages:
Combines short-term and long-term trend detection.
Filters out false signals in choppy markets.
Visual and alert-based trade setups for easier execution.
//@version=6
// ─────────────────────────────────────────────────────────────────────────────
// Title: Dynamic Trend Bands (DTB) + Auto Buy/Sell + EMA 200 + ADX + VIDYA
//
// Description:
// Dynamic Trend Bands (DTB) is a volatility-based range filter combined with
// multiple trend confirmation tools to detect and visualize market direction
// and possible reversals.
//
// Features:
// - Range Filter: Identifies potential highs/lows and filters out market noise.
// - Trend Strength: Integrated ADX to validate trend momentum.
// - VIDYA Bands + ATR: Detects breakout conditions using variable adaptive moving averages and volatility bands.
// - EMA 200 Filter: Determines long-term trend direction.
// - Auto Buy/Sell Labels: Generates clear entry and exit signals.
// - Alerts: Ready-to-use alert conditions for automated notifications.
//
// Recommended Use:
// - Timeframe: 4H (works on other timeframes as well)
// - Markets: BTC, ETH, major altcoins, and traditional assets.
//
// Advantages:
// - Combines short-term and long-term trend detection.
// - Filters out false signals in choppy markets.
// - Visual and alert-based trade setups for easier execution.
// ───────────────────────────────────────────
BTCUSDT Correlation TableThis indicator calculates and displays the correlation between the current chart’s asset and Bitcoin (BTCUSDT) over a selected period. The correlation is shown as a percentage in a compact table on the chart.
Key features:
Customizable BTC symbol – default is BINANCE:BTCUSDT.
Adjustable correlation period – set the number of bars used for correlation calculation.
Color-coded output:
Green for strong positive correlation (above +80%)
Red for strong negative correlation (below –80%)
Blue for neutral correlation
Use this tool to quickly assess whether your asset is moving in sync with Bitcoin, inversely, or independently.
Daily 16:00 Vertical Lines//@version=5
indicator("Daily 16:00 Vertical Lines", overlay=true, max_lines_count=500)
// Input for session time
hourMark = input.int(16, "Hour to Mark (24hr)", minval=0, maxval=23)
minuteMark = input.int(0, "Minute to Mark", minval=0, maxval=59)
// Check if the current bar is at the chosen time
isMarkTime = (hour == hourMark) and (minute == minuteMark)
// Draw the vertical line when condition matches
if (isMarkTime)
line.new(x1=bar_index, y1=low, x2=bar_index, y2=high,
color=color.red, style=line.style_dotted, width=1)
kale1668公用版a8verified_bearish_original = enable_oversold_overbought ? original and overbought_condition) : trendDown_ori
偏向线 → 偏向
RSI线 → RS
多头区域 → 多头
空头区域 → 空头
偏向填充 → 偏向
多头填充 → 多头
空头填充 → 空头
K线颜色 → K线
Fractal Suite: MTF Fractals + BOS/CHOCH + OB + FVG + Targets Kese Way
Fractals (Multi-Timeframe): Automatically detects both current-timeframe and higher-timeframe Bill Williams fractals, with customizable left/right bar settings.
Break of Structure (BOS) & CHoCH: Marks structural breaks and changes of character in real time.
Liquidity Sweeps: Identifies sweep patterns where price takes out a previous swing high/low but closes back within range.
Order Blocks (OB): Highlights the last opposite candle before a BOS, with customizable extension bars.
Fair Value Gaps (FVG): Finds 3-bar inefficiencies with a minimum size filter.
Confluence Zones: Optionally require OB–FVG overlap for high-probability setups.
Entry, Stop, and Targets: Automatically calculates entry price, stop loss, and up to three take-profit targets based on risk-reward ratios.
Visual Dashboard: Mini on-chart table summarizing structure, last swing points, and settings.
Alerts: Set alerts for new fractals, BOS events, and confluence-based trade setups.
Gamma & Max Pain HelperGamma & Max Pain Helper
Plots Call Wall, Put Wall, and Max Pain levels directly on your chart so you can see where options positioning might influence price.
Features:
Manually enter Call Wall, Put Wall, and Max Pain strike prices.
Lines auto-update each bar — no redrawing needed.
Labels display name + strike price.
Option to only show lines near current price (within a % you choose).
Color-coded:
Red = Call Wall (potential resistance)
Green = Put Wall (potential support)
Blue = Max Pain (price magnet into expiry)
Adjustable line width & extension.
Use Case:
Perfect for traders combining options open interest/gamma analysis with price action, pivots, VWAP, and other intraday levels. Quickly spot overlaps between option walls and technical barriers for high-probability reaction zones.
NTX STOCKS V.1الوصف بالعربي
مؤشر NTX STOCKS V.1 مصمم خصيصًا لتداول الأسهم على مختلف الأسواق، ويعمل بكفاءة عالية على الفريمات الكبيرة: ساعة، 4 ساعات، ويومي.
المؤشر مناسب للتداول في السوق السعودي و السوق الأمريكي، ويوفر إشارات دخول وخروج واضحة تساعد المتداول على اتخاذ قراراته بثقة.
المميزات:
• يعمل على فريم الساعة، 4 ساعات، واليومي.
• إشارات بيع وشراء واضحة.
• مناسب للأسواق السعودية والأمريكية.
• سهل الاستخدام وملائم للمتداولين المبتدئين والمحترفين.
⸻
Description in English
The NTX STOCKS V.1 indicator is designed specifically for stock trading across multiple markets, performing best on higher timeframes: 1 Hour, 4 Hours, and Daily.
It is suitable for both the Saudi stock market and the U.S. stock market, providing clear buy and sell signals to help traders make confident decisions.
Features:
• Works on 1H, 4H, and Daily charts.
• Clear buy/sell signals.
• Suitable for Saudi and U.S. stock markets.
• Easy to use for both beginners and professional traders.
⸻
KaloSTFEnglish Description for KaloSTF Indicator
KaloSTF is a powerful multi-timeframe (MTF) indicator designed to enhance your trading decisions by providing clear trend direction and momentum analysis across different timeframes. It helps traders identify the optimal entry and exit points by combining price action insights with robust technical filters. Whether you are a day trader or a swing trader, KaloSTF streamlines your workflow by displaying synchronized signals from higher and lower timeframes directly on your chart.
Key Features:
Multi-Timeframe trend detection
Clear visual signals for trend strength and reversals
Lightweight and efficient for real-time trading
Customizable parameters to fit any trading style
Perfect for use with Forex, commodities, and indices
Unlock higher precision in your trading strategies with KaloSTF — where clarity meets efficiency.
ADVANCE HULL EMA + VWAP//@version=6
indicator("ADVANCE HULL EMA + VWAP", shorttitle="Adv Hull EMA VWAP", overlay=true, max_lines_count=500, max_labels_count=500)
// ========================================
// MOVING AVERAGE SETTINGS
// ========================================
MA_GROUP = "Moving Average Settings"
modeSwitch = input.string("Ehma", title="MA Mode", options= , group=MA_GROUP)
ma_length = input.int(16, title="MA Length", minval=1, group=MA_GROUP)
useHtf = input.bool(false, title="Use Higher Time Frame", group=MA_GROUP)
htf = input.timeframe("240", title="HTF", group=MA_GROUP)
switchColor = input.bool(true, title="Switch Color", group=MA_GROUP)
visualSwitch = input.bool(true, title="Visual Switch", group=MA_GROUP)
thicknessSwitch = input.int(1, title="Line Thickness", minval=1, group=MA_GROUP)
showEMA100 = input.bool(true, title="Show EMA 100", group=MA_GROUP)
// ========================================
// VWAP SETTINGS
// ========================================
VWAP_GROUP = "VWAP Settings"
hideonDWM = input(false, title="Hide VWAP on 1D or Above", group=VWAP_GROUP, display = display.data_window)
var anchor = input.string(defval = "Session", title="Anchor Period",
options= , group=VWAP_GROUP)
src = input(title = "Source", defval = hlc3, group=VWAP_GROUP, display = display.data_window)
offset = input.int(0, title="Offset", group=VWAP_GROUP, minval=0, display = display.data_window)
BANDS_GROUP = "VWAP Bands Settings"
CALC_MODE_TOOLTIP = "Determines the units used to calculate the distance of the bands. When 'Percentage' is selected, a multiplier of 1 means 1%."
calcModeInput = input.string("Standard Deviation", "Bands Calculation Mode", options = , group = BANDS_GROUP, tooltip = CALC_MODE_TOOLTIP, display = display.data_window)
showBand_1 = input(true, title = "", group = BANDS_GROUP, inline = "band_1", display = display.data_window)
bandMult_1 = input.float(1.0, title = "Bands Multiplier #1", group = BANDS_GROUP, inline = "band_1", step = 0.5, minval=0, display = display.data_window)
showBand_2 = input(false, title = "", group = BANDS_GROUP, inline = "band_2", display = display.data_window)
bandMult_2 = input.float(2.0, title = "Bands Multiplier #2", group = BANDS_GROUP, inline = "band_2", step = 0.5, minval=0, display = display.data_window)
showBand_3 = input(false, title = "", group = BANDS_GROUP, inline = "band_3", display = display.data_window)
bandMult_3 = input.float(3.0, title = "Bands Multiplier #3", group = BANDS_GROUP, inline = "band_3", step = 0.5, minval=0, display = display.data_window)
// ========================================
// TRENDLINES SETTINGS
// ========================================
TRENDLINES_GROUP = "Trendlines Settings"
tl_length = input.int(14, 'Swing Detection Lookback', group=TRENDLINES_GROUP)
mult = input.float(1., 'Slope', minval = 0, step = .1, group=TRENDLINES_GROUP)
calcMethod = input.string('Atr', 'Slope Calculation Method', options = , group=TRENDLINES_GROUP)
backpaint = input(true, tooltip = 'Backpainting offset displayed elements in the past. Disable backpainting to see real time information returned by the indicator.', group=TRENDLINES_GROUP)
//Style
upCss = input.color(color.teal, 'Up Trendline Color', group = TRENDLINES_GROUP)
dnCss = input.color(color.red, 'Down Trendline Color', group = TRENDLINES_GROUP)
showExt = input(true, 'Show Extended Lines', group = TRENDLINES_GROUP)
// ========================================
// MOVING AVERAGE FUNCTIONS
// ========================================
HMA(src_ma, length_ma) => ta.wma(2 * ta.wma(src_ma, length_ma / 2) - ta.wma(src_ma, length_ma), math.round(math.sqrt(length_ma)))
EHMA(src_ma, length_ma) => ta.ema(2 * ta.ema(src_ma, length_ma) - ta.ema(src_ma, length_ma), math.round(math.sqrt(length_ma)))
THMA(src_ma, length_ma) => ta.wma(ta.wma(src_ma, length_ma / 3) * 3 - ta.wma(src_ma, length_ma / 2) - ta.wma(src_ma, length_ma), length_ma)
// ========================================
// MOVING AVERAGE CALCULATIONS
// ========================================
ema100 = ta.ema(close, 100)
selectedMA = modeSwitch == "Hma" ? HMA(close, ma_length) :
modeSwitch == "Ehma" ? EHMA(close, ma_length) :
modeSwitch == "Thma" ? THMA(close, ma_length / 2) : na
_hull = useHtf ? request.security(syminfo.tickerid, htf, selectedMA) : selectedMA
MHULL = _hull
SHULL = ta.valuewhen(not na(MHULL), MHULL , 0)
// ========================================
// VWAP CALCULATIONS
// ========================================
cumVolume = ta.cum(volume)
if barstate.islast and cumVolume == 0
runtime.error("No volume is provided by the data vendor.")
new_earnings = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true)
new_dividends = request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true)
new_split = request.splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true)
isNewPeriod = switch anchor
"Earnings" => not na(new_earnings)
"Dividends" => not na(new_dividends)
"Splits" => not na(new_split)
"Session" => timeframe.change("D")
"Week" => timeframe.change("W")
"Month" => timeframe.change("M")
"Quarter" => timeframe.change("3M")
"Year" => timeframe.change("12M")
"Decade" => timeframe.change("12M") and year % 10 == 0
"Century" => timeframe.change("12M") and year % 100 == 0
=> false
isEsdAnchor = anchor == "Earnings" or anchor == "Dividends" or anchor == "Splits"
if na(src ) and not isEsdAnchor
isNewPeriod := true
float vwapValue = na
float upperBandValue1 = na
float lowerBandValue1 = na
float upperBandValue2 = na
float lowerBandValue2 = na
float upperBandValue3 = na
float lowerBandValue3 = na
if not (hideonDWM and timeframe.isdwm)
= ta.vwap(src, isNewPeriod, 1)
vwapValue := _vwap
stdevAbs = _stdevUpper - _vwap
bandBasis = calcModeInput == "Standard Deviation" ? stdevAbs : _vwap * 0.01
upperBandValue1 := _vwap + bandBasis * bandMult_1
lowerBandValue1 := _vwap - bandBasis * bandMult_1
upperBandValue2 := _vwap + bandBasis * bandMult_2
lowerBandValue2 := _vwap - bandBasis * bandMult_2
upperBandValue3 := _vwap + bandBasis * bandMult_3
lowerBandValue3 := _vwap - bandBasis * bandMult_3
// ========================================
// TRENDLINES CALCULATIONS
// ========================================
var upper_tl = 0.
var lower_tl = 0.
var slope_ph = 0.
var slope_pl = 0.
var tl_offset = backpaint ? tl_length : 0
n = bar_index
ph = ta.pivothigh(tl_length, tl_length)
pl = ta.pivotlow(tl_length, tl_length)
// Fix for the conditional operator issue
is_ph = not na(ph)
is_pl = not na(pl)
//Slope Calculation Method
slope = switch calcMethod
'Atr' => ta.atr(tl_length) / tl_length * mult
'Stdev' => ta.stdev(close, tl_length) / tl_length * mult
'Linreg' => math.abs(ta.sma(close * n, tl_length) - ta.sma(close, tl_length) * ta.sma(n, tl_length)) / ta.variance(n, tl_length) / 2 * mult
//Get slopes and calculate trendlines
slope_ph := is_ph ? slope : slope_ph
slope_pl := is_pl ? slope : slope_pl
upper_tl := is_ph ? ph : upper_tl - slope_ph
lower_tl := is_pl ? pl : lower_tl + slope_pl
var upos = 0
var dnos = 0
upos := is_ph ? 0 : close > upper_tl - slope_ph * tl_length ? 1 : upos
dnos := is_pl ? 0 : close < lower_tl + slope_pl * tl_length ? 1 : dnos
// ========================================
// EXTENDED TRENDLINES
// ========================================
var uptl = line.new(na,na,na,na, color = upCss, style = line.style_dashed, extend = extend.right)
var dntl = line.new(na,na,na,na, color = dnCss, style = line.style_dashed, extend = extend.right)
if is_ph and showExt
uptl.set_xy1(n-tl_offset, backpaint ? ph : upper_tl - slope_ph * tl_length)
uptl.set_xy2(n-tl_offset+1, backpaint ? ph - slope : upper_tl - slope_ph * (tl_length+1))
if is_pl and showExt
dntl.set_xy1(n-tl_offset, backpaint ? pl : lower_tl + slope_pl * tl_length)
dntl.set_xy2(n-tl_offset+1, backpaint ? pl + slope : lower_tl + slope_pl * (tl_length+1))
// ========================================
// PLOTTING - MOVING AVERAGES
// ========================================
hullColor = switchColor ? (MHULL > MHULL ? color.new(color.blue, 0) : color.new(color.red, 0)) : color.new(color.red, 0)
MHULL_plot = plot(MHULL, title="Main MA Band", color=hullColor, linewidth=thicknessSwitch)
SHULL_plot = plot(visualSwitch ? SHULL : na, title="Secondary MA Band", color=hullColor, linewidth=thicknessSwitch)
fill(MHULL_plot, SHULL_plot, color=color.new(hullColor, 80))
plot(showEMA100 ? ema100 : na, title="EMA 100", color=color.purple, linewidth=4)
// ========================================
// PLOTTING - VWAP & BANDS
// ========================================
plot(vwapValue, title = "VWAP", color = #2962FF, offset = offset, linewidth=2)
upperBand_1 = plot(upperBandValue1, title="VWAP Upper Band #1", color = color.green, offset = offset, display = showBand_1 ? display.all : display.none, editable = showBand_1)
lowerBand_1 = plot(lowerBandValue1, title="VWAP Lower Band #1", color = color.green, offset = offset, display = showBand_1 ? display.all : display.none, editable = showBand_1)
fill(upperBand_1, lowerBand_1, title="VWAP Bands Fill #1", color = color.new(color.green, 95), display = showBand_1 ? display.all : display.none, editable = showBand_1)
upperBand_2 = plot(upperBandValue2, title="VWAP Upper Band #2", color = color.olive, offset = offset, display = showBand_2 ? display.all : display.none, editable = showBand_2)
lowerBand_2 = plot(lowerBandValue2, title="VWAP Lower Band #2", color = color.olive, offset = offset, display = showBand_2 ? display.all : display.none, editable = showBand_2)
fill(upperBand_2, lowerBand_2, title="VWAP Bands Fill #2", color = color.new(color.olive, 95), display = showBand_2 ? display.all : display.none, editable = showBand_2)
upperBand_3 = plot(upperBandValue3, title="VWAP Upper Band #3", color = color.teal, offset = offset, display = showBand_3 ? display.all : display.none, editable = showBand_3)
lowerBand_3 = plot(lowerBandValue3, title="VWAP Lower Band #3", color = color.teal, offset = offset, display = showBand_3 ? display.all : display.none, editable = showBand_3)
fill(upperBand_3, lowerBand_3, title="VWAP Bands Fill #3", color = color.new(color.teal, 95), display = showBand_3 ? display.all : display.none, editable = showBand_3)
// ========================================
// PLOTTING - TRENDLINES
// ========================================
plot(backpaint ? upper_tl : upper_tl - slope_ph * tl_length, 'Upper Trendline', color = is_ph ? na : upCss, offset = -tl_offset, linewidth=2)
plot(backpaint ? lower_tl : lower_tl + slope_pl * tl_length, 'Lower Trendline', color = is_pl ? na : dnCss, offset = -tl_offset, linewidth=2)
//Breakout Signals
plotshape(upos > upos ? low : na, "Upper Break"
, shape.labelup
, location.absolute
, upCss
, text = "B"
, textcolor = color.white
, size = size.tiny)
plotshape(dnos > dnos ? high : na, "Lower Break"
, shape.labeldown
, location.absolute
, dnCss
, text = "B"
, textcolor = color.white
, size = size.tiny)
// ========================================
// ALERTS
// ========================================
alertcondition(upos > upos , 'Upward Breakout', 'Price broke the down-trendline upward')
alertcondition(dnos > dnos , 'Downward Breakout', 'Price broke the up-trendline downward')
// Additional alerts for MA crossovers
alertcondition(ta.crossover(close, MHULL), 'Price Above MA', 'Price crossed above the main moving average')
alertcondition(ta.crossunder(close, MHULL), 'Price Below MA', 'Price crossed below the main moving average')
// VWAP alerts
alertcondition(ta.crossover(close, vwapValue), 'Price Above VWAP', 'Price crossed above VWAP')
alertcondition(ta.crossunder(close, vwapValue), 'Price Below VWAP', 'Price crossed below VWAP')
Linh's Anomaly Radar v2What this script does
It’s an event detector for price/volume anomalies that often precede or confirm moves.
It watches a bunch of patterns (Wyckoff tests, squeezes, failed breakouts, turnover bursts, etc.), applies robust z-scores, optional trend filters, cooldowns (to avoid spam), and then fires:
A shape/label on the bar,
A row in the mini panel (top-right),
A ready-made alertcondition you can hook into.
How to add & set up (TradingView)
Paste the script → Save → Add to chart on Daily first (works on any TF).
Open Settings → Inputs:
General
• Use Robust Z (MAD): more outlier-resistant; keep on.
• Z Lookback: 60 bars is ~3 months; bump to 120 for slower regimes.
• Cooldown: min bars to wait before the same signal can fire again (default 5).
• Use trend filter: if on, “bullish” signals only fire above SMA(tfLen), “bearish” below.
Thresholds: fine-tune sensitivity (defaults are sane).
To create alerts: Right-click chart → Add alert
Condition: Linh’s Anomaly Radar v2 → choose a specific signal or Composite (Σ).
Options: “Once per bar close” (recommended).
Customize message if you want ticker/timeframe in your phone push.
The mini panel (top-right)
Signal column: short code (see cheat sheet below).
Fired column: a dot “•” means that on the latest bar this signal fired.
Score (right column): total count of signals that fired this bar.
Σ≥N shows your composite threshold (how many must fire to trigger the “Composite” alert).
Shapes & codes (what’s what)
Code Name (category) What it’s looking for Why it matters
STL Stealth Volume z(volume)>5 & ** z(return)
EVR Effort vs Result squeeze z(vol)>3 & z(TR)<−0.5 Heavy effort, tiny spread → absorption
TGV Tight+Heavy (HL/ATR)<0.6 & z(vol)>3 Tight bar + heavy tape → pro activity
CLS Accumulation cluster ≥3 of last 5 bars: up, vol↑, close near high Classic accumulation footprint
GAP Open drive failure Big gap not filled (≥80%) & vol↑ One-sided open stalls → fade risk
BB↑ BB squeeze breakout Squeeze (z(BBWidth)<−1.3) → close > upperBB & vol↑ Regime shift with confirmation
ER↑ Effort→Result inversion Down day on vol then next bar > prior high Demand overwhelms supply
OBV OBV divergence OBV slope up & ** z(ret20)
WER Wide Effort, Opposite Result z(vol)>3, close+1 Selling into strength / distribution
NS No-Supply (Wyckoff) Down bar, HL<0.6·ATR, vol << avg Sellers absent into weakness
ND No-Demand (Wyckoff) Up bar, HL<0.6·ATR, vol << avg Buyers absent into strength
VAC Liquidity Vacuum z(vol)<−1.5 & ** z(ret)
UTD UTAD (failed breakout) Breaks swing-high, closes back below, vol↑ Stop-run, reversal risk
SPR Spring (failed breakdown) Breaks swing-low, closes back above, vol↑ Bear trap, reversal risk
PIV Pocket Pivot Up bar; vol > max down-vol in lookback Quiet base → sudden demand
NR7 Narrow Range 7 + Vol HL is 7-bar low & z(vol)>2 Coiled spring with participation
52W 52-wk breakout quality New 52-wk close high + squeeze + vol↑ High-quality breakouts
VvK Vol-of-Vol kink z(ATR20,200)>0.5 & z(ATR5,60)<0 Long-vol wakes up, short-vol compresses
TAC Turnover acceleration SMA3 vol / SMA20 vol > 1.8 & muted return Participation surging before move
RBd RSI Bullish div Price LL, RSI HL, vol z>1 Exhaustion of sellers
RS↑ RSI Bearish div Price HH, RSI LH, vol z>1 Exhaustion of buyers
Σ Composite Count of all fired signals ≥ threshold High-conviction bar
Placement:
Triangles up (below bar) → bullish-leaning events.
Triangles down (above bar) → bearish-leaning events.
Circles → neutral context (VAC, VvK, Composite).
Key inputs (quick reference)
General
Use Robust Z (MAD): keep on for noisy tickers.
Z Lookback (lenZ): 60 default; 120 if you want fewer alerts.
Trend filter: when on, bullish signals require close > SMA(tfLen), bearish require <.
Cooldown: prevents repeated firing of the same signal within N bars.
Phase-1 thresholds (core)
Stealth: vol z > 5, |ret z| < 1.
EVR: vol z > 3, TR z < −0.5.
Tight+Heavy: (HL/ATR) < 0.6, vol z > 3.
Cluster: window=5, min=3 strong bars.
GapFail: gap/ATR ≥1.5, fill <80%, vol z > 2.
BB Squeeze: z(BBWidth)<−1.3 then breakout with vol z > 2.
Eff→Res Up: prev bar heavy down → current bar > prior high.
OBV Div: OBV uptrend + |z(ret20)|<0.3.
Phase-2 thresholds (extras)
WER: vol z > 3, close1.
No-Supply/No-Demand: tight bar & very light volume vs SMA20.
Vacuum: vol z < −1.5, |ret z|>1.5.
UTAD/Spring: swing lookback N (default 20), vol z > 2.
Pocket Pivot: lookback for prior down-vol max (default 10).
NR7: 7-bar narrowest range + vol z > 2.
52W Quality: new 52-wk high + squeeze + vol z > 2.
VoV Kink: z(ATR20,200)>0.5 AND z(ATR5,60)<0.
Turnover Accel: SMA3/SMA20 > 1.8 and |ret z|<1.
RSI Divergences: compare to n bars back (default 14).
How to use it (playbooks)
A) Daily scan workflow
Run on Daily for your VN watchlist.
Turn Composite (Σ) alert on with Σ≥2 or ≥3 to reduce noise.
When a bar fires Σ (or a fav combo like STL + BB↑), drop to 60-min to time entries.
B) Breakout quality check
Look for 52W together with BB↑, TAC, and OBV.
If WER/ND appear near highs → downgrade the breakout.
C) Spring/UTAD reversals
If SPR fires near major support and RBd confirms → long bias with stop below spring low.
If UTD + WER/RS↑ near resistance → short/fade with stop above UTAD high.
D) Accumulation basing
During bases, you want CLS, OBV, TGV, STL, NR7.
A pocket pivot (PIV) can be your early add; manage risk below base lows.
Tuning tips
Too many signals? Raise stealthVolZ to 5.5–6, evrVolZ to 3.5, use Σ≥3.
Fast movers? Lower bbwZthr to −1.0 (less strict squeeze), keep trend filter on.
Illiquid tickers? Keep MAD z-scores on, increase lookbacks (e.g., lenZ=120).
Limitations & good habits
First lenZ bars on a new symbol are less reliable (incomplete z-window).
Some ideas (VWAP magnet, close auction spikes, ETF/foreign flows, options skew) need intraday/external feeds — not included here.
Pine can’t “screen” across the whole market; set alerts or cycle your watchlist.
Quick troubleshooting
Compilation errors: make sure you’re on Pine v6; don’t nest functions in if blocks; each var int must be declared on its own line.
No shapes firing: check trend filter (maybe price is below SMA and you’re waiting for bullish signals), and verify thresholds aren’t too strict.
4 Moving Averages 4 Moving Averages
An indicator with four moving averages with ready-to-use settings. Use them as support and resistance.
EMA+RSI+MACD+Vol - Buy/Sell-2EMA+RSI+MACD+Volume Indicator Summary
This Pine Script (v5) is a TradingView indicator that combines EMA, RSI, MACD, and volume to generate buy and sell signals.
Featurez
EMA (50): Tracks the price trend.
RSI (14): Monitors overbought (70) and oversold (30) levels.
MACD (12, 26, 9): Used for momentum signals.
Volume Filter: Validates signals with sufficient volume.
Signals: Buy when MACD crosses above the signal line, price is above EMA, RSI is above oversold, and volume is adequate. Sell for the opposite conditions.
Visuals: Green "BUY" labels for buy signals and red "SELL" labels for sell signals are displayed on the chart.
Alerts: Configurable TradingView alerts for buy/sell signals.
Usage
Customize parameters (EMA length, RSI levels, etc.) based on your market.
Displays signals on the chart and clears old labels to avoid clutter.
Backtest to verify signal effectiveness.
tenth-OptionsThis Pine Script indicator "tenth-Options" automatically detects the 9:30 AM opening candle, draws a green line at its high with a buy label, adds a sell/stop-loss label at its low, and plots a white Kijun-Sen line (default period 30) for trend reference on intraday timeframes under one hour.
VN30 Effort-vs-Result Multi-Scanner — LinhVN30 Effort-vs-Result Multi-Scanner (Pine v5)
Cross-section scanner for Vietnam’s VN30 stocks that surfaces Effort vs Result footprints and related accumulation/distribution and volatility tells. It renders a ranked table (Top-N) with per-ticker signals and key metrics.
What it does
Scans up to 30 tickers (editable input.symbol slots) using one security() call per symbol → stays under Pine’s 40-call limit and runs reliably on any chart.
Scores each ticker by counting active signals, then ranks and lists the top names.
Optional metrics columns: zVol(60), zTR(60), ATR(20), HL/ATR(20).
Signals (toggleable)
Price/Volume – Effort vs Result
EVR Squeeze (stealth): z(Vol,60) > 4 & z(TR,60) < −0.5
5σ Vol, ≤1σ Ret: z(Vol,60) > 5 & |z(Return,60)| < 1
Wide Effort, Opposite Result: z(Vol,60) > 3 & close < open & z(CLV×Vol,60) > 1
Spread Compression, Heavy Tape: (H−L)/ATR(20) < 0.6 & z(Vol,60) > 3
No-Supply / No-Demand: close < close & range < 0.6×ATR(20) & vol < 0.5×SMA(20)
Momentum & Volatility
Vol-of-Vol Kink: z(ATR20,200) rising & z(ATR5,60) falling
BB Squeeze → Expansion: BBWidth(20) in low regime (z<−1.3) then close > upper band & z(Vol,60) > 2
RSI Non-Confirmation: Price LL/HH with RSI HL/LH & z(Vol,60) > 1
Accumulation/Distribution
OBV Divergence w/ Flat Price: OBV slope > 0 & |z(ret20,260)| < 0.3
Accumulation Days Cluster: ≥3/5 bars: up close, higher vol, close near high
Effort-Result Inversion (Down): big vol on down day then next day close > prior high
How to use
Set the timeframe (works best on 1D for EOD scans).
Edit the 30 symbol slots to your VN30 constituents.
Choose Top N, toggle Show metrics/Only matches and enable/disable scenarios.
Read the table: Rank, Ticker, (metrics), Score, and comma-separated Signals fired.
Method notes
Z-scores use a population-std estimate; CLV×Vol is used for effort/location.
Rolling counts avoid ta.sum; OBV is computed manually; all logic is Pine v5-safe.
Intraday-only ideas (true VWAP magnets, auction volume, flows, futures/options) are not included—Pine can’t cross-scan those datasets.
Disclaimer: Educational tool, not financial advice. Always confirm signals on the chart and with your process.
My script
//@version=5
indicator(title = "Trader Club 5in1", shorttitle="Trader Club 5in1", overlay=true, format=format.price, precision=2,max_lines_count = 500, max_labels_count = 500, max_bars_back=500)
showEma200 = input(true, title="EMA 200")
showPmax = input(true, title="Pmax")
showLinreg = input(true, title="Linreg")
showMavilim = input(true, title="Mavilim")
showNadaray = input(true, title="Nadaraya Watson")
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
//Ema200
timeFrame = input.timeframe(defval = '240',title= 'EMA200 TimeFrame',group = 'EMA200 Settings')
len200 = input.int(200, minval=1, title="Length",group = 'EMA200 Settings')
src200 = input(close, title="Source",group = 'EMA200 Settings')
offset200 = input.int(title="Offset", defval=0, minval=-500, maxval=500,group = 'EMA200 Settings')
out200 = ta.ema(src200, len200)
higherTimeFrame = request.security(syminfo.tickerid,timeFrame,out200 ,barmerge.gaps_on,barmerge.lookahead_on)
ema200Plot = showEma200 ? higherTimeFrame : na
plot(ema200Plot, title="EMA200", offset=offset200)
//Linreq
group1 = "Linreg Settings"
lengthInput = input.int(100, title="Length", minval = 1, maxval = 5000,group = group1)
sourceInput = input.source(close, title="Source")
useUpperDevInput = input.bool(true, title="Upper Deviation", inline = "Upper Deviation", group = group1)
upperMultInput = input.float(2.0, title="", inline = "Upper Deviation", group = group1)
useLowerDevInput = input.bool(true, title="Lower Deviation", inline = "Lower Deviation", group = group1)
lowerMultInput = input.float(2.0, title="", inline = "Lower Deviation", group = group1)
group2 = "Linreg Display Settings"
showPearsonInput = input.bool(true, "Show Pearson's R", group = group2)
extendLeftInput = input.bool(false, "Extend Lines Left", group = group2)
extendRightInput = input.bool(true, "Extend Lines Right", group = group2)
extendStyle = switch
extendLeftInput and extendRightInput => extend.both
extendLeftInput => extend.left
extendRightInput => extend.right
=> extend.none
group3 = "Linreg Color Settings"
colorUpper = input.color(color.new(color.blue, 85), "Linreg Renk", inline = group3, group = group3)
colorLower = input.color(color.new(color.red, 85), "", inline = group3, group = group3)
calcSlope(source, length) =>
max_bars_back(source, 5000)
if not barstate.islast or length <= 1
else
sumX = 0.0
sumY = 0.0
sumXSqr = 0.0
sumXY = 0.0
for i = 0 to length - 1 by 1
val = source
per = i + 1.0
sumX += per
sumY += val
sumXSqr += per * per
sumXY += val * per
slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX)
average = sumY / length
intercept = average - slope * sumX / length + slope
= calcSlope(sourceInput, lengthInput)
startPrice = i + s * (lengthInput - 1)
endPrice = i
var line baseLine = na
if na(baseLine) and not na(startPrice) and showLinreg
baseLine := line.new(bar_index - lengthInput + 1, startPrice, bar_index, endPrice, width=1, extend=extendStyle, color=color.new(colorLower, 0))
else
line.set_xy1(baseLine, bar_index - lengthInput + 1, startPrice)
line.set_xy2(baseLine, bar_index, endPrice)
na
calcDev(source, length, slope, average, intercept) =>
upDev = 0.0
dnDev = 0.0
stdDevAcc = 0.0
dsxx = 0.0
dsyy = 0.0
dsxy = 0.0
periods = length - 1
daY = intercept + slope * periods / 2
val = intercept
for j = 0 to periods by 1
price = high - val
if price > upDev
upDev := price
price := val - low
if price > dnDev
dnDev := price
price := source
dxt = price - average
dyt = val - daY
price -= val
stdDevAcc += price * price
dsxx += dxt * dxt
dsyy += dyt * dyt
dsxy += dxt * dyt
val += slope
stdDev = math.sqrt(stdDevAcc / (periods == 0 ? 1 : periods))
pearsonR = dsxx == 0 or dsyy == 0 ? 0 : dsxy / math.sqrt(dsxx * dsyy)
= calcDev(sourceInput, lengthInput, s, a, i)
upperStartPrice = startPrice + (useUpperDevInput ? upperMultInput * stdDev : upDev)
upperEndPrice = endPrice + (useUpperDevInput ? upperMultInput * stdDev : upDev)
var line upper = na
lowerStartPrice = startPrice + (useLowerDevInput ? -lowerMultInput * stdDev : -dnDev)
lowerEndPrice = endPrice + (useLowerDevInput ? -lowerMultInput * stdDev : -dnDev)
var line lower = na
if na(upper) and not na(upperStartPrice) and showLinreg
upper := line.new(bar_index - lengthInput + 1, upperStartPrice, bar_index, upperEndPrice, width=1, extend=extendStyle, color=color.new(colorUpper, 0))
else
line.set_xy1(upper, bar_index - lengthInput + 1, upperStartPrice)
line.set_xy2(upper, bar_index, upperEndPrice)
na
if na(lower) and not na(lowerStartPrice) and showLinreg
lower := line.new(bar_index - lengthInput + 1, lowerStartPrice, bar_index, lowerEndPrice, width=1, extend=extendStyle, color=color.new(colorUpper, 0))
else
line.set_xy1(lower, bar_index - lengthInput + 1, lowerStartPrice)
line.set_xy2(lower, bar_index, lowerEndPrice)
na
showLinregPlotUpper = showLinreg ? upper : na
showLinregPlotLower = showLinreg ? lower : na
showLinregPlotBaseLine = showLinreg ? baseLine : na
linefill.new(showLinregPlotUpper, showLinregPlotBaseLine, color = colorUpper)
linefill.new(showLinregPlotBaseLine, showLinregPlotLower, color = colorLower)
// Pearson's R
var label r = na
label.delete(r )
if showPearsonInput and not na(pearsonR) and showLinreg
r := label.new(bar_index - lengthInput + 1, lowerStartPrice, str.tostring(pearsonR, "#.################"), color = color.new(color.white, 100), textcolor=color.new(colorUpper, 0), size=size.normal, style=label.style_label_up)
//Mavilim
group4 = "Mavilim Settings"
mavilimold = input(false, title="Show Previous Version of MavilimW?",group=group4)
fmal=input(3,"First Moving Average length",group = group4)
smal=input(5,"Second Moving Average length",group = group4)
tmal=fmal+smal
Fmal=smal+tmal
Ftmal=tmal+Fmal
Smal=Fmal+Ftmal
M1= ta.wma(close, fmal)
M2= ta.wma(M1, smal)
M3= ta.wma(M2, tmal)
M4= ta.wma(M3, Fmal)
M5= ta.wma(M4, Ftmal)
MAVW= ta.wma(M5, Smal)
col1= MAVW>MAVW
col3= MAVWpmaxsrc ? pmaxsrc-pmaxsrc : 0
vdd1=pmaxsrc
ma = 0.0
if mav == "SMA"
ma := ta.sma(pmaxsrc, length)
ma
if mav == "EMA"
ma := ta.ema(pmaxsrc, length)
ma
if mav == "WMA"
ma := ta.wma(pmaxsrc, length)
ma
if mav == "TMA"
ma := ta.sma(ta.sma(pmaxsrc, math.ceil(length / 2)), math.floor(length / 2) + 1)
ma
if mav == "VAR"
ma := VAR
ma
if mav == "WWMA"
ma := WWMA
ma
if mav == "ZLEMA"
ma := ZLEMA
ma
if mav == "TSF"
ma := TSF
ma
ma
MAvg=getMA(pmaxsrc, length)
longStop = Normalize ? MAvg - Multiplier*atr/close : MAvg - Multiplier*atr
longStopPrev = nz(longStop , longStop)
longStop := MAvg > longStopPrev ? math.max(longStop, longStopPrev) : longStop
shortStop = Normalize ? MAvg + Multiplier*atr/close : MAvg + Multiplier*atr
shortStopPrev = nz(shortStop , shortStop)
shortStop := MAvg < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
dir = 1
dir := nz(dir , dir)
dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg < longStopPrev ? -1 : dir
PMax = dir==1 ? longStop: shortStop
// plot(showsupport ? MAvg : na, color=#0585E1, linewidth=2, title="EMA9")
pmaxPlot = showPmax ? PMax : na
pALL=plot(pmaxPlot, color=color.new(#FF5252, transp = 0), linewidth=2, title="PMax")
alertcondition(ta.cross(MAvg, PMax), title="Cross Alert", message="PMax - Moving Avg Crossing!")
alertcondition(ta.crossover(MAvg, PMax), title="Crossover Alarm", message="Moving Avg BUY SIGNAL!")
alertcondition(ta.crossunder(MAvg, PMax), title="Crossunder Alarm", message="Moving Avg SELL SIGNAL!")
alertcondition(ta.cross(pmaxsrc, PMax), title="Price Cross Alert", message="PMax - Price Crossing!")
alertcondition(ta.crossover(pmaxsrc, PMax), title="Price Crossover Alarm", message="PRICE OVER PMax - BUY SIGNAL!")
alertcondition(ta.crossunder(pmaxsrc, PMax), title="Price Crossunder Alarm", message="PRICE UNDER PMax - SELL SIGNAL!")
buySignalk = ta.crossover(MAvg, PMax)
plotshape(buySignalk and showsignalsk and showPmax ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, transp = 0), textcolor=color.white)
sellSignallk = ta.crossunder(MAvg, PMax)
plotshape(sellSignallk and showsignalsk and showPmax ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, transp = 0), textcolor=color.white)
// buySignalc = ta.crossover(pmaxsrc, PMax)
// plotshape(buySignalc and showsignalsc ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=#0F18BF, textcolor=color.white)
// sellSignallc = ta.crossunder(pmaxsrc, PMax)
// plotshape(sellSignallc and showsignalsc ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=#0F18BF, textcolor=color.white)
// mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0,display=display.none)
longFillColor = highlighting ? (MAvg>PMax ? color.new(color.green, transp = 90) : na) : na
shortFillColor = highlighting ? (MAvg math.exp(-(math.pow(x, 2)/(h * h * 2)))
//-----------------------------------------------------------------------------}
//Append lines
//-----------------------------------------------------------------------------{
n = bar_index
var ln = array.new_line(0)
if barstate.isfirst and repaint
for i = 0 to 499
array.push(ln,line.new(na,na,na,na))
//-----------------------------------------------------------------------------}
//End point method
//-----------------------------------------------------------------------------{
var coefs = array.new_float(0)
var den = 0.
if barstate.isfirst and not repaint
for i = 0 to 499
w = gauss(i, h)
coefs.push(w)
den := coefs.sum()
out = 0.
if not repaint
for i = 0 to 499
out += src * coefs.get(i)
out /= den
mae = ta.sma(math.abs(src - out), 499) * mult
upperN = out + mae
lowerN = out - mae
//-----------------------------------------------------------------------------}
//Compute and display NWE
//-----------------------------------------------------------------------------{
float y2 = na
float y1 = na
nwe = array.new(0)
if barstate.islast and repaint
sae = 0.
//Compute and set NWE point
for i = 0 to math.min(499,n - 1)
sum = 0.
sumw = 0.
//Compute weighted mean
for j = 0 to math.min(499,n - 1)
w = gauss(i - j, h)
sum += src * w
sumw += w
y2 := sum / sumw
sae += math.abs(src - y2)
nwe.push(y2)
sae := sae / math.min(499,n - 1) * mult
for i = 0 to math.min(499,n - 1)
if i%2 and showNadaray
line.new(n-i+1, y1 + sae, n-i, nwe.get(i) + sae, color = upCss)
line.new(n-i+1, y1 - sae, n-i, nwe.get(i) - sae, color = dnCss)
if src > nwe.get(i) + sae and src < nwe.get(i) + sae and showNadaray
label.new(n-i, src , '▼', color = color(na), style = label.style_label_down, textcolor = dnCss, textalign = text.align_center)
if src < nwe.get(i) - sae and src > nwe.get(i) - sae and showNadaray
label.new(n-i, src , '▲', color = color(na), style = label.style_label_up, textcolor = upCss, textalign = text.align_center)
y1 := nwe.get(i)
//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
var tb = table.new(position.top_right, 1, 1
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if repaint
tb.cell(0, 0, 'Repainting Mode Enabled', text_color = color.white, text_size = size.small)
//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------}
// plot(repaint ? na : out + mae, 'Upper', upCss)
// plot(repaint ? na : out - mae, 'Lower', dnCss)
//Crossing Arrows
// plotshape(ta.crossunder(close, out - mae) ? low : na, "Crossunder", shape.labelup, location.absolute, color(na), 0 , text = '▲', textcolor = upCss, size = size.tiny)
// plotshape(ta.crossover(close, out + mae) ? high : na, "Crossover", shape.labeldown, location.absolute, color(na), 0 , text = '▼', textcolor = dnCss, size = size.tiny)
//-----------------------------------------------------------------------------}
VP-Period with Previous Day Levels & Historical POC# Volume Profile with Previous Day Levels & Historical POCs
## Description
Comprehensive indicator combining Volume Profile analysis, previous day levels, and historical POC (Point of Control) levels for advanced technical analysis.
## Key Features
### Volume Profile
- **Customizable period**: 3 to 500 days
- **Calculation resolution**: 400 to 700 points
- **Current VPOC**: Point of Control line for current period
- **Volume bars**: graphical display of volume profile distribution
### Historical POCs
- **POC history**: up to 20 previous days
- **Time labels**: shows how many days ago for each POC
- **Dashed lines**: easy identification of historical levels
### Previous Day Levels (last 5 days)
- **High/Low**: daily highs and lows
- **Midpoint**: 50% level (High+Low)/2
- **Open/Close**: opening and closing prices
- **Progressive thickness**: day 1 thicker, decreasing for previous days
## Customization
- Fully configurable colors for each element
- Toggle on/off switches for every component
- Different line styles (solid, dashed, dotted)
## Usage
Perfect for traders using volume analysis and support/resistance based on previous daily levels. Ideal for identifying key zones and significant breakout points.
Multi Timeframe 7 Bollinger Bands by CSPMulti Timeframe 7 Bollinger Bands by CSP IT SHOW 1MT,5MT,10MT,1HR,D, W,M BOLLINGER BAND IN ASINGLE CHART.