strategy.opentrades.max_runup() - Pine Script Function
strategy.opentrades.max_runup()
Section titled “strategy.opentrades.max_runup()”Overview
Section titled “Overview”Returns the maximum run up of the open trade, i.e., the maximum possible profit during the trade, expressed in strategy.account_currency.
Syntax
Section titled “Syntax”strategy.opentrades.max_runup(trade_num) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| trade_num | series int | The trade number of the open trade. The number of the first trade is zero. |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”// Calculates the max trade runup valuefor all open trades.//@version=6strategy("strategy.opentrades.max_runup Example 2", pyramiding = 100)// Enter a long position every 30 bars.if bar_index % 30 == 0strategy.entry("Long", strategy.long)// Calculate biggest max trade runup value from all of the open trades.maxOpenTradeRunUp() => maxRunup = 0.0for tradeNo = 0 to strategy.opentrades - 1 maxRunup :=math.max(maxRunup, strategy.opentrades.max_runup(tradeNo)) result = maxRunupplot(maxOpenTradeRunUp(), "Biggest max runup of all open trades")