The best unrealised profit a closed trade reached, as a percentage of its entry value.
strategy.closedtrades.max_runup_percent(trade_num) is the peak profit of the trade divided by its entry value, times 100. It uses the same intrabar highs and lows as strategy.closedtrades.max_runup.
Being relative to the trade's size, it is the version to average across trades or to compare with profit_percent.
Syntax
strategy.closedtrades.max_runup_percent(trade_num: series int) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| trade_num | series int | required | Zero-based index of the closed trade. 0 is the first trade the strategy closed and strategy.closedtrades - 1 is the most recent. |
Returns
series float: The largest unrealised gain as a percentage of the trade's entry value. na when the trade does not exist.
Remarks
- Returns na when trade_num is negative, is not below
strategy.closedtrades, or points at a trade that has dropped out of the history (seestrategy.closedtrades.first_index).
Example
//@version=6
strategy("Average run-up, %", overlay = false)
fast = ta.sma(close, 10)
slow = ta.sma(close, 30)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long")
sum = 0.0
for i = strategy.closedtrades.first_index to strategy.closedtrades - 1
sum += strategy.closedtrades.max_runup_percent(i)
plot(strategy.closedtrades > 0 ? sum / strategy.closedtrades : na, "Average run-up, %", color.teal)See also
strategy.closedtrades.max_runupstrategy.closedtrades.max_drawdown_percentstrategy.closedtrades.profit_percentstrategy.max_runup_percent
Runs on Sidechair