Sidechair

strategy.margin_liquidation_price

Browse the reference

The price at which the current position would be liquidated by a margin call, or na.

Try it in the editor

strategy.margin_liquidation_price is a series float. When margin_long or margin_short in the strategy() header is above 0, the emulator closes positions the account can no longer fund. This is the price where that happens for the open position.

Type

series float

Remarks

  • It is na when there is no position or no margin requirement applies.
  • A margin call closes enough of the position to bring the margin back within the rules, which shows as an order in the trade list.

Example

Pine ScriptDraw the liquidation levelOpen in editor
//@version=6
strategy("Liquidation level", overlay = true, initial_capital = 10000, margin_long = 50, margin_short = 50, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
if ta.crossover(ta.sma(close, 10), ta.sma(close, 30))
    strategy.entry("Long", strategy.long)
plot(strategy.margin_liquidation_price, "Liquidation price", color.red, style = plot.style_linebr)
plot(strategy.position_avg_price, "Average price", color.gray, style = plot.style_linebr)

See also

Runs on Sidechair