Intrabar VWAP - NinjaTrader Programming | futures io social day trading
futures io futures trading


Intrabar VWAP
Updated: Views / Replies:2,212 / 6
Created: by Eubie Attachments:2

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

Intrabar VWAP

  #1 (permalink)
Elite Member
Prague, Czech republic
 
Futures Experience: Beginner
Platform: NinjaTrader/ZF
Favorite Futures: ES, TF
 
Posts: 79 since Jul 2010
Thanks: 41 given, 34 received

Intrabar VWAP

Hello everybody,

I am trying to create an indicator that takes all the ticks within a bar and makes a VWAP out of them. The purpose is to have a dot in the middle of the bar where the VWAP sits.

As a first attempt, I coded it form gomCD, separating Buy and Sell volume. It worked but there was too little difference between buy and sell VWAP for the amount of messing up of charts. Hence, I would like to replace it with a version that does not differentiate between buy/sell volume.

So far, my code is the following:

 
Code
	
private double SumPrices;
private double SumVolume;

...

protected override void OnMarketData(MarketDataEventArgs e)
{
if ( FirstTickOfBar ){
	SumPrices = 0;
	SumVolume = 0;
	}
	
SumPrices += e.Price;
SumVolume += e.Volume;

DrawDot( "IntrabarVWAP" + CurrentBar, false, 0, SumPrices / SumVolume, Color.Black);
}
However, like this I sometimes get 3M bars with non-zero volume that have no VWAP (dot displayed). At the same time I sometimes get a VWAP that lies out of the High-Low range. NT Support kindly told me they cannot "debug custom indicators". It's obvious I am doing something wrong but can't figure out what. Including the screen of what is happening.

Any help is greatly appreciated.
Regards,
Daniel.

EDIT:
After writing a new version which stored the Last price and volume from OnMarketData() and calculating the VWAP in OnBarUpdate(), I found out that OnMarketData() does not fire with each tick of the replay. I knew that OnMarketDepth() does not fire on each update of the book on replay, but I had no idea that OnMarketData() is unrealiable as well. NT know about this stuff, I sent them several emails regarding this anomaly, without response. So in the end, I hacked the good ol' gomCD. Gomi, you are King. Without gomCD, ninja is dead.

Attached Thumbnails
Intrabar VWAP-intrabar_vwap_error.png  

Last edited by Eubie; October 17th, 2011 at 10:09 AM. Reason: Solved
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,599 received
Forum Reputation: Legendary



Eubie View Post
However, like this I sometimes get 3M bars with non-zero volume that have no VWAP (dot displayed). At the same time I sometimes get a VWAP that lies out of the High-Low range. NT Support kindly told me they cannot "debug custom indicators". It's obvious I am doing something wrong but can't figure out what. Including the screen of what is happening.

Any help is greatly appreciated.
Regards,
Daniel.

There are several problems with your code.

First, if you use OnMarketData(), the outcome depends on the data stream of you data provider. I personally use Interactive Brokers, and they use the fields e.price and e.Volume to transport other information. Often I just get a zero value for price and a huge value for volume, probably representing some sort of cumulated volume.

There is no need to use OnMarketData(), you can all do in OnBarUpdate(). Also I am not sure that OnMarketData() will recognize FirstTickOfBar, as this again is a value related to OnBarUpdate().

Third, your VWAP formula is false. You cannot simply up the price, but you need to add up the weighted price, so you sumSeries should include

 
Code
sumPriceVolume  +=  e.Price * e.Volume;
sumVolume += e.Volume;
or in OnBarUpdate() simply

 
Code
if (FirstTickOfBar)
{
      sumPriceVolume = Close[0] * Volume[0];
      sumVolume = Volume[0];
}
else
{
      sumPriceVolume += Close[0] * (Volume[0] - sumVolume);
      sumVolume = Volume[0];
}
if (sumVolume> 0)
   DrawDot ("IntrabarVWAP" + CurrentBar, false, 0, sumPriceVolume / sumVolume, Color.Black);
