Skip to content
Algo Trade Analytics Docs

strategy.opentrades.max_runup() - Pine Script Function

Returns the maximum run up of the open trade, i.e., the maximum possible profit during the trade, expressed in strategy.account_currency.

strategy.opentrades.max_runup(trade_num) → series float
NameTypeDescription
trade_numseries intThe trade number of the open trade. The number of the first trade is zero.
// Calculates the max trade runup value
for all open trades.//@version=6
strategy("strategy.opentrades.max_runup Example 2", pyramiding = 100)// Enter a long position every 30 bars.
if bar_index % 30 == 0
strategy.entry("Long", strategy.long)// Calculate biggest max trade runup value from all of the open trades.maxOpenTradeRunUp() => maxRunup = 0.0
for tradeNo = 0 to strategy.opentrades - 1 maxRunup :=
math.max(maxRunup, strategy.opentrades.max_runup(tradeNo)) result = maxRunup
plot(maxOpenTradeRunUp(), "Biggest max runup of all open trades")