I have my own Pine script strategy V5 and it's profitable on almost all forex pairs and XAU pairs as well. However, it's somehow inflated because it ignores that fact of spread and comission. How can I consider these factors in the backtesting on Tradingview to be similar to what I should expect while trading in FTMO challenges?
2 Answers
You can use the commission
and slippage
properties.
You can set those either manually via the settings:
Or programmatically with the corresoping arguments in your strategy()
call.
slippage (const int) Slippage expressed in ticks. This value is added to or subtracted from the fill price of market/stop orders to make the fill price less favorable for the strategy. E.g., if syminfo.mintick is 0.01 and
slippage
is set to 5, a long market order will enter at 5 * 0.01 = 0.05 points above the actual price. This setting can also be changed in the strategy's "Settings/Properties" tab. Optional. The default is 0.commission_type (const string) Determines what the number passed to the
commission_value
expresses: strategy.commission.percent for a percentage of the cash volume of the order, strategy.commission.cash_per_contract for currency per contract, strategy.commission.cash_per_order for currency per order. This setting can also be changed in the strategy's "Settings/Properties" tab. Optional. The default is strategy.commission.percent.commission_value (const int/float) Commission applied to the strategy's orders in units determined by the argument passed to the
commission_type
parameter. This setting can also be changed in the strategy's "Settings/Properties" tab. Optional. The default is 0.

- 15,740
- 3
- 16
- 26
-
thanks so much... what I understood is that I should use the commission value for the commission fees. and I should use the slippage for the spread values. is it right? if yes, how much should I put in both inputs to simulate the FTMO trading? any idea? – SAB Investments Feb 01 '23 at 18:09
I struggled with your question as well, this is what I found:
Slippage will only be used for market and stop orders. Slippage simply refers to the request to make backtesting more realistic. Slippage is empirical, determined by the results of observations of the performance of a particular broker, and, by and large, has nothing to do with bid/ask spread.
For both commission or spread you can use the commission parameters of the backtester.
Spread is not directly tied to the commission. Say, you broker charges 3.5$ per lot, which is 100 000 contracts. So commission for one contract is 3.5/100000 = 0.000035$.
And if you want to add the spread to that then add it divided by 2 (entry and exit, so you don't get charged twice for one contract) to that if you want to take that into account as well.
Say, GBPUSD current price is 1.29470 --- 1.29480, so the spread is 0.0001$. You slice it in two and get 0.00005. Add it to the commission and get 0.000085$.
When calculating your commission/spread fees be mindful of your base currency. When it is different to the second symbol of your ticker (as in GBPUSD is USD vs USDJPY is JPY) you will need to convert this back to your base currency. If trading USDJPY and you have USD as your base currency, remember to convert JPY back to USD to get the correct rate/value.
Hope this helps!

- 7
- 2