The number of closed trades that made a profit.
strategy.wintrades is a series int. A trade counts when it is closed and its result after commission is above 0.
Type
series int
Remarks
- Divide it by
strategy.closedtradesfor the win rate, after checking that closedtrades is not 0. strategy.wintradesdivided bystrategy.closedtradesis the win rate. A high win rate can still lose money when the losers are larger than the winners.
Example
//@version=6
strategy("Win rate", 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")
winRate = strategy.closedtrades > 0 ? strategy.wintrades / strategy.closedtrades * 100 : na
plot(winRate, "Win rate %", color.green)
hline(50, "Half", color.gray)See also
strategy.losstradesstrategy.eventradesstrategy.closedtradesstrategy.grossprofitstrategy.avg_winning_trade
Runs on Sidechair