Hi all, Here's my first contribution to the community: an attempted implementation of the value area calculation from auction maket theory (Steidlmayer, Dalton etc). Couldn't find this on QC and other implementations I've seen floating on other sites seem to be wrong. Briefly:
"The value area represents the area of greatest trade facilitation and acceptance of value in the day timeframe and is signified by the price region where 70 percent of the day’s volume occurred." (Page 331, Mind Over Markets: Power Trading with Market Generated Information).
As a stand-alone signal, it probably won't get you very far but in combination with others trading signals can help you verify when price action is consolidating, overextended etc. You pass the function bars from a History call and it returns the the Point of Control (most traded price), the high and the low of the value area as decimals.
It works most of the time but could still use alot of testing and improvement (am fairly new to developing in c#). Major bug at the moment is the backtest hangs on certain days (e.g. Feburary 5th and 6th 2020) yet works fine others (all days in March so far, e.g.) and I can't seem to figure out why. Open to any suggestions and feedback!
Cheers
Patrick Chen
Still working on this but I think I know what the issue is...the 'comparing volume of price intervals' starts from the highest volume interval and works its way out, but isn't robust to local minimas, so it'll gets stuck in an infinite loop if the volume profile doesn't follow a nice bell shape e.g on the example chart here https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/V-Z/VolumeProfile
Will update this as I try other methods...
Josh M
I am very interested in this; if you are a 'pro' on tradingview.com you also get access to the 'value area' metrics which are very useful!
Jake Mitchell
I've made a working script in Python that calculates volume-based POC as well as time-based POC. However it runs quite slowly as is apparent when calculating over large datasets (1H history over 2 years of data takes ~8 minutes on a single symbol!). I'd be interested in hearing of an implementation that somehow avoids "binning" volume/time @ price but instead relies only on a novel idea for accumulating/decumulating volume/time @ price that saves on memory/iterations.
I was mulling over a notion of creating a "vector path histogram", where the beginning is the lowest price encountered (or just simply $0), and the end point is the highest value encountered. The step-wise curve itself is defined by the accumulation of bar data as it's encountered and decumulation as it passes beyond the lookback period.
So when you encounter new bar data, you create two 90 degree pivot anchors for each high/low when/where required which rises/fells the histogram line by the quantity you specify (volume / time). So the only object retained in memory is a vector path with a lower limit of 0 and an unbound upper limit. However I don't know how to program this or what the optimal mathematics is.
Joe Pereira
Jake Mitchell , happy to take a look at optimizing your data vector. It sounds like a great idea.
Derek Melchin
Hi everyone,
I've attached a Python backtest which implements a technique for calculating the Point of Control for a given day. We can accomplish this by setting our universe resolution to minute/second and determining the volume traded at each level over the intraday candles in OnData. When the day is over, we can build a window which captures the prices levels and the associated volumes traded. We start this window at the price level which had the most volume throughout the day and grow it incrementally in the direction of the price level that had the most volume (up or down) until we have 70% of the day's volume captured.
See the attached backtest and code for a full working example.
Best,
Derek
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Charles Naccio
Just wanted to comment here on the performance issue. I've found that migrating some of our algos to C# improved speeds by nearly 50X! We had backtests in Python that took ~6min per symbol to process, but that completed in just 8 seconds in C#. We're now writing all our algorithms in C#, and only using Python during research within the Python notebook Research environment. Hope this helps!
Derek Melchin
Hi Kbsaravana,
This related thread extends the use of this indicator.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
.ekz.
Derek Melchin : interested in this. any chance you have an updated link? The one you shared leads to a 404.
Jared Broad
Fixed ekz
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Prakash Murali
Hi Derek,
Thank you for sharing your code. I was trying to create a program that would take the symbol and date as input and spit out the POC for the day. I was trying to use your solution as the base and ran into couple of issues:
a). I tried running it for 11th and 12th of Nov and it gives the POC as 462.82. On 11th at 12th the price does not touch 462.
b). Is it possible to simply take a single date as start date and just aggregate volume for that date?
c).Does QC allow file IO? I want to write the output to a file. I searched the documentation and ran into custom reader but nothing on writing output.
Any help would be greatly appreciated.
Thanks,
Prakash
Varad Kabade
Hi Prakash Murali,
Would you mind sharing the backtest you are working with for a precise diagnosis?
No, we cannot do file IO it's a requirement of our data vendors to avoid data theft.
We recommend using the ObjectStore for storing or retrieving data during backtesting or the research environment. Refer to the following thread for more information.
Best,
Varad Kabade
Patrick Chen
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!