Hi,
I am trying to find VWAP at a specific time of the day. Say for example, how to find the VWAP after 30 minutes of opening? I am wondering if this is possible and if so would someone post the code.
Thanks in advance,
Kundurs
# VWAP_At_Time
# Created by rad14733 for usethinkscript.com per @kundurs request
# v1.0 : 2021-07-23 : Initial Release
def vwapTime = 1000;
def vwapVal = if SecondsFromTime(vwapTime) == 0 then vwap(period = AggregationPeriod.THIRTY_MIN) else if SecondsFromTime(vwapTime) > 0 then vwapVal[1] else 0;
AddLabel(yes, "10:00 vwap = " + vwapVal, Color.WHITE);
# END - VWAP_At_Time
# VWAP_At_Time
# Created by rad14733 for usethinkscript.com per @kundurs request
# v1.0 : 2021-07-23 : Initial Release
def vwapTime = 1000;
def vwapVal = if SecondsFromTime(vwapTime) == 0 then vwap() else if SecondsFromTime(vwapTime) > 0 then vwapVal[1] else Double.NaN;
AddLabel(yes, "10:00 vwap = " + vwapVal, Color.WHITE);
Trying to set up your watchlist, but it does not appear as a watchlist item that I can add, and when I enter it manually as a custom watchlist item, TOS won't let me click save. How can I put your watchlist in action?@PapaBear10 Your code had several syntax errors. Here is my version of a VWAP Watchlist that is painted green when 9 ema crosses above vwap within last 3 bars. It is painted red when 9 ema crosses below vwap within last 3 bars. Remember to select the aggregation period you are interested in when configuring this watchlist
Code:# VWAP Watchlist # tomsk # 1.25.2020 # Watchlist that is painted green when 9 ema crosses above vwap within last 3 bars # It is painted red when 9 ema crosses below vwap within last 3 bars input length = 9; def ema = ExpAverage(close, length); def vwapValue = reference VWAP(); def crossUp = ema crosses above vwapValue within 3 bars; def crossDn = ema crosses below vwapValue within 3 bars; AddLabel(1, if crossUp then "X Up" else if crossDn then "X Down" else " ", Color.Black); AssignBackgroundColor(if ema crosses above vwapValue then Color.GREEN else if ema crosses below vwapValue then Color.RED else Color.Gray); # End VWAP Watchlist
Hi all,
I searched and couldn’t find something, sorry if I missed it (please post link if I did miss it).
I’m looking to add both 9 and 21 EMA crossover VWAP.
So basically 4 indicators on 1 min chart;
- 9 EMA crossover VWAP on 5 min
- 9 EMA crossover VWAP on 15 min
- 21 EMA crossover VWAP on 5 min
- 21 EMA crossover VWAP on 15 min
is that possible?
thanks in advance
Ruby:input showlabels = yes; input showplots = yes; input agg1 = AggregationPeriod.FIVE_MIN; input agg2 = AggregationPeriod.FIFTEEN_MIN; input len1 = 9; input len2 = 21; plot vwap = reference VWAP(); plot ema1 = ExpAverage(close(period = agg1), len1); plot ema2 = ExpAverage(close(period = agg2), len1); plot ema3 = ExpAverage(close(period = agg1), len2); plot ema4 = ExpAverage(close(period = agg2), len2); ema1.SetHiding(!showplots); ema2.SetHiding(!showplots); ema3.SetHiding(!showplots); ema4.SetHiding(!showplots); ema1.AssignValueColor(if ema1 > vwap then Color.GREEN else Color.RED); ema2.AssignValueColor(if ema2 > vwap then Color.GREEN else Color.RED); ema3.AssignValueColor(if ema3 > vwap then Color.GREEN else Color.RED); ema4.AssignValueColor(if ema4 > vwap then Color.GREEN else Color.RED); AddLabel(showlabels, "EMA9 " + agg1 / 60000 + "m", if ema1 > vwap then Color.GREEN else Color.RED); AddLabel(showlabels, "EMA21 " + agg1 / 60000 + "m", if ema3 > vwap then Color.GREEN else Color.RED); AddLabel(showlabels, "EMA9 " + agg2 / 60000 + "m", if ema2 > vwap then Color.GREEN else Color.RED); AddLabel(showlabels, "EMA21 " + agg2 / 60000 + "m", if ema4 > vwap then Color.GREEN else Color.RED);
Another Way To Load Watch Lists
Shared Link: http://tos.mx/8PcaOer
Click here for --> Easiest way to load shared links
@Batman[/UF
[/QUOTE]
First time caller long time listener.... I appreciate what all you guys do here. I was looking around for this but haven't found exactly what i wanted. Basically what i want is to add to my watchlist something like the above photo but I want it to ... show price close is above or equal to VWAP and above the 200SMA (when it is i want it to paint green) and also to show price close is below VWAP and VWAP is below 200SMA (when this happens paint Red) (if none of the above black)Another Way To Load Watch Lists
Shared Link: http://tos.mx/8PcaOer
Click here for --> Easiest way to load shared links
@Batman
First time caller long time listener.... I appreciate what all you guys do here. I was looking around for this but haven't found exactly what i wanted. Basically what i want is to add to my watchlist something like the above photo but I want it to ... show price close is above or equal to VWAP and above the 200SMA (when it is i want it to paint green) and also to show price close is below VWAP and VWAP is below 200SMA (when this happens paint Red) (if none of the above black)
I'm not very good at these scripts and the below is what i was trying to do but it's not correct. Any help greatly appreciated.
def VWAP = close crosses above reference VWAP ()."VWAP";
def SMA200 = close is greater than or equal to SimpleMovingAvg()."SMA" from 200 bars ago;
def BullStack = close is greater than VWAP and VWAP is greater than or equal to SMA200;
def BearStack = close is less than VWAP and VWAP is less than or equal to SMA200;
AddLabel(BullStack, “Bull”, color.green);
AddLabel(BearStack, “Bear”, color.red);
AddLabel(!BullStack and !BearStack, "Do Nothing", color.BLACK);
# hello, i see a couple of things you can try changing. the main problem is that you are comparing numbers to boolean values( true/false).
# vwap and sma200 are true/ false values. in your bull and bear formulas, you comparing them as if they are numbers.
# try to use unique variable names. change vwap. use a variable to hold the wvap value.
def vwap1 = reference VWAP()."VWAP";
# this isn't used
#def VWAPxup = close crosses above reference VWAP()."VWAP";
# if you want a 200 period average, put the number between the ( ).
# what you are referencing is a study. there are also functions that you can use, to get average values.
# it is ok to combine functions in a long formula, but sometimes it is easier to fix if you separate things out into several formulas.
# i would define a variable to hold the vwap and average values, then use a 2nd variable to compare it to something.
def SMA200 = SimpleMovingAvg( length = 200 )."SMA";
# this isn't neeed
#def abovesma = (close >= sma200);
def BullStack = close > VWAP1 and VWAP1 >= SMA200;
def BearStack = close < VWAP1 and VWAP1 <= SMA200;
AddLabel(BullStack, “Bull”, color.green);
AddLabel(BearStack, “Bear”, color.red);
AddLabel(!BullStack and !BearStack, "Do Nothing", color.BLACK);
# combined label
AddLabel( BullStack or bearstack,
(if BullStack then "Bull" else if bearstack then "Bear" else "----"),
(if BullStack then color.green
else if bearstack then color.red else color.black) );
# there are only 2 conditions that trigger the label. so if it is not a bull or bear, no label will appear.
# because i used 2 definite conditions , i had to finish with a 3rd to complete the if-thens. ( ---- and black)
def calc_vwap = (close-vwap())/close*100;
plot vwap = round(calc_vwap,1);
AssignBackgroundColor(if vwap > 0 then Color.GREEN else if vwap < 0 then Color.RED else Color.BLACK);
In dark mode the default font is white, can you help change that to black? Thanks!@geebeeaye Added round function and by default the font is black:
View attachment 866Ruby:def calc_vwap = (close-vwap())/close*100; plot vwap = round(calc_vwap,1); AssignBackgroundColor(if vwap > 0 then Color.GREEN else if vwap < 0 then Color.RED else Color.BLACK);
def calc_vwap = (close-vwap())/close*100;
def vwap = round(calc_vwap,1);
AddLabel(yes, vwap, color.black);
AssignBackgroundColor(if vwap > 0 then Color.GREEN else if vwap < 0 then Color.RED else Color.BLACK);
I've been trying to figure out how to code this for intraday but am having a very difficult time doing so. All the scripts I've found never worked for intraday (1m/5m) charts.
I would use this one but it doesn't seem to work for intraday
plot vwap = vwap();
AssignBackgroundColor(if close > vwap then Color.DARK_GREEN else if close < vwap then Color.DARK_RED else Color.Dark_ORANGE);
It shows colors and for some tickers it is accurate but many of them aren't so I'm guessing it's deriving the VWAP from a different time frame. I'm trying to show in the Watchlist whether a ticker is above or below the VWAP at the current price, possibly within 5 bars on the 1 minute time frame?
I'm also trying to figure out how to show when a ticker is above or below the zero line on the RSMK, again intraday and on the Watchlist. I've found a code that would compare the stock to multiple tickers like SPY/QQQ/VOO but I'm just trying to compare it to SPY.
Is there anyone that has a code for that or can possibly figure it out?
plot v = reference vwap();
v.assignValueColor(if close > v then Color.DARK_GREEN else if close < v then Color.DARK_RED else Color.Dark_ORANGE);
v.setlineWeight(5);
#assignbackgroundColor(if close > v then Color.DARK_GREEN else if close < v then Color.DARK_RED else Color.Dark_ORANGE);
Ruby:def r = if IsNaN(reference RSMK()) then r[1] else reference RSMK(); plot rsmk = r; rsmk.AssignValueColor(if r >= 0 then Color.GREEN else Color.RED); rsmk.SetLineWeight(5); #assignbackgroundColor(if r>=0 then color.green else color.red);
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.