Sidechair

strategy.opentrades.capital_held

Browse the reference

The account-currency capital tied up by the trades that are currently open.

Try it in the editor

strategy.opentrades.capital_held is a series float. It is the money the broker emulator sets aside to keep the open trades, which depends on the margin percentages in the strategy() header (margin_long and margin_short).

With the default 100% margin, a long position holds its full entry value. With a lower margin, only that fraction is held and the rest of the position is leveraged. It drops back to 0 when the strategy is flat.

Type

series float

Remarks

  • It is in the account currency, so compare it with strategy.equity and not with a price.
  • A new entry is refused or the position is liquidated when equity cannot cover the margin; strategy.margin_liquidation_price reports the price where that happens.

Example

Pine ScriptShare of equity heldOpen in editor
//@version=6
strategy("Capital held", overlay = false, margin_long = 50, margin_short = 50)
fast = ta.sma(close, 10)
slow = ta.sma(close, 30)
if ta.crossover(fast, slow)
    strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
    strategy.close("Long")
share = strategy.equity > 0 ? 100 * strategy.opentrades.capital_held / strategy.equity : na
plot(share, "Equity held, %", color.purple)

See also

Runs on Sidechair