TradingView
gorx1
30 มีนา 2022 เวลา 15 นาฬิกา 15 นาที

Market Profile Visible Range 

Crude Oil FuturesNYMEX

คำอธิบาย

Sup TV, 2 important points.
1) surprisingly, it's the first MP Visible Range script on TV;
2) This one doesn't use any bagging/binning*, instead each row represents the time spent on the actual minimal price steps (aka ticks).

The script will be further extended with usual market profile related functionally in future updates. At this point we have:
- Profile itself (each row represents how many bars touch the given price);
- Mode of the profile (called POC)**;

* Still it will be introduced in future when I will find / design the proper aggregating technique. It is vital for processing very wide price ranges (for example, 500 days on ES futures).
** The script correctly calculates POC by finding all the modes in the data & choosing the closest one to data's midrange.

For this kind of technical instrument finally it was more convenient to use Pine Script 5 (btw it's my first Pine 5).

Basically this script is a side-effect of another R&D I'm doing, the stuff is useful tho so let's go.
By choosing length we both specify the amount of data to be processed & the profile's location screen-wise. It's pretty cool and & useful, on my screen it's always almost touching the left side and still always visible.

The code is heavily commented in order to be understood fast, nothing fantastic, just a lil patience required this time.

Rationale
Market & volume profiles are well known concepts, lotta info available, the most important point of all that is that MP is just another way of visualizing data that lets you notice things you don't usually notice on sequential charts. From my side I can only add that it's better to use your own brain for thinking and reconsidering using volume profile in all the cases, especially on decentralized markets (unless you're aggregating ALL the volume data from everywhere, including options, OTC etc).


Here is it, for you

เอกสารเผยแพร่

New: tick-based rounding (ceiling) / aggregation was just added.

After a lil thought I decided to use ceiling function and then rounding by orders of magnitude. It makes sense, in case of using normal rounding or flooring we can end up with histogram building at zero price, just imagine what can happen if an asset trades close to zero... Then, the steps by orders of magnitude make sense as well, we don't introduce any arbitrary rounding and stick to math nature.

P.S.: huge thanks to @QuantNomad for rounding function, thank god at least I didn't have to do even this myself xD

- Aggregate. When this checkbox is checked, no ceiling occurs, you see histogram tied to actual ticks.
- Digits. Allows you to turn in aggregation, minding you checked off the previously mention setting.

Tbf, I havn't tested it yet on assets with exotic tick sizes such as ZB, but cmon, otherwise it's all cool!

เอกสารเผยแพร่

Fixed:
- max_bars_back;
- aggregation formula;

New:
- Now the profile can be placed on the right side of the screen;
- Offset parameter will help to fine-tune the profile's' position.

เอกสารเผยแพร่

New: the amount of rows was increased from 500 to 1000... by utilizing 'both' lines and boxes to make drawings.
It terms of code, now every even row is a box, and every odd row is a line.

Has Slavic engineering gone too far this time?
ความคิดเห็น
aljn8aljn
error " array is too large... "
gorx1
@aljn8aljn, hey, yeah I know, it's because of TV's limit on amount of lines. Gonna finish and release the proper tick-based binning soon, just wanna make it real. Before that, only short timeframes and non-volatile stuff like ZB and ES.

Because all this mainstream binning formulas a la "take the range & divide it by x" not good. In that case, even classic density estimation would be better.
aljn8aljn
error mate
gorx1
@aljn8aljn, just updated the stuff, check it out. "Aggregate" and "Digits" settings, works the same way as round() function in python, tho in our case we do ceiling rather than rounding
Intuitive_Trader
Thanks. How do you display it on the right side of the chart? When I add it it shows on the left instead of right.
gorx1
@Intuitive_Trader, hi, "Left / right" checkbox
Intuitive_Trader
@gorx1, Awesome. Thank you!
gorx1
//I know that currently script doesn't work in all cases due to TV's line limit and lack of bucketing, but still you can already use it, say on ES of FDAX
gorx1
@gorx1, FIXED
เพิ่มเติม