TradingView strategy research

Momentum trading strategy: measurement, entry and decay

A momentum trading strategy tests whether past price direction continues after a trade begins. Time-series momentum measures an asset against its own history; cross-sectional momentum ranks assets against one another. The daily long-or-cash example below uses a 63-bar price return, enters after a completed positive signal, and exits after a nonpositive signal. It is a reproducible research baseline, not a proven edge.

See the decision guide

Time-series momentum and relative ranking

Moskowitz, Ooi, and Pedersen distinguish own-return momentum from momentum based on relative performance. Their research does not validate this page's shorter, long-only example. A momentum oscillator is a measurement; a strategy must also specify when to act, how much to hold, and when to exit.

  • If asset A returns -2%, B -5%, and C -9%, A ranks first. The zero-threshold time-series rule holds none of them. These invented returns demonstrate why the two methods cannot be substituted.
  • Relative strength here means performance ranking, not the RSI oscillator. A single chart strategy does not establish the performance of a ranked portfolio.
DecisionTime-series momentumCross-sectional momentum
ComparisonCurrent price versus this asset's earlier price.Returns across a predefined universe at the same decision time.
Example signalHold long when its 63-bar return exceeds zero.Buy the highest-ranked assets; a long-short version also sells the lowest-ranked assets.
All assets fallingA long-or-cash rule can hold cash.The highest-ranked asset can still be a loser in absolute terms.
Required dataOne price history and its adjustment settings.Synchronized histories, historical membership, delisted assets, weights, and a rebalance calendar.

A complete single-asset rulebook

Use one stock or unleveraged ETF on standard one-day candles. Define R(t) = 100 × (close(t) / close(t - 63) - 1). This is a price return in percent on the selected feed, not automatically a total or excess return. Record the symbol, session, corporate-action adjustments, and sample dates. The number 63 is a test setting, not an optimal horizon.

  • The 10% allocation limits initial exposure, not the loss of a trade or the future portfolio weight. Instrument quantity rounding and sufficient capital still matter.
  • Daily decisions are the baseline review schedule. Weekly decisions, fixed-weight rebalancing, protective stops, and short positions each change the experiment and need separate records.
  • No stop is intentional for isolating the signal, but it leaves overnight and intraday losses uncapped by a stop order. This example is not a complete live risk policy.
RuleBaseline definition
Warm-upRequire the current close and the close 63 bars earlier to be positive and available. With 63 as the lookback, the first eligible decision needs 64 bars.
Decision scheduleEvaluate each completed daily bar. Stay in cash while flat and R is zero or negative.
EntryWhen flat and R > 0, submit one market buy. Do not require a fresh zero crossing, so the first eligible positive observation can enter.
SizeUse 10% of strategy equity at entry, with 100% margin and no pyramiding. Keep the quantity unchanged while holding; do not rebalance it back to 10% daily.
ExitWhen holding and R <= 0, submit a market close. There is no profit target, intraday protective stop, or maximum holding period in this baseline.
ExecutionKeep on-close fills and intrabar recalculation disabled. Orders generated at the close normally fill at the next bar open in this simulation.
Missing measurementDo not enter; submit a close if already holding. A missing market bar still cannot provide an executable fill.

Pine Script for the daily baseline

Run this on standard 1D candles with the declared calculation settings. The script reads only the chart series and does not request other timeframes or rank symbols. The plotted return helps audit each decision. The 0.10% commission per order and two ticks of slippage are illustrative inputs to a cost scenario, not estimates for a particular broker.

  • The example starts trading as soon as history is sufficient and does not force liquidation on the last chart bar. Report open positions separately from completed trades.
  • For a held-out test, add an explicit start/end policy while retaining earlier bars for warm-up. Start flat at the chosen boundary, freeze the rules before that date, and document whether the end position is marked to market or liquidated on a later executable bar.
Pine v6 research example. Syntax validation does not establish profitability. Select standard candles manually; the timeframe guard checks the interval, not the chart construction.pine
//@version=6
strategy("Daily time-series momentum baseline", overlay = false,
     initial_capital = 100000, pyramiding = 0,
     default_qty_type = strategy.percent_of_equity, default_qty_value = 10,
     margin_long = 100, commission_type = strategy.commission.percent,
     commission_value = 0.10, slippage = 2,
     calc_on_every_tick = false, calc_on_order_fills = false,
     process_orders_on_close = false)

int lookback = input.int(63, "Lookback in daily bars", minval = 1)
if not timeframe.isdaily or timeframe.multiplier != 1
    runtime.error("Use a standard one-day candle chart.")

bool ready = not na(close[lookback]) and close[lookback] > 0 and close > 0
float momentum = ready ? 100.0 * (close / close[lookback] - 1.0) : na

if barstate.isconfirmed
    if ready and momentum > 0
        if strategy.position_size == 0
            strategy.entry("Long", strategy.long)
    else if strategy.position_size > 0
        strategy.close("Long")

plot(momentum, "Price return (%)", color = color.blue)
hline(0, "Zero", color = color.gray)

A reversal can lose money while momentum is positive

Consider a hypothetical path, not a historical result. At day t, the close is 110 and the close 63 bars earlier is 100, so R is +10%. The strategy is flat. The following observations are sufficient to audit the state changes; intermediate daily prices are omitted.

  • The signal compares price with a rolling reference, not with the entry fill. It therefore does not measure the open trade's profit.
  • Old observations leaving the window can change momentum even if the current price barely changes. Inspect both endpoints when a signal flips.
  • A fast rebound creates a different failure for a long-short ranked portfolio: former losers on the short side can rise sharply. Daniel and Moskowitz document momentum crash risk around rebounds after distressed market conditions. That finding is not a forecast of losses for this long-only script.
TimeKnown measurement or priceAction under the rules
Day t close110 / 100 - 1 = +10%.Submit a buy after the close; do not book a purchase at 110.
Day t + 1 openThe market opens at 111.Fill at 111 before the separate slippage assumption.
Day t + 5 closeClose 105; its own 63-bar reference close is 100. R = +5%.Continue holding despite the fall from the entry.
Day t + 10 closeClose 99; its own reference close is 100. R = -1%.Submit the exit after this close.
Day t + 11 openThe market opens at 97.Exit at 97 before slippage: (97 / 111 - 1) × 100 = -12.61% gross on the position.

Calculate costs before interpreting small gains

In a separate invented one-share trade, suppose the reference entry is $100 and exit is $101. With a $0.01 tick and two adverse ticks per fill, the executed prices are $100.02 and $100.98. Gross P&L becomes $0.96. Commission of 0.10% on each executed notional is $0.201, leaving $0.759 net, or about 0.759% of entry cost. This excludes taxes, financing, and any spread not already represented by the slippage assumption.

  • Use the actual tick size and applicable fee model. Fixed-tick slippage is a scenario, not a reconstruction of spreads, market impact, or order-book depth.
  • Near zero momentum, repeated entries and exits can accumulate costs while the asset makes little net progress. Count fills and turnover as well as closed trades.
  • Compare base and stressed costs on the same signals and dates. If adding a threshold buffer to reduce turnover, record it as a new rule and evaluate it on separate data.

Test horizon and decay without selecting the answer afterward

A longer lookback changes which past move the signal measures; a slower decision schedule changes how long a stale position can remain. Neither choice guarantees lower risk. Freeze a small experiment plan before viewing the final period and retain failed variants.

  • Export TradingView's List of trades CSV to Backtest Deep Report to inspect trade distributions and large losses. Keep chart equity, open trades, source, and settings alongside the export.
  • A completed-trade distribution cannot recover every intraday loss or prove that the signal was available at the claimed time. Check decision timestamps on the chart and during forward observation.
  • This page reports no performance run. The examples prove arithmetic and rule timing, not expected returns.
CheckKeep comparableWhat would weaken the hypothesis
Lookback sensitivityPreselect 42, 63, and 84 daily bars; keep costs, sizing, and evaluation dates identical.Only one isolated lookback works, especially after many unreported trials.
Decision frequencyCompare daily decisions with a separately coded weekly close schedule; retain the same return window.Apparent improvement comes from omitting bad trades or using a weekly close before it exists.
Untouched periodChoose rules on earlier dates, then start a separate evaluation with a declared boundary and warm-up policy.The later sample fails after costs or has too few trades to assess.
Reversal episodesInspect the worst trades and the delay between peak price, signal exit, and fill.A few reversals dominate losses while average trade statistics conceal their size.
Benchmark and exposureCompare with buy-and-hold using the same data and state the difference in invested capital and time in market.Raw net profit is mistaken for an exposure-adjusted comparison.
Where Pineify fits

Pine Script AI Coding Agent

Use the rulebook to draft or modify a single-asset Pine strategy, including an explicit test window or weekly decision schedule. Review the generated source, validate its syntax, and audit signal timestamps before comparing results.

Also useful: Backtest Deep Report. Import a TradingView trade-list CSV to examine outcome distributions and tail losses. It analyzes supplied trades; it does not turn raw OHLC data into a portfolio backtest or repair lookahead bias.

Build the momentum rulebook

Frequently asked questions

Educational strategy research, not investment advice. Rules and numerical examples are illustrative; no backtest performance is claimed. Trading can lose capital, and historical momentum research does not guarantee future returns or validate this script.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.