plot AvgExpShort = MovAvgExponential(length = emaShort, price = price, displace = displace);
plot VWAPplot = VWAP(-2.0,2.0,"DAY");
def vw=vwap;
plot diff =absvalue((close -vw)) < 0.20 within 2 bars;
#Code
# Green vwap value means it is currently above the price.
# Red vwap value means it is currently below the price.
plot vw = reference vwap();
vw.AssignValueColor(if close > vw then Color.green else if close < vw then Color.red else Color.orANGE);
#end code
close > vw - 0.20 within 2 bars;what does the -.20 mean in this script?
study("VWAP MTF",overlay=true)
TimeFrame = input('W')
start = security(tickerid, TimeFrame, time)
//------------------------------------------------
newSession = iff(change(start), 1, 0)
//------------------------------------------------
vwapsum = iff(newSession, hl2*volume, vwapsum[1]+hl2*volume)
volumesum = iff(newSession, volume, volumesum[1]+volume)
v2sum = iff(newSession, volume*hl2*hl2, v2sum[1]+volume*hl2*hl2)
myvwap = vwapsum/volumesum
dev = sqrt(max(v2sum/volumesum - myvwap*myvwap, 0))
Coloring=close>myvwap?green:red
av=myvwap
showBcol = input(false, type=bool, title="Show barcolors")
showPrevVWAP = input(false, type=bool, title="Show previous VWAP close")
prevwap = iff(newSession, myvwap[1], prevwap[1])
plot(showPrevVWAP ? prevwap : na, style=circles, color=close > prevwap ? green : red)
A=plot(av, style=circles, color=Coloring)
barcolor(showBcol?Coloring:na)
#
# Plot Previous Days VWAP
# By XeoNoX via https://usethinkscript.com/
#
input numDevDn = -2.0;
input numDevUp = 2.0;
input timeFrame = {default DAY, WEEK, MONTH};
def cap = getAggregationPeriod();
def errorInAggregation =
timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH;
assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = getYyyyMmDd();
def periodIndx;
switch (timeFrame) {
case DAY:
periodIndx = yyyyMmDd;
case WEEK:
periodIndx = Floor((daysFromDate(first(yyyyMmDd)) + getDayOfWeek(first(yyyyMmDd))) / 7);
case MONTH:
periodIndx = roundDown(yyyyMmDd / 100, 0);
}
def isPeriodRolled = compoundValue(1, periodIndx != periodIndx[1], yes);
def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;
if (isPeriodRolled) {
volumeSum = volume;
volumeVwapSum = volume * vwap;
volumeVwap2Sum = volume * Sqr(vwap);
} else {
volumeSum = compoundValue(1, volumeSum[1] + volume, volume);
volumeVwapSum = compoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
volumeVwap2Sum = compoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def price = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));
plot VWAP = price;
def UpperBand = price + numDevUp * deviation;
def LowerBand = price + numDevDn * deviation;
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;
plot PrevDayVWAP;
if showOnlyLastPeriod and !IsNaN(vwap(period = aggregationPeriod)[-1]) {
PrevDayVWAP = Double.NaN;
} else {
PrevDayVWAP = Highest(vwap(period = aggregationPeriod)[-displace], length);
}
PrevDayVWAP.SetDefaultColor(GetColor(9));
PrevDayVWAP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
//@version=3
study("VWAP/MVWAP/EMA CROSSOVER", overlay = true)
//created by @DerrickLaFlame
// Get user input
vwaplength= input(title="VWAP Length", type=integer, defval=1)
emaSource1= input(title="EMA 1 Source", type=source, defval=close)
emaLength1= input(title="EMA 1 Length", type=integer, defval=7)
emaSource2= input(title="EMA 2 Source", type=source, defval=close)
emaLength2= input(title="EMA 2 Length", type=integer, defval=25)
rsilimit= input(title="RSI Limit (RISKY)", type=integer, defval=65)
rsiminimum= input(title="RSI Minimum (WAIT FOR DIP)", type=integer, defval=51)
/// MVWAP ///
avlength = input(title="MVWAP Length", type=integer, defval=21)
av = ema(vwap,avlength)
plotav = plot(av,color= fuchsia, transp=0, title = "MVWAP")
mvwap = av
// Get values
ema1= ema(emaSource1, emaLength1)
ema2= ema(emaSource2, emaLength2)
/// VWAP ///
cvwap = ema(vwap,vwaplength)
plotvwap = plot(cvwap,color= yellow, transp=0, title = "VWAP", linewidth=3)
Check1 = ema1 >= mvwap
Check2 = ema2 >= mvwap
Check3 = cvwap >= mvwap
Cross = Check1 and Check2
Crossup = Cross and Check3
Buy = Crossup and rsi(close,14)
Risky = Crossup and rsi(close,14) > rsilimit
BuyDip = Crossup and rsi(close,14) < rsiminimum
GoodBuy = Buy and rsi(close,14) < rsilimit
GreatBuy = GoodBuy and rsi(close,14) > rsiminimum
//Test
Long = Buy == 1 ? 1 : 0
Short = Buy != 1 ? 1 : 0
Longtrigger = crossover(Long, 0.5)
Shorttrigger = crossover(Short, 0.5)
plotshape(Longtrigger, title= "Long Entry", location=location.belowbar, color=green, transp=0, style=shape.triangleup, text="Long")
plotshape(Shorttrigger, title= "Short Entry", location=location.abovebar, color=red, transp=0, style=shape.triangledown, text="Short")
// Plot signals to chart
plotshape(Buy, title= "Buy Alert", location=location.belowbar, color=white, transp=100, style=shape.triangleup, text="")
plotshape(Risky, title= "Risky", location=location.abovebar, color=red, transp=100, style=shape.triangledown, text="")
plotshape(BuyDip, title= "WAIT", location=location.abovebar, color=orange, transp=100, style=shape.triangledown, text="")
plotshape(GreatBuy, title= "Enter Here", location=location.belowbar, color=green, transp=100, style=shape.triangleup, text="")
plot(ema(emaSource1, emaLength1), color=yellow, linewidth=1, transp=0, title='EMA1')
plot(ema(emaSource2, emaLength2), color=orange, linewidth=1, transp=0, title='EMA2')
// Alerts
alertcondition(Longtrigger, title="Long Alert", message="Long Alert")
alertcondition(Shorttrigger, title="Short Alert", message="Short Alert")
//Barcolor
barcolor(Long == 1 ? green : red, title = "Bar Color")
// Cloud
displacement_A = 26
displacement_B = 26
conversion_len = 9
base_line_len = 26
senkou_B_len = 51
f(x) =>
total_volume = sum(volume, x)
volume_weighted_high = sum(high*volume, x)/total_volume
volume_weighted_low = sum(low*volume, x)/total_volume
(volume_weighted_high + volume_weighted_low)/2
conversion_line = f(conversion_len)
base_line = f(base_line_len)
senkou_A = (conversion_line + base_line)/2
senkou_B = f(senkou_B_len)
p1 = plot(senkou_A, offset = displacement_A, color = green, title = "Senkou A", linewidth = 2, transp = 100)
p2 = plot(senkou_B, offset = displacement_B, color = red, title = "Senkou B", linewidth = 2, transp = 100)
fill(p1, p2 , color = senkou_A > senkou_B ? green : red, transp= 73)
**/
# Alerts
#
# TD Ameritrade IP Company, Inc. (c) 2011-2020
#
input numDevDn = -2.0;
input numDevUp = 2.0;
input timeFrame = {default DAY, WEEK, MONTH};
def cap = getAggregationPeriod();
def errorInAggregation =
timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH;
assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = getYyyyMmDd();
def periodIndx;
switch (timeFrame) {
case DAY:
periodIndx = yyyyMmDd;
case WEEK:
periodIndx = Floor((daysFromDate(first(yyyyMmDd)) + getDayOfWeek(first(yyyyMmDd))) / 7);
case MONTH:
periodIndx = roundDown(yyyyMmDd / 100, 0);
}
def isPeriodRolled = compoundValue(1, periodIndx != periodIndx[1], yes);
def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;
if (isPeriodRolled) {
volumeSum = volume;
volumeVwapSum = volume * vwap;
volumeVwap2Sum = volume * Sqr(vwap);
} else {
volumeSum = compoundValue(1, volumeSum[1] + volume, volume);
volumeVwapSum = compoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
volumeVwap2Sum = compoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def price = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));
plot VWAPx = price;
plot UpperBand = price + numDevUp * deviation;
plot LowerBand = price + numDevDn * deviation;
VWAPx.setDefaultColor(getColor(0));
UpperBand.setDefaultColor(getColor(2));
LowerBand.setDefaultColor(getColor(4));
#instead of cross we use the low the then candle is below vwap and the high of the candle is above vwap
#this is better method of scanning for a crossing
def vwap_cross = low < vwapx and high > vwapx;
Alert(vwap_cross, " ", Alert.BAR, Sound.Chimes);
def vwap_cross = low < LowerBandand and high > LowerBand;
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
RSI (or MACD) with VWAP & MA & div for ThinkOrSwim | Indicators | 11 | ||
J | High/Low Anchored VWAP For ThinkOrSwim | Indicators | 16 | |
Opening Range Indicator with Measured Moves and VWAP For ThinkOrSwim | Indicators | 43 | ||
RSI-VWAP Indicator for ThinkorSwim | Indicators | 68 | ||
Squeeze Clouds based on SMA and VWAP | Indicators | 7 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.