Sidechair

strategy.initial_capital

Browse the reference

The starting capital set by the initial_capital argument of strategy().

Try it in the editor

strategy.initial_capital is a series float that holds the same number on every bar. It is the base for the percent forms of net profit, drawdown and run-up, and for sizing orders by percent of equity.

Type

series float

Remarks

  • The default is 1,000,000 in the account currency when the strategy() header does not set it.
  • Changing the value in the settings dialog re-runs the strategy from the first bar.

Example

Pine ScriptRisk one percent of the starting capitalOpen in editor
//@version=6
strategy("Fixed-fraction risk", overlay = true, initial_capital = 25000)
riskCash = strategy.initial_capital * 0.01
stopDistance = ta.atr(14) * 2
qty = riskCash / stopDistance
if ta.crossover(close, ta.sma(close, 50))
    strategy.entry("Long", strategy.long, qty = qty)
    strategy.exit("Stop", "Long", stop = close - stopDistance)
plot(qty, "Quantity", display = display.data_window)

See also

Runs on Sidechair