VWAP difference between ToS and TradingSim

Z

ztrader

New member
Hello all,

I use tradingsim and thinkorswim for my strategy backtesting. I use the VWAP indicator for one of my strategies, however the VWAP plot is different on these two platforms.

I think the reason is if the VWAP on thinkonswim uses the HIGH price and VWAP on tradingism uses the Open price for its parameters. I have attached a photo from the two platforms that illustrates this perfectly. Any clarification for the difference?

Any opinions on how to fix this so they are showing the same VWAP?



 
Last edited:
Z

ztrader

New member
I can¨t change the paramters on tradingsim. I guess its possible to do so on TOS with some coding, but unable to find out.
 
C

codydog

Active member
imo, there's no one best way to calculate vwap, heres an example for tos.

Code:
# VWAPALOOZA
# By Prospectus @ http://readtheprospectus.worspress.com
#
# This Thinkscript calculates four different types of VWAP:
# OneDay (standard type), Rolling (N bar lookback), Bar
# Incremental (discrete N bar periods) and Volume Incremental
# (discrete N-shares-traded periods).
#
declare upper;
#
# Check if we are on the current day:
#
def istoday = if getDay() == getLastDay() then 1 else 0;
#
# Input Rolling / Incremental period, VWAP type, and
# Averaging method ( (H+L)/2 or Close):
#
input Period = 20;
def n = Period;
input VolIncrement=20000;
def v=VolIncrement;
input VWAPType = {Rolling, BarIncremental, VolIncremental, default OneDay};
def type;
switch (VWAPType){
case Rolling:
type = 1;
case BarIncremental:
type = 0;
case OneDay:
type = 2;
case VolIncremental:
type=3;
}
input AverageMethod = {CLOSE, default H_L};
def num;
switch (AverageMethod){
case CLOSE:
num = close;
case H_L:
num = (high + low) / 2;
}
#
# Define volume for today only (other days zero):
#
def todayvol = if istoday then volume else 0;
#
# Calculate the P*V term for VWAP:
#
def pv = num * todayvol;
#
# Code for BarIncremental counter:
#
rec k = if k[1] == n then 1 else k[1] + 1;
#
# Code for VolIncremental volume sum:
#
rec volsum=if volsum[1]>v then volume else volsum[1]+volume;
#
# Code for VolIncremental price*volume:
#
rec pvsum =if volsum[1]>v then num*volume else pvsum[1] + num*volume;
#
# Now define the VolIncremental to display:
#
rec volinc=if volsum[1]==0 then num else if volsum[1]>v then pvsum[1]/volsum[1] else volinc[1];
#
# Now the final VWAP calculations:
#
rec calcVWAP = if type == 2 then TotalSum(pv) / TotalSum(todayvol) else if type == 1 then sum(num*volume, n) / sum(volume, n) else if type==3 then volinc else if type==0 and k == n then sum(num*volume, n) / sum(volume, n) else calcvwap[1];
#
# Define the plot:
#
plot VWAPALOOZA = calcvwap;
#
# Formatting:
#
VWAPALOOZA.setdefaultcolor(color.white);
VWAPALOOZA.setstyle(curve.long_dash);
VWAPALOOZA.setlineweight(3);
 
murkr

murkr

Member
VIP
Why is my TOS VWAP different than my IB VWAP? Here are my TOS and interactive brokers VWAP next to each other.

Why are they different?



(VWAP is yellow)
 
Last edited by a moderator:
T

tradebyday

Active member
For those experiencing differences in VWAPs between platforms there are 3 reasons that can cause discrepancies: 1) The base formula driving the code is different (would be kind of rare for something as widely universal as VWAP, but not possible to rule out until you dive into their codes and know how the platform interprets them)... 2) The time at which your platform starts collecting data is different. I have used platforms that start new days directly at midnight on futures despite the "new day" for futures begins at 6pm EST on the previous day. An other example is whether your platform or indicator is considering only regular hours or extended hours in the VWAP calculation (whether you have pre-market hours shown on your chart or not)... 3) The actual data being collected is different. This would occur mainly in FX since there is no centralized market for volume and bid/ask prices beyond what your data provider receives in the way of orders, so they would naturally follow different data sets among different platforms. But it could occur in other markets on occasion as well caused by simple orderbook errors....

All of these possible problems makes backtesting and forwardtesting rather inconsistent, which can be frustrating when you think you have figured out a killer strategy but can't duplicate it on your other platform. Now for the possible solutions.... 1) Just use one platform for all of your charting. Pretty simple concept but if you're a tinker it is hard to do because you like to play with new set ups, new indicators, and of course, new platforms. This does not mean only TRADE on one platform, I recommend trading on multiple platforms to keep the account spread out, but just one platform telling you when to execute trades provides simplicity, stability, and consistency... 2) For all of my tinkers out there, develop a strategy for EACH platform. This is actually a concept I really like, as some platforms have some very special indicators or tools that others do not. For example TOS does not have bid/ask candles but someone else does. I could develop a strategy based on the new information I can gather with that new tool on the other platform while still using my already tested and true strategy on TOS at the same time. This could also get you a few different systems designed for specific market conditions. TOS for bullish trend trading, TradeStation for bearish trend trading, and TradingView for choppy market scalping. All up in front of you for when the market shows its hand.

Hope this moves you guys past the "problem" and gets you thinking about solutions and workarounds instead.
 

Similar threads

Top