Market Profile Value Area Calculations Using Python

QuanTrader
2 min readJan 11, 2019

--

My fork is based on bfolkens python code https://github.com/bfolkens/py-market-profile

Link for my fork.

Made the following changes.

1. Local CSV file is added as a source for raw data instead of google API since it doesn’t work anymore.
2. Expanded the Market Profile function so users can select between TPO and volume profile.
3. Now you can plot Market Profile in a horizontal fashion in a classical way. (original code plots it in the vertical bar format)
4. You can plot horizontal lines such as POC, VAH, VAL on the same Market Profile chart

You can check the example python code right here

We will calculate value areas for Nifty Future using the local CSV or txt file.

The .csv format is something like this:

ticker, date, time, open, high, low, Close, volume.

The data looks like this

_NF1,20181228,09:15,10859.65,10871.0,10851.45,10871.0,172875
_NF1,20181228,09:16,10869.2,10879.0,10869.2,10878.1,137850
_NF1,20181228,09:17,10878.75,10884.0,10878.15,10879.15,152325
_NF1,20181228,09:18,10880.35,10885.95,10877.5,10880.15,137925
_NF1,20181228,09:19,10880.05,10888.3,10880.05,10884.95,90150

The MP plot looks like this

Horizontal value area lines

Print output

Initial balance: 10869.200000, 10929.650000
Opening range: 10869.200000, 10898.100000
POC: 10925.000000
Profile range: 10880.000000, 10945.000000
Value area: 10920.000000, 10935.000000
Balanced Target: 10970.00000

I hope that we will see a lot of Market Profile in the algo community as an objective tool.

--

--

QuanTrader

Learner, a full-time trader for 11 years. Currently with prop desk based in Toronto risking my own capital.