Is there a way to say “If trading account is above XXX USD then position size = YYY”?
There is no way from TradingView.com to know what’s the broker trading account balance.
But from tradingview.to, we can access to the trading account balance with the “BALANCE” command
This will result to 3 buys if the balance is at least 1000, 2 buys if it is at least 2000 as the first order will fail.
Your request is to have dynamic volume based on the balance. Since your Q and balance seem to increase constantly, I would suggest using the Q as a percentage which will have the same effect.
If lets say with a 1000 USD balance and 1% volume is 1, then if the balance is 2000USD the volume will be 2.
The balance parameter is for limiting trade execution if the balance has not met a certain value. Using Q as percentage uses the balance to determine the appropriate volume. So if your balance is 1500 from my previous example, your volume would be 0.15. This means that you no longer want to filter the Q based on balance because it is automatic.