//version=4
study(title="AIO MAs", shorttitle="AIO MAs", overlay=true, resolution="", resolution_gaps=true)
computeVWAP(src, isNewPeriod, stDevMultiplier) =>
var float sumSrcVol = na
var float sumVol = na
var float sumSrcSrcVol = na
sumSrcVol := isNewPeriod ? src * volume : src * volume + sumSrcVol[1]
sumVol := isNewPeriod ? volume : volume + sumVol[1]
// sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation
sumSrcSrcVol := isNewPeriod ? volume * pow(src, 2) : volume * pow(src, 2) + sumSrcSrcVol[1]
_vwap = sumSrcVol / sumVol
variance = sumSrcSrcVol / sumVol - pow(_vwap, 2)
variance := variance < 0 ? 0 : variance
stDev = sqrt(variance)
lowerBand = _vwap - stDev * stDevMultiplier
upperBand = _vwap + stDev * stDevMultiplier
[_vwap, lowerBand, upperBand]
hideonDWM = input(true, title="Hide VWAP on 1D or Above", group="VWAP Settings")
var anchor = input(defval = "Session", title="Anchor Period", type=input.string,
options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group="VWAP Settings")
src = input(title = "Source", type = input.source, defval = hlc3, group="VWAP Settings")
offset = input(0, title="Offset", group="VWAP Settings")
// showBands = input(false, title="Calculate Bands", group="Standard Deviation Bands Settings")
// stdevMult = input(1.0, title="Bands Multiplier", group="Standard Deviation Bands Settings")
stdevMult = 1.0
timeChange(period) =>
change(time(period))
new_earnings = earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on)
new_dividends = dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on)
new_split = splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on)
isNewPeriod = anchor == "Earnings" ? new_earnings :
anchor == "Dividends" ? new_dividends :
anchor == "Splits" ? new_split :
na(src[1]) ? true :
anchor == "Session" ? timeChange("D") :
anchor == "Week" ? timeChange("W") :
anchor == "Month" ? timeChange("M") :
anchor == "Quarter" ? timeChange("3M") :
anchor == "Year" ? timeChange("12M") :
anchor == "Decade" ? timeChange("12M") and year % 10 == 0 :
anchor == "Century" ? timeChange("12M") and year % 100 == 0 :
false
float vwapValue = na
float std = na
float upperBandValue = na
float lowerBandValue = na
if not (hideonDWM and timeframe.isdwm)
[_vwap, bottom, top] = computeVWAP(src, isNewPeriod, stdevMult)
vwapValue := _vwap
// upperBandValue := showBands ? top : na
// lowerBandValue := showBands ? bottom : na
plot(vwapValue, title="VWAP", color=#2962FF, offset=offset)
type = input(defval = "EMA", title = "Type", options = ["EMA", "SMA"])
len1=input(8, title ="MA 1")
len2=input(13, title ="MA 2")
len3=input(21, title = "MA 3")
len4=input(55, title = "MA 4")
len5=input(89, title = "MA 5")
len6=input(144, title = "MA 6")
len7=input(233, title = "MA 7")
onOff1 = input(defval=true, title="Enable 1")
onOff2 = input(defval=true, title="Enable 2")
onOff3 = input(defval=true, title="Enable 3")
onOff4 = input(defval=true, title="Enable 4")
onOff5 = input(defval=true, title="Enable 5")
onOff6 = input(defval=true, title="Enable 6")
onOff7 = input(defval=true, title="Enable 7")
atrPeriod = input(5, "ATR Length")
factor = input(2, "Factor")
[supertrend, direction] = supertrend(factor, atrPeriod)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)
ma1 = type == "EMA" ? ema(close, len1) : sma(close, len1)
ma2 = type == "EMA" ? ema(close, len2) : sma(close, len2)
ma3 = type == "EMA" ? ema(close, len3) : sma(close, len3)
ma4 = type == "EMA" ? ema(close, len4) : sma(close, len4)
ma5 = type == "EMA" ? ema(close, len5) : sma(close, len5)
ma6 = type == "EMA" ? ema(close, len6) : sma(close, len6)
ma7 = type == "EMA" ? ema(close, len7) : sma(close, len7)
c1=#FFE9AF
c2=#F7F7F0
c3=#BAF1BE
c4=#FFBFBF
c5=#4E67EB
c6 = #EB6E3D
c7 = #4C5175
col1 = c1
col2 = c2
col3 = c3
col4 = c4
col5 = c5
col6 = c6
col7 = c7
p1 = plot(onOff1 ? ma1 : na, title = "MA 1", color = col1, linewidth = 1, style = plot.style_linebr)
p2 = plot(onOff2 ? ma2 : na, title = "MA 2", color = col2, linewidth = 1, style = plot.style_linebr)
p3 = plot(onOff3 ? ma3 : na, title = "MA 3", color = col3, linewidth = 1, style = plot.style_linebr)
p4 = plot(onOff4 ? ma4 : na, title = "MA 4", color = col4, linewidth = 1, style = plot.style_linebr)
p5 = plot(onOff5 ? ma5 : na, title = "MA 5", color = col5, linewidth = 1, style = plot.style_linebr)
p6 = plot(onOff6 ? ma6 : na, title = "MA 6", color = col6, linewidth = 1, style = plot.style_linebr)
p7 = plot(onOff6 ? ma7 : na, title = "MA 7", color = col7, linewidth = 1, style = plot.style_linebr)
study(title="AIO MAs", shorttitle="AIO MAs", overlay=true, resolution="", resolution_gaps=true)
computeVWAP(src, isNewPeriod, stDevMultiplier) =>
var float sumSrcVol = na
var float sumVol = na
var float sumSrcSrcVol = na
sumSrcVol := isNewPeriod ? src * volume : src * volume + sumSrcVol[1]
sumVol := isNewPeriod ? volume : volume + sumVol[1]
// sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation
sumSrcSrcVol := isNewPeriod ? volume * pow(src, 2) : volume * pow(src, 2) + sumSrcSrcVol[1]
_vwap = sumSrcVol / sumVol
variance = sumSrcSrcVol / sumVol - pow(_vwap, 2)
variance := variance < 0 ? 0 : variance
stDev = sqrt(variance)
lowerBand = _vwap - stDev * stDevMultiplier
upperBand = _vwap + stDev * stDevMultiplier
[_vwap, lowerBand, upperBand]
hideonDWM = input(true, title="Hide VWAP on 1D or Above", group="VWAP Settings")
var anchor = input(defval = "Session", title="Anchor Period", type=input.string,
options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group="VWAP Settings")
src = input(title = "Source", type = input.source, defval = hlc3, group="VWAP Settings")
offset = input(0, title="Offset", group="VWAP Settings")
// showBands = input(false, title="Calculate Bands", group="Standard Deviation Bands Settings")
// stdevMult = input(1.0, title="Bands Multiplier", group="Standard Deviation Bands Settings")
stdevMult = 1.0
timeChange(period) =>
change(time(period))
new_earnings = earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on)
new_dividends = dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on)
new_split = splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on)
isNewPeriod = anchor == "Earnings" ? new_earnings :
anchor == "Dividends" ? new_dividends :
anchor == "Splits" ? new_split :
na(src[1]) ? true :
anchor == "Session" ? timeChange("D") :
anchor == "Week" ? timeChange("W") :
anchor == "Month" ? timeChange("M") :
anchor == "Quarter" ? timeChange("3M") :
anchor == "Year" ? timeChange("12M") :
anchor == "Decade" ? timeChange("12M") and year % 10 == 0 :
anchor == "Century" ? timeChange("12M") and year % 100 == 0 :
false
float vwapValue = na
float std = na
float upperBandValue = na
float lowerBandValue = na
if not (hideonDWM and timeframe.isdwm)
[_vwap, bottom, top] = computeVWAP(src, isNewPeriod, stdevMult)
vwapValue := _vwap
// upperBandValue := showBands ? top : na
// lowerBandValue := showBands ? bottom : na
plot(vwapValue, title="VWAP", color=#2962FF, offset=offset)
type = input(defval = "EMA", title = "Type", options = ["EMA", "SMA"])
len1=input(8, title ="MA 1")
len2=input(13, title ="MA 2")
len3=input(21, title = "MA 3")
len4=input(55, title = "MA 4")
len5=input(89, title = "MA 5")
len6=input(144, title = "MA 6")
len7=input(233, title = "MA 7")
onOff1 = input(defval=true, title="Enable 1")
onOff2 = input(defval=true, title="Enable 2")
onOff3 = input(defval=true, title="Enable 3")
onOff4 = input(defval=true, title="Enable 4")
onOff5 = input(defval=true, title="Enable 5")
onOff6 = input(defval=true, title="Enable 6")
onOff7 = input(defval=true, title="Enable 7")
atrPeriod = input(5, "ATR Length")
factor = input(2, "Factor")
[supertrend, direction] = supertrend(factor, atrPeriod)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)
ma1 = type == "EMA" ? ema(close, len1) : sma(close, len1)
ma2 = type == "EMA" ? ema(close, len2) : sma(close, len2)
ma3 = type == "EMA" ? ema(close, len3) : sma(close, len3)
ma4 = type == "EMA" ? ema(close, len4) : sma(close, len4)
ma5 = type == "EMA" ? ema(close, len5) : sma(close, len5)
ma6 = type == "EMA" ? ema(close, len6) : sma(close, len6)
ma7 = type == "EMA" ? ema(close, len7) : sma(close, len7)
c1=#FFE9AF
c2=#F7F7F0
c3=#BAF1BE
c4=#FFBFBF
c5=#4E67EB
c6 = #EB6E3D
c7 = #4C5175
col1 = c1
col2 = c2
col3 = c3
col4 = c4
col5 = c5
col6 = c6
col7 = c7
p1 = plot(onOff1 ? ma1 : na, title = "MA 1", color = col1, linewidth = 1, style = plot.style_linebr)
p2 = plot(onOff2 ? ma2 : na, title = "MA 2", color = col2, linewidth = 1, style = plot.style_linebr)
p3 = plot(onOff3 ? ma3 : na, title = "MA 3", color = col3, linewidth = 1, style = plot.style_linebr)
p4 = plot(onOff4 ? ma4 : na, title = "MA 4", color = col4, linewidth = 1, style = plot.style_linebr)
p5 = plot(onOff5 ? ma5 : na, title = "MA 5", color = col5, linewidth = 1, style = plot.style_linebr)
p6 = plot(onOff6 ? ma6 : na, title = "MA 6", color = col6, linewidth = 1, style = plot.style_linebr)
p7 = plot(onOff6 ? ma7 : na, title = "MA 7", color = col7, linewidth = 1, style = plot.style_linebr)
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.