How do you determine how much to bet (when you have an advantage)?

That is an interesting question. Firstly you need a positive expected value (advantage.) If expected value is not positive then best bet is as little as possible. If expected value is positive then the greater the bet the greater the long run profit. However if a big bet loses then your bankroll takes a big hit and too big a hit can immediately put you out of business. Therefore unless a given situation is a sure win it is intuitively obvious that it is better to bet some portion of your bankroll on a positive expected value and not the whole thing for purposes of longevity.

One way of determining bet size is to simply flat bet a set amount for a given expected value. For example let's say starting bankroll is 100 units. You may decide that whenever expected value is 5% then you will bet 5 units. Whenever any subsequent 5% expected value occurs you will likewise bet 5 units regardless of current bankroll. (This will require playing on credit should current bankroll fall below 5 units.) Other expected values would call for differing flat bets as they occur.

Another way of determining bet size is to bet a fraction of (current) bankroll depending upon expected value. For example a 5% expected value that occurs when bankroll is 100 units may call for a 5 unit bet but a 5% expected value when bankroll is 60 units may call for a bet of 3 units. This assumes that betting policy is to bet 5% of current bankroll whenever expected value is 5%. Note that in theory it is impossible to ever go broke betting a fraction of current bankroll. In practice, though, an extensive losing streak could reduce bankroll such that it is less than a minimum bet requirement.

In the shorter term flat betting an advantage outperforms sizing bets by a fractional portion of bankroll which is dependent on expected value. However in the longer run fractional resizing is better. Why is this? Flat betting is like applying a fixed interest rate to an amount deposited in a bank account. If interest rate is 5% per year and \$1000 is the fixed principle then \$50 per year is added to the account. Fractional betting is like applying a compound interest rate. Interest is paid on the principle as well as money subsequently added to the account so even if interest rate is less than 5% if enough time passes then the compound interest account will be greater then the fixed interest account.

In the end there is one constant element required for a player to have a long term advantage in blackjack and that is the ability to consistently identify positive expected value betting opportunities. How a player uses the advantage is a subjective decision. With a positive expected value the more you bet the more you can expect to win. However it is also true that, somewhat paradoxically, the more you bet on a positive EV the more likely it is that your bankroll will be decimated. So what gives? Let's say there are 1000 players that aggressively "overbet" all positive EV opportunities. Maybe out of the 1000, 999 are wiped out but 1 out of the 1000 does well. In the long run the 1 that does well will bring up the average result of all 1000 such that the average result is a profit. After all, it is positive EV isn't it? Basically the choice is to bet positive EV aggressively for a small chance to win a lot with a larger chance of being wiped out or more conservatively with a greater chance of winning less and a smaller chance of failure.