strategy.closedtrades.max_runup() - Pine Script Function
strategy.closedtrades.max_runup()
Section titled “strategy.closedtrades.max_runup()”Overview
Section titled “Overview”Returns the maximum run up of the closed trade, i.e., the maximum possible profit during the trade, expressed in strategy.account_currency.
Syntax
Section titled “Syntax”strategy.closedtrades.max_runup(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.max_runup` Example")// 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")// Get the biggest max trade runup value from all of the closed trades.maxTradeRunUp() => maxRunup = 0.0for tradeNo = 0 to strategy.closedtrades - 1 maxRunup :=math.max(maxRunup, strategy.closedtrades.max_runup(tradeNo)) result = maxRunupplot(maxTradeRunUp(), "Max trade runup")