Hi
Try the attached trigger in test mode and see if does what you need.
Every second it sums all selections back_volume and all selections lay_volume in variables: mbv and mlv
In the settings if Download all price offers is ticked, it will give the market back and lay offered volume for all prices. If it is unticked, it will be for best 3 back and lay prices.
The trigger recalculates every second. If all price offers is on, that adds an extra request to the API, so it may skip a refresh once in a while and show zero. In this case just decrease the repetiton rate of the trigger to say no more often than 5 secs, and perhaps add a condition in your betting trigger to check mlv or mbv is greater than 0.