Trading metric
Trade Expectancy Calculator
Combine your win rate with the average size of your wins and losses to find the expected value of a single trade. It is the number that ties win rate and payoff together into one figure.
What trade expectancy is
Expectancy is the average amount you can expect to win or lose per trade over a large number of trades, given a win rate and the typical size of wins and losses. It is the probability-weighted average outcome: expectancy = (win rate × average win) − (loss rate × average loss), where the loss rate is simply one minus the win rate.
Expectancy is what finally reconciles win rate and payoff, the two figures that are misleading on their own. A strategy that wins only 45% of the time can have strongly positive expectancy if its average win is twice its average loss, while a 70% win rate can still be a losing approach if the losses are large. Expressing expectancy in R, where one R equals the size of a typical loss, makes it easy to compare very different strategies on the same scale.
Why expectancy is used
Expectancy is used to judge whether an approach has a positive edge at all, and to compare strategies regardless of how often they win. A positive expectancy means the average trade adds value over the sample measured; a negative one means it subtracts value. Paired with how many trades a strategy produces, expectancy also hints at how quickly results tend to accumulate.
Expectancy is calculated from past results and assumes the future resembles the sample, which it may not. It is a descriptive figure, not a promise, and how you use it is entirely your own decision.
What are TradingView and Pine Script?
TradingView is one of the most widely used charting and market-analysis platforms, where traders and analysts study price movement across stocks, crypto, forex, and futures on interactive charts. Pine Script is TradingView's own lightweight programming language, created so anyone can build custom tools that run directly on those charts.
People use Pine Script to build four main kinds of tools. Indicators calculate and plot values on the chart, exactly like the calculation above, but recomputed automatically on every bar. Strategies add explicit entry and exit rules and can be backtested against historical data in TradingView's Strategy Tester to see how they would have behaved. Screeners scan many symbols at once for conditions you define. Alerts notify you the moment a condition you specified occurs, so you do not have to watch the screen.
The value is precision and automation. Instead of eyeballing a chart, you describe exactly what you want measured, visualized, or notified about, and TradingView runs it consistently across any market and timeframe. That is why traders, analysts, and developers write Pine Script: it turns a manual charting idea into a repeatable tool. These tools are for tracking, visualizing, and testing market ideas; they do not tell you what to trade, and that decision always remains yours.
Writing that code by hand means learning Pine Script's syntax, its type system, and the exact names of hundreds of built-in functions. It is a real programming language, and small mistakes stop a script from compiling in the Pine Editor.
Turn this into Pine Script
You entered your win rate and average P&L by hand here. In a coded strategy, TradingView tracks winning and losing trades and their totals, so the pieces of expectancy, the win rate and the average win and loss, come straight from built-ins like strategy.grossprofit and strategy.wintrades. Turning your idea into that strategy is the real work, and where PineScripter helps.
//@version=6
strategy("Expectancy Example", overlay=true)
winRate = strategy.closedtrades > 0 ? strategy.wintrades / strategy.closedtrades : 0.0
avgWin = strategy.wintrades > 0 ? strategy.grossprofit / strategy.wintrades : 0.0
avgLoss = strategy.losstrades > 0 ? strategy.grossloss / strategy.losstrades : 0.0
expectancy = winRate * avgWin - (1 - winRate) * avgLoss
plot(expectancy, "Expectancy per trade")PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v5 or v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.
Related free calculators
From the blog
PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.