Re: Something interesting please post here (Metatrader)
4383Dynamic Swing Anchored VWAP (Zeiierman)
Code: Select all
// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// https://creativecommons.org/licenses/by-nc-sa/4.0/
// © Zeiierman {
//@version=6
indicator('Dynamic Swing Anchored VWAP (Zeiierman)', overlay = true, max_bars_back = 5000, max_labels_count = 500, max_polylines_count = 100)
//~~}
// ~~ Tooltips {
var string t1 = "Number of bars used to detect swing highs and lows. Larger values identify bigger, more significant swings but react slower. Smaller values detect more frequent swings but may produce more noise."
var string t2 = "Controls how quickly the VWAP adjusts to new price action. Lower values make the VWAP react faster (tighter to price), higher values make it smoother and slower to change."
var string t3 = "When enabled, the VWAP reaction speed changes automatically based on market volatility. High volatility shortens the tracking period (more responsive), low volatility lengthens it (smoother)."
var string t4 = "Controls how strongly volatility influences the VWAP reaction speed. Values above 1 increase the effect of volatility changes; values below 1 make it less sensitive to volatility."
var string t5 = "Color used for swing high/low labels drawn on the chart to indicate pivot points."
var string t6 = "Color used for swing low labels when marking pivot points."
var string t7 = "Color used for VWAP lines when in an uptrend."
var string t8 = "Color used for VWAP lines when in a downtrend."
var string t9 = "Width of the VWAP lines drawn on the chart. Larger values make the lines thicker and more visible."
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Inputs {
prd = input.int(50, title='Swing Period', minval=2, group='Swing Points', tooltip=t1)
baseAPT = input.float(20, 'Adaptive Price Tracking', minval=1, step=1, group='Swing Points', tooltip=t2)
useAdapt = input.bool(false, 'Adapt APT by ATR ratio', group='Swing Points', tooltip=t3)
volBias = input.float(10.0, 'Volatility Bias', minval=0.1, step=0.1, group='Swing Points', tooltip=t4)
highS = input.color(color.lime, title="Swing Labels", group="Style", inline="Swing", tooltip=t5)
lowS = input.color(color.red, title="", group="Style", inline="Swing", tooltip=t6)
S = input.color(color.lime, title="VWAP Lines", group="Style", inline="VWAP", tooltip=t7)
R = input.color(color.red, title="", group="Style", inline="VWAP", tooltip=t8)
xx = input.int(2, minval=1, title="", group="Style", inline="VWAP", tooltip=t9)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Global Variable {
b = bar_index
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ PIVOTS Variables {
var ph = float(na)
var pl = float(na)
var phL = b
var plL = b
var lab = label(na)
var prev = float(na)
ph := ta.highestbars(high, prd) == 0 ? high : ph
pl := ta.lowestbars(low, prd) == 0 ? low : pl
phL := ta.highestbars(high, prd) == 0 ? b : phL
plL := ta.lowestbars(low, prd) == 0 ? b : plL
dir = phL > plL ? 1 : -1
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Adaptation {
atrLen = 50
atr = ta.atr(atrLen)
atrAvg = ta.rma(atr, atrLen)
ratio = atrAvg > 0 ? atr / atrAvg : 1.0
aptRaw = useAdapt ? baseAPT / math.pow(ratio, volBias) : baseAPT
aptClamped = math.max(5.0, math.min(300.0, aptRaw))
aptSeries = math.round(aptClamped)
// alpha from APT (half-life -> EWMA alpha)
alphaFromAPT(apt) =>
decay = math.exp(-math.log(2.0) / math.max(1.0, apt))
1.0 - decay
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ VWAP Variables {
var p = hlc3 * volume
var vol = volume
type dataPoints
array<chart.point> points
polyline poly = na
var vwap = dataPoints.new(array.new<chart.point>())
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Main {
if dir != dir[1]
x = dir > 0 ? plL : phL
y = dir > 0 ? pl : ph
loc = dir > 0 ? label.style_label_up : label.style_label_down
col = dir > 0 ? highS : lowS
txt = dir > 0 and pl < prev ? 'LL' : dir > 0 and pl > prev ? 'HL' : dir < 0 and ph < prev ? 'LH' : dir < 0 and ph > prev ? 'HH' : ''
label.new(x, y, text=txt, style=loc, color=color.new(col, 20), textcolor=color.white)
prev := dir > 0 ? ph[1] : pl[1]
barsback = b - x
p := y * volume[barsback]
vol := volume[barsback]
vap = p / vol
vwap.poly.delete()
polyline.new(vwap.points, false, false, line_color = dir < 0 ? R : S, line_width = xx)
vwap.points.clear()
for i = barsback to 0 by 1
apt_i = aptSeries[i]
alpha = alphaFromAPT(apt_i)
pxv = hlc3[i] * volume[i]
v_i = volume[i]
p := (1.0 - alpha) * p + alpha * pxv
vol := (1.0 - alpha) * vol + alpha * v_i
vappe = vol > 0 ? p / vol : na
vwap.points.push(chart.point.from_index(b - i, vappe))
vwap.poly := polyline.new(vwap.points, false, false, line_color = dir < 0 ? R : S, line_width = xx)
else
apt_0 = aptSeries
alpha = alphaFromAPT(apt_0)
pxv = hlc3 * volume
v0 = volume
p := (1.0 - alpha) * p + alpha * pxv
vol := (1.0 - alpha) * vol + alpha * v0
vap = vol > 0 ? p / vol : na
vwap.poly.delete()
vwap.points.push(chart.point.from_index(b, vap))
vwap.poly := polyline.new(vwap.points, false, false, line_color = dir > 0 ? R : S, line_width = xx)
//~~ }
Re: Something interesting please post here (Metatrader)
4385Uptrick: Volatility Adjusted Trail
Code: Select all
// This work is licensed under an Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0)
// https://creativecommons.org/licenses/by-sa/4.0/
// © Uptrick
//@version=6
// ██╗ ██╗██████╗ ████████╗██████╗ ██╗ ██████╗██╗ ██╗
// ██║ ██║██╔══██╗╚══██╔══╝██╔══██╗██║██╔════╝██║ ██╔╝
// ██║ ██║██████╔╝ ██║ ██████╔╝██║██║ █████╔╝
// ██║ ██║██╔═══╝ ██║ ██╔══██╗██║██║ ██╔═██╗
// ╚██████╔╝██║ ██║ ██║ ██║██║╚██████╗██║ ██╗
// ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝╚═╝ ╚═╝
indicator("Uptrick: Volatility Adjusted Trail", overlay=true)
//== Inputs
emaLen = input.int(8, "Basis EMA Length", minval=2)
atrLen = input.int(14, "ATR Length", minval=1)
baseMult = input.float(2.0, "Base ATR Mult", minval=0.1, step=0.1)
sensExp = input.float(1.00, "Volatility Expansion Sensitivity", minval=0.10, step=0.05)
persLen = input.int(20, "Trend Persistence Window", minval=2)
persGain = input.float(0.30, "Persistence Impact (0..1)", minval=0.0, maxval=1.0, step=0.05)
multMin = input.float(1.0, "Min Effective Mult", minval=0.1, step=0.1)
multMax = input.float(4.0, "Max Effective Mult", minval=0.5, step=0.1)
confirmN = input.int(1, "Bars Above/Below to Confirm Flip", minval=1)
//== Colors (Uptrick palette)
bullCol = color.rgb(92,240,215) // #5CF0D7
bearCol = color.rgb(179,42,195) // #B32AC3
midGray = color.new(color.gray, 100)
fillBull = color.new(color.rgb(88,237,212), 80)
fillBear = color.new(color.rgb(177,41,192), 80)
//== Core series
basis = ta.ema(close, emaLen)
atr = ta.atr(atrLen)
atrMA = ta.sma(atr, atrLen)
expRatio = atrMA == 0.0 ? 1.0 : atr / atrMA // >1 = expansion, <1 = compression
expAdj = math.pow(expRatio, sensExp) // sensitivity to expansion
slope = basis - basis[1]
dirStep = slope >= 0 ? 1.0 : -1.0
persist = ta.ema(dirStep, persLen) // -1..+1 trend memory
persistAdj = 1.0 + persGain * math.abs(persist) // widen when trend is consistent
dynMultRaw = baseMult * expAdj * persistAdj
dynMult = math.min(math.max(dynMultRaw, multMin), multMax) // clamp to bounds
upperBand = basis + dynMult * atr
lowerBand = basis - dynMult * atr
//== Trailing bands (Supertrend-style)
var float trailUp = na
var float trailDn = na
var int state = 0 // 1 bull, -1 bear, 0 neutral
if na(trailUp)
trailUp := lowerBand
if na(trailDn)
trailDn := upperBand
if state == 1
trailUp := math.max(lowerBand, nz(trailUp[1]))
trailDn := upperBand // reset opposing side
if state == -1
trailDn := math.min(upperBand, nz(trailDn[1]))
trailUp := lowerBand
//== Flip conditions with persistence confirmation
var int upCnt = 0
var int dnCnt = 0
aboveDn = close > trailDn
belowUp = close < trailUp
if aboveDn
upCnt += 1
else
upCnt := 0
if belowUp
dnCnt += 1
else
dnCnt := 0
if state == 0
if upCnt >= confirmN
state := 1
if dnCnt >= confirmN
state := -1
else
if state == 1 and dnCnt >= confirmN
state := -1
if state == -1 and upCnt >= confirmN
state := 1
//== Visuals
isBull = state == 1
isBear = state == -1
ribColor = isBull ? bullCol : isBear ? bearCol : midGray
pUpper = plot(trailDn, "ASB Upper Trail", color=isBear ? bearCol : midGray, linewidth=2, style=plot.style_linebr)
pLower = plot(trailUp, "ASB Lower Trail", color=isBull ? bullCol : midGray, linewidth=2, style=plot.style_linebr)
price = plot(close, color=midGray)
fill(pUpper, price, trailDn, close, isBear? color.new(bearCol,50): midGray, midGray,'FILL COLOR')
fill(pLower, price, close, trailUp, midGray, isBull? color.new(bullCol,50): midGray,'FILL COLOR')
barcolor(isBull ? bullCol : isBear ? bearCol : color.new(color.gray, 70))
//== Flip markers & alerts
bullFlip = ta.change(state) == 2 // -1 -> 1
bearFlip = ta.change(state) == -2 // 1 -> -1
// === Label settings
showLabels = input.bool(true, "Show Flip Labels")
lblSize = input.string("Normal", "Label Size", options=["Tiny","Small","Normal","Large","Huge"])
lblAtrOffset = input.float(0.60, "Label ATR Offset (× ATR)")
toSize(s) =>
s == "Tiny" ? size.tiny :
s == "Small" ? size.small :
s == "Normal" ? size.normal:
s == "Large" ? size.large :
size.huge
// === Flip labels anchored to bands
if showLabels and bullFlip
yDn = trailUp - lblAtrOffset * atr // below lower band
label.new(bar_index, yDn,
text="𝓤𝓹",
style=label.style_label_up,
size=toSize(lblSize),
color=color.new(bullCol, 0),
textcolor=#000000)
if showLabels and bearFlip
yUp = trailDn + lblAtrOffset * atr // above upper band
label.new(bar_index, yUp,
text="𝓓𝓸𝔀𝓷",
style=label.style_label_down,
size=toSize(lblSize),
color=color.new(bearCol, 0),
textcolor=#ffffff)
alertcondition(bullFlip, "ASB Bull Flip", "ASB: Bullish flip on {{ticker}} {{interval}}")
alertcondition(bearFlip, "ASB Bear Flip", "ASB: Bearish flip on {{ticker}} {{interval}}")
plotcandle(open,high,low,close,'Plotcandle',isBull ? bullCol : isBear ? bearCol : color.new(color.gray, 70),isBull ? bullCol : isBear ? bearCol : color.new(color.gray, 70),bordercolor = isBull ? bullCol : isBear ? bearCol : color.new(color.gray, 70),force_overlay = true,display = display.pane)
Re: Something interesting please post here (Metatrader)
4386Advanced Supply Demand 8.3
- These users thanked the author pin12 for the post (total 2):
- Tsar, specialkey
Re: Something interesting please post here (Metatrader)
4387
Kubii indicator when its broken ober baughtand over sold need arrow indicator with alert, can admin rebuild it plsfriend4you wrote: Fri Feb 17, 2017 7:41 am I found something, a mix of many popular oszilators in one called kubi (oscilator in pic). Maybe you ca do a dynamic indicator out of it or do some filtering.
Red - blue is a tsd 2015 production Fractals - adjustable price breakout _mtf+alerts nmc.mq4
Subtrade are the thin stepma like lines. All indicators don't look to repaint in strategy tester. How can I see that in the code?
kubi.PNG
kubi.mq4
Fractals - adjustable price breakout _mtf+alerts nmc.mq4
sub_trade1.mq4
sub_trade2.mq4
Re: Something interesting please post here (Metatrader)
4388Claude Ai did the conversion.Eis wrote: Wed Jul 22, 2026 3:21 am
Dynamic Swing Anchored VWAP (Zeiierman)
Code: Select all
// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International // https://creativecommons.org/licenses/by-nc-sa/4.0/ // © Zeiierman { //@version=6 indicator('Dynamic Swing Anchored VWAP (Zeiierman)', overlay = true, max_bars_back = 5000, max_labels_count = 500, max_polylines_count = 100) //~~} // ~~ Tooltips { var string t1 = "Number of bars used to detect swing highs and lows. Larger values identify bigger, more significant swings but react slower. Smaller values detect more frequent swings but may produce more noise." var string t2 = "Controls how quickly the VWAP adjusts to new price action. Lower values make the VWAP react faster (tighter to price), higher values make it smoother and slower to change." var string t3 = "When enabled, the VWAP reaction speed changes automatically based on market volatility. High volatility shortens the tracking period (more responsive), low volatility lengthens it (smoother)." var string t4 = "Controls how strongly volatility influences the VWAP reaction speed. Values above 1 increase the effect of volatility changes; values below 1 make it less sensitive to volatility." var string t5 = "Color used for swing high/low labels drawn on the chart to indicate pivot points." var string t6 = "Color used for swing low labels when marking pivot points." var string t7 = "Color used for VWAP lines when in an uptrend." var string t8 = "Color used for VWAP lines when in a downtrend." var string t9 = "Width of the VWAP lines drawn on the chart. Larger values make the lines thicker and more visible." //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Inputs { prd = input.int(50, title='Swing Period', minval=2, group='Swing Points', tooltip=t1) baseAPT = input.float(20, 'Adaptive Price Tracking', minval=1, step=1, group='Swing Points', tooltip=t2) useAdapt = input.bool(false, 'Adapt APT by ATR ratio', group='Swing Points', tooltip=t3) volBias = input.float(10.0, 'Volatility Bias', minval=0.1, step=0.1, group='Swing Points', tooltip=t4) highS = input.color(color.lime, title="Swing Labels", group="Style", inline="Swing", tooltip=t5) lowS = input.color(color.red, title="", group="Style", inline="Swing", tooltip=t6) S = input.color(color.lime, title="VWAP Lines", group="Style", inline="VWAP", tooltip=t7) R = input.color(color.red, title="", group="Style", inline="VWAP", tooltip=t8) xx = input.int(2, minval=1, title="", group="Style", inline="VWAP", tooltip=t9) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Global Variable { b = bar_index //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ PIVOTS Variables { var ph = float(na) var pl = float(na) var phL = b var plL = b var lab = label(na) var prev = float(na) ph := ta.highestbars(high, prd) == 0 ? high : ph pl := ta.lowestbars(low, prd) == 0 ? low : pl phL := ta.highestbars(high, prd) == 0 ? b : phL plL := ta.lowestbars(low, prd) == 0 ? b : plL dir = phL > plL ? 1 : -1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Adaptation { atrLen = 50 atr = ta.atr(atrLen) atrAvg = ta.rma(atr, atrLen) ratio = atrAvg > 0 ? atr / atrAvg : 1.0 aptRaw = useAdapt ? baseAPT / math.pow(ratio, volBias) : baseAPT aptClamped = math.max(5.0, math.min(300.0, aptRaw)) aptSeries = math.round(aptClamped) // alpha from APT (half-life -> EWMA alpha) alphaFromAPT(apt) => decay = math.exp(-math.log(2.0) / math.max(1.0, apt)) 1.0 - decay //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ VWAP Variables { var p = hlc3 * volume var vol = volume type dataPoints array<chart.point> points polyline poly = na var vwap = dataPoints.new(array.new<chart.point>()) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Main { if dir != dir[1] x = dir > 0 ? plL : phL y = dir > 0 ? pl : ph loc = dir > 0 ? label.style_label_up : label.style_label_down col = dir > 0 ? highS : lowS txt = dir > 0 and pl < prev ? 'LL' : dir > 0 and pl > prev ? 'HL' : dir < 0 and ph < prev ? 'LH' : dir < 0 and ph > prev ? 'HH' : '' label.new(x, y, text=txt, style=loc, color=color.new(col, 20), textcolor=color.white) prev := dir > 0 ? ph[1] : pl[1] barsback = b - x p := y * volume[barsback] vol := volume[barsback] vap = p / vol vwap.poly.delete() polyline.new(vwap.points, false, false, line_color = dir < 0 ? R : S, line_width = xx) vwap.points.clear() for i = barsback to 0 by 1 apt_i = aptSeries[i] alpha = alphaFromAPT(apt_i) pxv = hlc3[i] * volume[i] v_i = volume[i] p := (1.0 - alpha) * p + alpha * pxv vol := (1.0 - alpha) * vol + alpha * v_i vappe = vol > 0 ? p / vol : na vwap.points.push(chart.point.from_index(b - i, vappe)) vwap.poly := polyline.new(vwap.points, false, false, line_color = dir < 0 ? R : S, line_width = xx) else apt_0 = aptSeries alpha = alphaFromAPT(apt_0) pxv = hlc3 * volume v0 = volume p := (1.0 - alpha) * p + alpha * pxv vol := (1.0 - alpha) * vol + alpha * v0 vap = vol > 0 ? p / vol : na vwap.poly.delete() vwap.points.push(chart.point.from_index(b, vap)) vwap.poly := polyline.new(vwap.points, false, false, line_color = dir > 0 ? R : S, line_width = xx) //~~ }
I think the Senior in the house can optimize to function like the original.
Re: Something interesting please post here (Metatrader)
4390I have not mt4 only mt5 but this looks like the best trendline indicator everWole wrote: Thu Jul 23, 2026 9:42 pm Claude Ai did the conversion.
I think the Senior in the house can optimize to function like the original.