The largest position size, long or short, that the strategy has held so far.
strategy.max_contracts_held_all is a series float: the highest absolute value that strategy.position_size has reached, in contracts, shares or units.
Type
series float
Remarks
- It only grows. It answers how large the strategy ever got, whichever side.
- A position is either long or short at any time, so this equals the larger of
strategy.max_contracts_held_longandstrategy.max_contracts_held_short.
Example
//@version=6
strategy("Largest position", overlay = true, pyramiding = 3, initial_capital = 10000)
if ta.crossover(close, ta.sma(close, 20))
strategy.entry("Layer", strategy.long, qty = 5)
if ta.crossunder(close, ta.sma(close, 50))
strategy.close_all()
plot(strategy.position_size, "Position size", color.blue, style = plot.style_stepline)
plot(strategy.max_contracts_held_all, "Largest ever", color.gray, style = plot.style_stepline)See also
strategy.max_contracts_held_longstrategy.max_contracts_held_shortstrategy.position_sizestrategy.risk.max_position_sizestrategy.opentrades
Runs on Sidechair