The account-currency capital tied up by the trades that are currently open.
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.equityand not with a price. - A new entry is refused or the position is liquidated when equity cannot cover the margin;
strategy.margin_liquidation_pricereports the price where that happens.
Example
//@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