OPEN-SOURCE SCRIPT
Worldclassedge [Patrick nill]

plotshape(long, title="BUY", text="Long▲", style=shape.labelup, textcolor=color.white, size=size.auto, location=location.belowbar, color=color.green)
plotshape(short, title="SELL", text="Short▼", style=shape.labeldown, textcolor=color.white, size=size.auto, location=location.abovebar, color=color.red)
alertcondition(long, title="BUY", message="Long▲")
alertcondition(short, title="SELL", message="Short▼")
// VWAP
anchor = input.string("Session", title="Anchor Period")
MILLIS_IN_DAY = 86400000
dwmBarTime = timeframe.isdwm ? time : request.security(syminfo.tickerid, "D", time)
dwmBarTime := na(dwmBarTime) ? nz(dwmBarTime[1]) : dwmBarTime
var periodStart = time - time
makeMondayZero(dayOfWeek) => (dayOfWeek + 5) % 7
isMidnight(t) => hour(t) == 0 and minute(t) == 0
isSameDay(t1, t2) => dayofmonth(t1) == dayofmonth(t2) and month(t1) == month(t2) and year(t1) == year(t2)
isOvernight() => not (isMidnight(dwmBarTime) or request.security(syminfo.tickerid, "D", isSameDay(time, time_close), lookahead=barmerge.lookahead_on))
tradingDayStart(t) => timestamp(year(t), month(t), dayofmonth(t), 0, 0)
numDaysBetween(t1, t2) =>
diff = math.abs(tradingDayStart(t1) - tradingDayStart(t2))
diff / MILLIS_IN_DAY
tradingDay = isOvernight() ? tradingDayStart(dwmBarTime + MILLIS_IN_DAY) : tradingDayStart(dwmBarTime)
isNewPeriod() =>
var isNew = false
if tradingDay != nz(tradingDay[1])
isNew := switch anchor
"Session" => na(tradingDay[1]) or tradingDay > tradingDay[1]
"Week" => makeMondayZero(dayofweek(periodStart)) + numDaysBetween(periodStart, tradingDay) >= 7
"Month" => month(periodStart) != month(tradingDay) or year(periodStart) != year(tradingDay)
"Year" => year(periodStart) != year(tradingDay)
=> false
isNew
srcVWAP = hlc3
var float sumSrc = 0
var float sumVol = 0
if isNewPeriod()
periodStart := tradingDay
sumSrc := 0
sumVol := 0
if not na(srcVWAP) and not na(volume)
sumSrc += srcVWAP * volume
sumVol += volume
vwapValue = sumSrc / sumVol
plot(vwapValue, title="VWAP", color=color.red, linewidth=3)
// =
enableCloud = input.bool(false, "Enable Cloud")
lenn = input.int(20, "Period")
mult = input.float(2.5, "StdDev Multiplier")
tc = input.int(25, "Gauge Size", minval=3)
upColor = input.color(#00ffbb, "Up Color")
downColor = input.color(#ff1100, "Down Color")
basis = ta.sma(close, lenn)
upper1 = basis + ta.stdev(close, lenn) * mult
lower1 = basis - ta.stdev(close, lenn) * mult
// TP
var int position = 0
if long
position := 1
else if short
position := -1
plotshape(short, title="SELL", text="Short▼", style=shape.labeldown, textcolor=color.white, size=size.auto, location=location.abovebar, color=color.red)
alertcondition(long, title="BUY", message="Long▲")
alertcondition(short, title="SELL", message="Short▼")
// VWAP
anchor = input.string("Session", title="Anchor Period")
MILLIS_IN_DAY = 86400000
dwmBarTime = timeframe.isdwm ? time : request.security(syminfo.tickerid, "D", time)
dwmBarTime := na(dwmBarTime) ? nz(dwmBarTime[1]) : dwmBarTime
var periodStart = time - time
makeMondayZero(dayOfWeek) => (dayOfWeek + 5) % 7
isMidnight(t) => hour(t) == 0 and minute(t) == 0
isSameDay(t1, t2) => dayofmonth(t1) == dayofmonth(t2) and month(t1) == month(t2) and year(t1) == year(t2)
isOvernight() => not (isMidnight(dwmBarTime) or request.security(syminfo.tickerid, "D", isSameDay(time, time_close), lookahead=barmerge.lookahead_on))
tradingDayStart(t) => timestamp(year(t), month(t), dayofmonth(t), 0, 0)
numDaysBetween(t1, t2) =>
diff = math.abs(tradingDayStart(t1) - tradingDayStart(t2))
diff / MILLIS_IN_DAY
tradingDay = isOvernight() ? tradingDayStart(dwmBarTime + MILLIS_IN_DAY) : tradingDayStart(dwmBarTime)
isNewPeriod() =>
var isNew = false
if tradingDay != nz(tradingDay[1])
isNew := switch anchor
"Session" => na(tradingDay[1]) or tradingDay > tradingDay[1]
"Week" => makeMondayZero(dayofweek(periodStart)) + numDaysBetween(periodStart, tradingDay) >= 7
"Month" => month(periodStart) != month(tradingDay) or year(periodStart) != year(tradingDay)
"Year" => year(periodStart) != year(tradingDay)
=> false
isNew
srcVWAP = hlc3
var float sumSrc = 0
var float sumVol = 0
if isNewPeriod()
periodStart := tradingDay
sumSrc := 0
sumVol := 0
if not na(srcVWAP) and not na(volume)
sumSrc += srcVWAP * volume
sumVol += volume
vwapValue = sumSrc / sumVol
plot(vwapValue, title="VWAP", color=color.red, linewidth=3)
// =
enableCloud = input.bool(false, "Enable Cloud")
lenn = input.int(20, "Period")
mult = input.float(2.5, "StdDev Multiplier")
tc = input.int(25, "Gauge Size", minval=3)
upColor = input.color(#00ffbb, "Up Color")
downColor = input.color(#ff1100, "Down Color")
basis = ta.sma(close, lenn)
upper1 = basis + ta.stdev(close, lenn) * mult
lower1 = basis - ta.stdev(close, lenn) * mult
// TP
var int position = 0
if long
position := 1
else if short
position := -1
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.