TWap
Forums › ProRealTime English forum › ProBuilder support › TWap
- This topic has 3 replies, 2 voices, and was last updated 4 years ago by Dr Manhattan.
Viewing 4 posts - 1 through 4 (of 4 total)
-
-
07/08/2020 at 3:22 PM #13875612345678910111213141516171819202122//@version=4study("TWAP Trend", "TWAP", true)smoothing = input(14)resolution = input("0", "Timeframe") //240 Dsrc = input(ohlc4)res = resolution != "0" ? resolution : timeframe.periodweight = barssince(change(security(syminfo.tickerid, res, time, lookahead=barmerge.lookahead_on)))price = 0.price:= weight == 0 ? src : src + nz(price[1])twap = price / (weight + 1)ma = smoothing < 2 ? twap : sma(twap, smoothing)bullish = iff(smoothing < 2, src >= ma, src > ma)disposition = bullish ? color.lime : color.redbasis = plot(src, "OHLC4", disposition, linewidth=1, transp=100)work = plot(ma, "TWAP", disposition, linewidth=2, transp=20)fill(basis, work, disposition, transp=65)showcross = input(false, title="Show Buy/Sell")crossup = ma[1] < src[1] and ma > srccrossdn = ma[1] > src[1] and ma < srcplotshape(showcross and crossup and not crossup[1] ? src : na, location=location.absolute, style=shape.labeldown, color=color.red, size=size.tiny, text="Sell", textcolor=#ffffff, transp=0, offset=-1)plotshape(showcross and crossdn and not crossdn[1] ? src : na, location=location.absolute, style=shape.labelup, color=color.lime, size=size.tiny, text="Buy", textcolor=#ffffff, transp=0, offset=-1)
In finance, time-weighted average price (TWAP) is the average price of a security over a specified time. Below are some contrasting differences between TWAP and VWAP:-
- TWAP is weighted based on time, VWAP is weighted based on time and volume.
- Small volume trades do not impact TWAP but it does impact VWAP
- TWAP calculation is fairly simple while VWAP calculation is complex
- VWAP trade will buy or sell 40% of a trade in the first half of the day and then the other 60% in the second half of the day. A TWAP trade would most likely execute an even 50/50 volume in the first and second half of the day.
07/10/2020 at 7:13 PM #138981I made a coding request for this one. I didnt know it would end up as a forum post, but this is a coding request. I wasnt sure how to convert this from pine script to pro real code.
07/13/2020 at 9:01 AM #13911507/16/2020 at 1:00 AM #139388Below is a screenshot! I can work on the current timeframe. I use it personally on a 30 min. It doesnt matter so much the settings, it just to cut it in a nice way and then use the risk control.
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)