Not tested.

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #4 (permalink)
Elite Member
Prague, Czech republic
 
Futures Experience: Beginner
Platform: NinjaTrader/ZF
Favorite Futures: ES, TF
 
Posts: 79 since Jul 2010
Thanks: 41 given, 34 received

The e.Price * e.Volume was obviously a mistake out of rushing too much. The indicator is running nicely (the same as hacked gomi) but I guess faster. Thank you very much Fat Tails. I learned a lot from those few lines of code.

Reply With Quote
The following user says Thank You to Eubie for this post:
 
  #5 (permalink)
Elite Member
Portland, OR
 
Futures Experience: Intermediate
Platform: Sierra Chart
Favorite Futures: ES
 
Posts: 269 since Jan 2011
Thanks: 326 given, 179 received

Eubie/Harry - I tried to use this exact code - and I get the dots plotted on the close of the bar - instead of calculated VWAP for the bar.

Anything wrong with the code or should I be doing this with Gomi framework?

Thanks.

 
Code
        protected override void OnBarUpdate()
        {
			if (FirstTickOfBar)
			{
      			sumPriceVolume = Close[0] * Volume[0];
      			sumVolume = Volume[0];
			}
			else
			{
      			sumPriceVolume += Close[0] * (Volume[0] - sumVolume);
      			sumVolume = Volume[0];
			}

			if (sumVolume> 0)
   			DrawDot ("IntrabarVWAP" + CurrentBar, false, 0, sumPriceVolume / sumVolume, Color.Black);
        }

Attached Thumbnails
Intrabar VWAP-nt_dots.jpg  
Reply With Quote
 
  #6 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,599 received
Forum Reputation: Legendary


ejtrader View Post
Eubie/Harry - I tried to use this exact code - and I get the dots plotted on the close of the bar - instead of calculated VWAP for the bar.

Anything wrong with the code or should I be doing this with Gomi framework?

Thanks.

 
Code
        protected override void OnBarUpdate()
        {
            if (FirstTickOfBar)
            {
                  sumPriceVolume = Close[0] * Volume[0];
                  sumVolume = Volume[0];
            }
            else
            {
                  sumPriceVolume += Close[0] * (Volume[0] - sumVolume);
                  sumVolume = Volume[0];
            }

            if (sumVolume> 0)
               DrawDot ("IntrabarVWAP" + CurrentBar, false, 0, sumPriceVolume / sumVolume, Color.Black);
        }

You would need to set your indicator to CalculateOnBarClose = false. The VWAP will only be displayed on real-time data but not on historical data. If you also want to display an intraday VWAP on historical data, this would would require to load a secondary bar series of 1-tick bars and then perform the calculations by using the secondary bar series.

You can use high + low + open + close as a proxy for the VWAP. It is easier to calculate and does not make much of a difference.

Reply With Quote
 
  #7 (permalink)
Elite Member
Portland, OR
 
Futures Experience: Intermediate
Platform: Sierra Chart
Favorite Futures: ES
 
Posts: 269 since Jan 2011
Thanks: 326 given, 179 received

Thanks Harry.

I would use the O+C+H+L instead of close instead.

Reply With Quote

Reply



futures io > > > > > Intrabar VWAP

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute trade intrabar on bar close indicator spinnybobo NinjaTrader 3 April 2nd, 2012 03:59 PM
VWAP bands crazybears NinjaTrader 102 March 6th, 2012 05:33 PM
IOG causing my limit order to cancel and replace intrabar tradersheldon EasyLanguage Programming 10 August 2nd, 2011 10:03 AM
Plot RSI intrabar extremes jtrade The Elite Circle 13 April 12th, 2010 02:25 PM
VWAP question Todd NinjaTrader Programming 3 March 14th, 2010 07:13 PM


All times are GMT -4. The time now is 01:31 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, 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
Page generated 2017-12-11 in 0.12 seconds with 20 queries on phoenix via your IP 54.145.16.43