NexusFi: Find Your Edge


Home Menu

 





Trouble calculating the VWAP of each bar in a chart


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Quick Summary with 1 posts (0 thanks)
    2. looks_two chisound with 1 posts (0 thanks)
    3. looks_3 Big Mike with 1 posts (2 thanks)
    4. looks_4 Jura with 1 posts (1 thanks)
    1. trending_up 3,548 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Trouble calculating the VWAP of each bar in a chart

  #1 (permalink)
 chisound 
Chicago, IL USA
 
Experience: Advanced
Platform: Multicharts
Broker: TT and IQFeed
Trading: ES
Posts: 6 since Apr 2010
Thanks Given: 3
Thanks Received: 5

Hi:

I am attempting to calculate the internal VWAP for each bar in a chart as opposed to what is normally done when calculating VWAP, ie calculate the VWAP of a day as of the close of the last bar. So for each tick in a bar after and including the first tick of the bar i need to keep two counters going, one to keep a sum of Price of tick * volume of tick for the bar and the other to sum the volume of each tick for the bar. At the end of each bar i then calculate the internal VWAP of the bar that just closed using the following:

IntrabarVWAP = Bar Sum of (Price of tick * volume of tick ) / ( Sum of volume of ticks)

I then need to reset the two sum counters to 0 so that the internal VWAP for the next bar can be calculated independently.

Seems simple enough but this is a real headache. I either get the Internal VWAP of each bar to equal the Close of each bar, which is not possible or i get it to be a number that is outside of the range of each bar, which is also not possible.

I am using Multicharts 7.0 and have "Update on every tick" disabled for the indicator as i am using intrabarpersist . I have tried using Range Bars, minute bars (built from ticks) and tick bars all with the same results.

Here is the code i am using:

 
Code
vars:
    intrabarpersist PriceW(0),
    intrabarpersist ShareW(0),
    PriceX(0),
    ShareX(0),
    IntrabarVWAP(0);

If barstatus = 0 then begin    
    PriceW = 0;
    ShareW = 0;
end;
PriceW = PriceW + (Close * (Ticks));
ShareW = ShareW + (Ticks);
PriceX = PriceW;
ShareX = ShareW;
If ShareX > 0 then IntrabarVWAP = PriceX / ShareX; 

Plot1(IntrabarVWAP,"BarVWAP");
Many thanks for your help with this.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,465 since Jun 2009
Thanks Given: 33,242
Thanks Received: 101,665


You might check here:



Mike



Join the free Markets Chat beta: one platform, all the trade rooms!

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690

Also worth checking out:
-
- and this post.

Reply With Quote
Thanked by:




Last Updated on October 3, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts