Use this file to discover all available pages before exploring further.
Analysis criteria measure a single aspect of strategy performance — returns, drawdown, win rate, or cost — and return a Num value. They share a common interface that makes it straightforward to swap metrics or combine them for strategy ranking.
public interface AnalysisCriterion { // Evaluate over all positions in a trading record Num calculate(BarSeries series, TradingRecord tradingRecord); // Evaluate for a single position Num calculate(BarSeries series, Position position); // Compare two criterion values — each criterion defines what "better" means boolean betterThan(Num criterionValue1, Num criterionValue2);}
Simulates a buy-and-hold baseline: enter at the close of the first bar, exit at the close of the last bar. Wrap any criterion to get its buy-and-hold equivalent.
// Net return of a simple buy-and-hold over the same periodEnterAndHoldCriterion buyAndHold = new EnterAndHoldCriterion( TradeType.BUY, new NetReturnCriterion());Num holdReturn = buyAndHold.calculate(series, record);
Computes a criterion for the active strategy and divides it by the same criterion calculated for a buy-and-hold baseline — giving a relative performance ratio.
VersusEnterAndHoldCriterion vs = new VersusEnterAndHoldCriterion( TradeType.BUY, new NetReturnCriterion());Num ratio = vs.calculate(series, record);// ratio > 1.0 means the strategy outperformed buy-and-hold
Largest single-position net profit or net loss across the trading record.
new MaxPositionNetProfitCriterion()new MaxPositionNetLossCriterion()
AverageReturnPerBarCriterion
Average return per bar over the full series duration — useful for comparing strategies with different holding periods.
new AverageReturnPerBarCriterion()
Drawdown criteria
Criteria in org.ta4j.core.criteria.drawdown measure peak-to-trough losses in the equity curve.
MaximumDrawdownCriterion
Maximum peak-to-trough decline of the equity curve, expressed as a decimal in [0, 1] (e.g., 0.20 = 20% drawdown). Lower values are better.
new MaximumDrawdownCriterion()// With explicit equity curve modenew MaximumDrawdownCriterion(EquityCurveMode.MARK_TO_MARKET, OpenPositionHandling.IGNORE)
MaximumAbsoluteDrawdownCriterion
Maximum drawdown in absolute currency units rather than as a percentage.
new MaximumAbsoluteDrawdownCriterion()
MaximumDrawdownBarLengthCriterion
Duration of the maximum drawdown period, expressed in bars.
new MaximumDrawdownBarLengthCriterion()
ReturnOverMaxDrawdownCriterion (RoMaD)
Net return divided by maximum drawdown. Higher is better — rewards strategies that earn more per unit of drawdown risk.
// Use the canonical location (not the deprecated alias)new org.ta4j.core.criteria.drawdown.ReturnOverMaxDrawdownCriterion()
org.ta4j.core.criteria.ReturnOverMaxDrawdownCriterion is deprecated since 0.19 and will be removed in 0.24.0. Use org.ta4j.core.criteria.drawdown.ReturnOverMaxDrawdownCriterion directly.
MonteCarloMaximumDrawdownCriterion
Monte Carlo simulation of the maximum drawdown by randomly permuting the order of closed positions. Useful for estimating worst-case drawdown risk.
new MonteCarloMaximumDrawdownCriterion(1000) // 1000 simulation runs
Trade count criteria
Count and classify positions in the trading record.
NumberOfPositionsCriterion
Total number of closed positions.
new NumberOfPositionsCriterion()
NumberOfWinningPositionsCriterion
Number of positions that closed with a net profit.
new NumberOfWinningPositionsCriterion()
NumberOfLosingPositionsCriterion
Number of positions that closed with a net loss.
new NumberOfLosingPositionsCriterion()
NumberOfBreakEvenPositionsCriterion
Number of positions that closed at exactly zero net profit/loss.
new NumberOfBreakEvenPositionsCriterion()
PositionsRatioCriterion
Ratio of a filtered position count to the total — for example, the win rate.
// Win rate: winning positions / total positionsnew PositionsRatioCriterion(AnalysisCriterion.PositionFilter.PROFIT)
NumberOfConsecutivePositionsCriterion
Maximum number of consecutive positions of the specified type (profit or loss).
new NumberOfConsecutivePositionsCriterion(AnalysisCriterion.PositionFilter.PROFIT)
Other criteria
InPositionPercentageCriterion
Fraction of total bars during which a position was open. Higher values indicate the strategy is more frequently invested.
new InPositionPercentageCriterion()
NumberOfBarsCriterion
Total number of bars covered by the trading record.
new NumberOfBarsCriterion()
PositionDurationCriterion
Average duration of closed positions, in bars.
new PositionDurationCriterion()
ExpectancyCriterion
Mathematical expectancy: (winRate × avgWin) - (lossRate × avgLoss). Positive values indicate a profitable edge on average.
new ExpectancyCriterion()
LinearTransactionCostCriterion
Total transaction costs assuming a linear (percentage-based) cost model.
new LinearTransactionCostCriterion(series.numFactory().numOf(0.001)) // 0.1% per trade
OpenPositionCostBasisCriterion
Cost basis of any currently open position (entry price × quantity, including costs).
new OpenPositionCostBasisCriterion()
OpenPositionUnrealizedProfitCriterion
Unrealized profit or loss of the current open position at the last bar’s close price.