Sidechair

strategy.max_contracts_held_short

Browse the reference

The largest short position size the strategy has held so far.

Try it in the editor

strategy.max_contracts_held_short is a series float: the largest size of any short position, stated as a positive number. It is 0 if the strategy never went short.

Type

series float

Remarks

Example

Pine ScriptShort side as a share of the largest positionOpen in editor
//@version=6
strategy("Short peak size", overlay = true, 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 = 8)
shortShare = strategy.max_contracts_held_all > 0 ? strategy.max_contracts_held_short / strategy.max_contracts_held_all * 100 : na
plot(shortShare, "Short share of peak %", color.red)

See also

Runs on Sidechair