How to select bar range for indicator calculation in pinescript? Converting volume profile to interactive custom range volume profile
I’m trying to rework the volume profile script to an interactive one where I can select a custom bar range for volume profile calculation similar to the paid version on tradingview. I already made the script calculate correctly based on bar_index inputs, but the script plots the VP rows wrong. For some reason, it takes the pivot point high or low that is within [lastbar] index range from “bbars” which should be the beginning of volume calculation (attached screenshot). Instead, the script should fit all the VP rows to the high/low range between “bbars” and “lastbar” bar_index values, making the profile more detailed. The issue comes from this line: top = ta.highest(bbars)[lastbar] bot = ta.lowest(bbars)[lastbar]
which I don’t know how to code in other way.