The average result of a closed trade in the account currency, winners and losers together.
strategy.avg_trade is a series float: net profit divided by the number of closed trades. It is na until the first trade closes.
Type
series float
Remarks
- It is the expectancy of the strategy in money per trade, after commission.
- It equals
strategy.netprofitdivided bystrategy.closedtrades. Because it is in money, compare runs with different sizes throughstrategy.avg_trade_percentinstead.
Example
//@version=6
strategy("Expectancy guard", overlay = true, initial_capital = 10000)
enoughTrades = strategy.closedtrades >= 10
losing = enoughTrades and strategy.avg_trade < 0
if ta.crossover(ta.sma(close, 10), ta.sma(close, 30)) and not losing
strategy.entry("Long", strategy.long, qty = 10)
if ta.crossunder(ta.sma(close, 10), ta.sma(close, 30))
strategy.close("Long")
plot(strategy.avg_trade, "Average trade", color.blue, style = plot.style_stepline)
bgcolor(losing ? color.new(color.red, 90) : na)See also
strategy.avg_trade_percentstrategy.avg_winning_tradestrategy.avg_losing_tradestrategy.netprofitstrategy.closedtrades
Runs on Sidechair