How to dynamically select QTY to trade in CASH Segment Based on Filtered list for Fixed Capital?

Hello,

As title says i want to do dynamic quantity trades based on results we get. Let me give small example of what i want to do.

let’s say want to Long stocks trading above Vwap and short stocks trading below Vwap at 9:30.

now some days it’ll have 10 stocks some days 2 and some days 5. so i want to deploy fixed 1Lac capital for the setup so when it gets result of 2 stocks qty to trade to be taken for 50K each stocks, when result returned is 10 stocks, each stocks will get traded qty as per 10k value. when result is 5 stocks then each stocks will be traded qty as per 20k capital. so total capital always used is 1Lac regardless of results of the stocks returned.

How do i achieve this?

Thank you.

@Nelson kindly guide Thanks.