Sidechair

strategy.max_contracts_held_all

Browse the reference

The largest position size, long or short, that the strategy has held so far.

Try it in the editor

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

Example

Pine ScriptLargest position the run ever tookOpen in editor
//@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

Runs on Sidechair