The sum of the losses of all losing closed trades, as a positive number.
strategy.grossloss is a series float: the total of every closed trade that lost money, stated as a positive amount. It never decreases.
Type
series float
Remarks
- Net profit equals gross profit minus gross loss.
- Use it as the denominator of a profit factor:
strategy.grossprofit/strategy.grossloss, and check for 0 first. - It is stored as a positive number, so net profit is
strategy.grossprofitminusstrategy.grossloss, not plus.
Example
//@version=6
strategy("Profit factor", initial_capital = 10000, 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)
if ta.crossunder(ta.sma(close, 10), ta.sma(close, 30))
strategy.close("Long")
profitFactor = strategy.grossloss > 0 ? strategy.grossprofit / strategy.grossloss : na
plot(profitFactor, "Profit factor", color.blue)
hline(1, "Break even", color.gray)See also
strategy.grossprofitstrategy.netprofitstrategy.losstradesstrategy.grossloss_percentstrategy.avg_losing_trade
Runs on Sidechair