The total profit of all closed trades, after commission.
strategy.netprofit is a series float in the account currency: the sum of every closed trade's profit and loss. It does not include the open trade, so it changes only when a trade closes.
Type
series float
Remarks
- Equity equals initial capital plus net profit plus open profit.
- A losing strategy has a negative value.
Example
//@version=6
strategy("Profit target switch", overlay = true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
targetReached = strategy.netprofit >= 1000
if ta.crossover(ta.sma(close, 10), ta.sma(close, 30)) and not targetReached
strategy.entry("Long", strategy.long)
if ta.crossunder(ta.sma(close, 10), ta.sma(close, 30))
strategy.close("Long")
bgcolor(targetReached ? color.new(color.green, 90) : na)
plot(strategy.netprofit, "Net profit", color.green)See also
Runs on Sidechair