TradingView help in improving Anchored Vwap - futures io
futures io



TradingView help in improving Anchored Vwap


Discussion in Platforms and Indicators

Updated
    1. trending_up 2,974 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

TradingView help in improving Anchored Vwap

(login for full post details)
  #1 (permalink)
 foreverlearner 
Rio de Janeiro. Brazil.
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Trading: Emini ES
 
Posts: 26 since Sep 2019
Thanks: 9 given, 29 received

I am trying to create a Anchored VWAP for Trading view, but the problem is, it is not consistent when moving to a higher timeframe.

Trading View has a native drawing tool for Anchored Vwap, and it works consistently.

Example: If I plot my AVwap on the 14/April/2021 at 4am (4 hour chart) if I go up to a daily chart my AVwap will move to the 15th, but TV's AVwap Drawing tool works correctly at 14th. If I go to the weekly chart, my AVwap goes to the 19th, but native Drawing tool goes to the week 12th (which is correct).

What should I change in my code for it to work as the native drawing tool does?

This is my code:

 
Code
//@version=4
study("My Midas VWAP TimeStamp", shorttitle="MY MIDAS TS", overlay=true)

showmidas01=input(true, title="Show Midas")

startBar01 = input(timestamp('14 Apr 2021 04:00 -0400'), '#1 Start Time', type=input.time)
mid01=  true //input(true, title=" Show Midas 1 Line" )

startmidas01 = time >= startBar01 and time[1] < startBar01

v01 = na(volume) ? 1 : volume
cumV01= cum(v01)
CumPV01= cum(hl2*v01)

startV01 = valuewhen(startmidas01, cumV01[1], 0)
StartPV01 = valuewhen(startmidas01, CumPV01[1], 0)

Midas01 = (CumPV01-StartPV01)/(cumV01-startV01)

middle01 = plot(mid01 and showmidas01? Midas01:na, title="Midas 1", color=color.aqua,linewidth=2)

Attached Thumbnails
Click image for larger version

Name:	AnchoredVwap-TS.png
Views:	64
Size:	82.2 KB
ID:	315338  
Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
NFP
TradeStation
How many bars have passed since daily high
ThinkOrSwim
Server Sepcs
TradeStation
Looking for combined bar type (UniRenko with HeikinAshi) NT8
NinjaTrader
Can anyone help convert this pine script to EasyLanguage?
EasyLanguage Programming
 
 
(login for full post details)
  #2 (permalink)
 JayMay 
Toronto Ontario/Canada
 
Experience: Beginner
Platform: Tradingview
Trading: stocks, gold
 
Posts: 1 since Sep 2012
Thanks: 0 given, 1 received

Your script identifies a specific point in time (timestamp) for the plot session to initiate. If a bar opens at the same time as your timestamp then the MIDAS/anchored VWAP will be initiated at the same time as your timestamp. If the bar does not open at the same time as your timestamp then the MIDAS/anchored VWAP will be initiated on the next bar open.
To compensate you should have the script query the timeframe and then initiate the MIDAS/anchored VWAP one bar earlier in time. If you move to a weekly chart the initiating time must be moved back in time by one week.
I have added a line to address your specific request. I have not coded in any exceptions, that is to say, what if the timestamp is exactly at the starting point of a daily and/or weekly bar. The script will still subtract the daily or weekly time equivalent, which is not what you want. You might well be able to address this particular exception by using the following line as an alternate to the one I inserted below: startBar01=timeframe.isweekly?startBar_01 - (1000*7*24*60*60)+ 1000:timeframe.isdaily?startBar_01 - (1000*24*60*60)+1000:startBar_01. I have not tested it.
Also, I changed the plot colour to navy so that you can see the different plots.

// foreverlearner with input by jayy

//@version=4
study("Midas anchored VWAP TimeStamp", shorttitle="MIDAS TS", overlay=true)

showmidas01=input(true, title="Show Midas")

startBar_01 = input(timestamp('14 Apr 2021 04:00 -0400'), '#1 Start Time', type=input.time)
mid01= true //input(true, title=" Show Midas 1 Line" )
startBar01=timeframe.isweekly?startBar_01 - (1000*7*24*60*60):timeframe.isdaily?startBar_01 - (1000*24*60*60):startBar_01
startmidas01 = time >= startBar01 and time[1] < startBar01

v01 = na(volume) ? 1 : volume
cumV01= cum(v01)
CumPV01= cum(hl2*v01)

startV01 = valuewhen(startmidas01, cumV01[1], 0)
StartPV01 = valuewhen(startmidas01, CumPV01[1], 0)

Midas01 = (CumPV01-StartPV01)/(cumV01-startV01)

middle01 = plot(mid01 and showmidas01? Midas01:na, title="Midas 1", color=color.navy,linewidth=2)

Reply With Quote
The following user says Thank You to JayMay for this post:


futures io Trading Community Platforms and Indicators > TradingView help in improving Anchored Vwap


Last Updated on August 4, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts