Login Page - Create Account

Support Board


Date/Time: Thu, 03 Jul 2025 20:40:06 +0000



Post From: bid-ask volume on VBP

[2025-06-16 19:08:26]
joshtrader - Posts: 519
SC Engineers, I found this old thread as it is exactly what I was going to ask, and I think I see the error in the calculation of the Bid-Ask diff bars which makes the smallest ones too long. I think you are scaling the length (again, "length" but along the horizontal axis) of the existing bars which have already been calculated based on their absolute values, rather than calculating the width of the Bid-Ask diff bars based on the underlying volume data.

For example, in your current calculation I think you're probably calculating the absolute BidAskDiff bar lengths, and THEN scaling those bars by a factor specified by the user in the "Difference of Bid and Ask Volume Coloring Percentage of Maximum Bar" option. Perhaps this is a performance optimization to avoid looping twice.

If the longest BidAskDiff bar is 5% using absolute volume, and the user wishes to make it 50%, then the smallest BidAskDiff bar, if it has a width of 1, would now have a width of 10, even if the Bid-Ask absolute value there is only 1, which could represent something like 0.0000001% of the total width!

Rather than this, the bar width really should be based on the raw volume and not an existing bar width:


for i in each price in the VbP range:
[...]
BidAskDiffBarLength[i] = int(BidAskDiff[i] / MaxBidAskDiffAtPrice * UserInputBidAskDiffPctOfMaxBar * MaxTotalVolumeBarLength)

Imagine the following values:


MaxBidAskDiffAtPrice = 5000
MinBidAskDiffAtPrice = 1
MaxTotalVolumeBarLength = 1000 (total width of the VbP)
UserInputBidAskDiffPctOfMaxBar = 0.50 (50%)

For the largest BidAskDiff bar, which is 5000:
BidAskDiffBarLength[i] = int(BidAskDiff[i] / MaxBidAskDiffAtPrice * UserInputBidAskDiffPctOfMaxBar * MaxTotalVolumeBarLength)
= int(5000 / 5000 * 0.5 * 1000)
= 500

For the smallest BidAskDiff bar, which is 1:
BidAskDiffBarLength[i] = int(BidAskDiff[i] / MaxBidAskDiffAtPrice * UserInputBidAskDiffPctOfMaxBar * MaxTotalVolumeBarLength)
= int(1 / 5000 * 0.5 * 1000)
= 1

Perfect! The largest BidAskDiff price has the user desired 50% value. The smallest has the smallest possible value of 1.

Date Time Of Last Edit: 2025-06-17 15:39:59
imageBlockyVbP.png / V - Attached On 2025-06-16 19:10:32 UTC - Size: 88.05 KB - 10 views