The largest long position size the strategy has held so far.
strategy.max_contracts_held_long is a series float: the highest positive value strategy.position_size has reached. It is 0 if the strategy never went long.
Type
series float
Remarks
- It only grows.
- It never falls when the position closes, so it cannot tell you the current size. Read
strategy.position_sizefor that.
Example
//@version=6
strategy("Long peak size", overlay = true, pyramiding = 2, initial_capital = 10000)
fast = ta.sma(close, 10)
slow = ta.sma(close, 30)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long, qty = 5)
if ta.crossunder(fast, slow)
strategy.entry("Short", strategy.short, qty = 3)
plot(strategy.max_contracts_held_long, "Largest long", color.green, style = plot.style_stepline)
plot(strategy.max_contracts_held_short, "Largest short", color.red, style = plot.style_stepline)See also
strategy.max_contracts_held_shortstrategy.max_contracts_held_allstrategy.position_sizestrategy.entrystrategy.risk.max_position_size
Runs on Sidechair