Calculating the correct commission type for strategies

Calculating the correct commission type for strategies

When running strategies in Pine Script, we have the option to choose a commission type that reflects the commission type we will be using when live trading. Choosing the correct commission type is important in order to get the most accurate results for our strategy.

There are three types of commission we can choose from in Pine Script:

  1. strategy.commission.cash_per_contract: This type of commission is displayed in the account currency per contract. A contract is the order size divided by the base unit. For example, if we have an order size of $100 and we want to buy EUR/USD at 1.10, we would divide 100/1.10 and get around 90 contracts, which would be equivalent to 90 Euros. In Forex, these contracts are usually rounded. For BTC/USD, we could have an order size of $100 and buy BTC/USD at $10,000, making our contracts equal to 100/10,000 or 0.01 contracts. When using this commission type, our commission fees will vary based on the order size and the type of security we are trading.
  2. strategy.commission.cash_per_order: This type of commission is displayed in the account currency per order. The main difference between this type of commission and the cash_per_contract type is that the cash_per_order type charges a constant fee for each order, regardless of the order size or type of security being traded.
  3. strategy.commission.percent: This type of commission is a percentage of the cash volume of the order. This is probably the most common commission type, as it charges a percentage of the trade’s value rather than a fixed fee.
It's important to note that all commissions are paid on each order, including both entries and exits. For example, if we buy $100 worth of a security and pay a 1% commission, we would pay a $1 commission on the entry. If we then sell the security at a profit and the price doubles, our $100 is now worth $200. If we pay a 1% commission on the exit, we would pay a $2 commission. In total, we would pay $3 in commission for the full trade.

By understanding the different commission types available in Pine Script and choosing the one that best reflects the commission type we will be using in live trading, we can ensure that our strategy results are as accurate as possible.

Leave a Reply