Dear community,

I'm currently developing a strategy where it is crucial to set entries & stops based on the volume profile.

I have read this article which shows how to get the volume profile for a particular day (



I want to set entires/stops based on the previous x days of the accumulated volume.

For example:

As soon as price is outside of the 2nd standard deviation (based on volume) of the last ten days buy/sell a security.

If I placed an order I want to set stops based on percentiles, for instance as soon as price hits the 10% or 90% percentile (based on volume) liquidate the position.


I am trying to understand how to modify the code (Derek Melchin's code from the post) so it incorporates the functionality I need.


I hope that you can point me into the right direction.


Thank you very much