strategy.closedtrades.commission() - Pine Script Function
strategy.closedtrades.commission()
Section titled “strategy.closedtrades.commission()”Overview
Section titled “Overview”Returns the sum of entry and exit fees paid in the closed trade, expressed in strategy.account_currency.
Syntax
Section titled “Syntax”strategy.closedtrades.commission(trade_num) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| trade_num | series int | The trade number of the closed trade. The number of the first trade is zero. |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6strategy("`strategy.closedtrades.commission` Example", commission_type = strategy.commission.percent, commission_value = 0.1)// Strategy calls to enter long trades every 15 bars and exit long trades every 20 bars.if bar_index % 15 == 0strategy.entry("Long", strategy.long)if bar_index % 20 == 0strategy.close("Long")// Plot total feesfor the latest closed trade.plot(strategy.closedtrades.commission(strategy.closedtrades - 1))