# 19/11/2020

### 1. How to factor the exchange commission into loss recovery?

This is a seemingly simple question, but it puzzles many of you when you want to recover the losses from earlier bets by increasing your next bet. BetFair deducts a commission (anything from 4.5% to 7%) from your net winnings, so you need to take that into account when calculating the amount you want to bet.

The commission rate is applicable to each market (it can vary from market to market), and it depends on which country you are in, whether you pay a premium commission, and many other factors. Read more about the exchange commission here.

Let’s throw in a few basic formulas.

BACKING

If you back bet_size at a price of back_price, you will get the following amount in profit, provided that the selection wins:

bet_size*(back_price - 1)*(1-commission)

If the selection loses, you lose bet_size, and the commission is not charged.

If you want to recover the whole amount of your current loss (let’s call it current_lss) in your next bet, in addition to your flat bet of bet_size, you need to back the following amount:

bet_size + current_lss/((back_price-1)*(1-commission))

where commission is your commission rate.

LAYING

If you lay bet_size at a price of lay_price, you will get the following amount in profit, provided that the selection loses:

bet_size*(1-commission)

If the selection wins, you lose bet_size*(lay_price - 1), and the commission is not charged.

If you want to recover the whole amount of your current loss (let’s call it current_lss) in your next bet, in addition to your flat bet of bet_size, you need to lay the following amount:

bet_size + current_lss/(1-commission)

If you are considering a green-up bet on a selection after you’ve backed or laid it previously, then the built-in tradeout_net variable will give you the net P/L after the green-up bet is matched, with the commission already included. So if you're looking to recover current_lss with a green-up trigger, you would need to check that the following is true:

Selection’s Trigger Expression tradeout_net is equal or greater than current_lss

### 2. How to calculate the sum of back or lay bets in a market?

There are no dedicated variables for this, but you can easily make them yourself.

Here’s an example of such trigger. It creates four variables with the sums of matched and unmatched back and lay bets.

mlay_bets_sum: sum of matched lay bets

ulay_bets_sum: sum of unmatched lay bets

mback_bets_sum: sum of matched back bets

uback_bets_sum: sum of unmatched back bets

### 3. Where are the statement files and program logs stored?

Where %username% is your Windows username and %profile name% is the name of the settings profile you’ve chosen when logging in to MarketFeeder Pro. Each settings profile has a separate place for storing logs.

The statements (both real and test) can be found further down that path:

The trigger logs here:

The Program Log here:

It’s a good practice to clear these folders from time to time to avoid clogging up your hard drive. There is a way to do it automatically using the following setting:

Tip: you can view your statement in Excel, as it is stored in a *.csv file.

### 4. How to concatenate strings in triggers?

String concatenation is simply gluing together two or more strings. Most programing languages have a dedicated operator for string concatenation, e.g. "String1" + "String2" or "String1"."String2".

In MarketFeeder Pro, two or more strings can be concatenated just by putting them together within double quotes, e.g.:

"String1 String2"

If your strings are stored in variables, you just put these variables in a single string, like this:

"var1 var2 var3"

Note: neither of these variables must actually be strings, i.e. they can be numbers.

See a trigger example that concatenates strings below. The resulting variables will give you the following:

concat1: a string with the names of the first and second selections

concat2: a single string with myvar1 and myvar2 constants.