Trendline trading strategy: confirmed pivots and breaks

A trendline trading strategy turns selected price swings into a line, then uses a defined touch or break to trigger a trade. The line becomes usable only when its anchors are confirmed. Specify the pivot delay, minimum touches, tolerance, and order timing before testing; a line drawn neatly across past swings does not show when it was available to trade.

Build a trendline strategy

Key Takeaways

  • Two anchors define the line; a third touch is an optional strategy filter, not proof that support or resistance will hold.
  • Keep the anchor bar and its later confirmation bar as separate events.
  • Freeze an active line so a new anchor cannot rewrite earlier signals.
  • Review failed breaks and execution costs as well as successful examples.

Choose anchors before judging the chart

Rising support connects selected lows; falling resistance connects selected highs. Use wick extremes or closes consistently. For two anchors at bar positions b1 and b2 with prices p1 and p2, the arithmetic line at bar t is L(t) = p1 + (p2 - p1) × (t - b1) / (b2 - b1). This uses chart bars as the horizontal unit and price as the vertical unit. It does not measure elapsed clock time or percentage growth.

  • Choose one symbol, session, and timeframe. A line derived from hourly bars is not the same rule on a five-minute chart.
  • Record both anchor coordinates. TradingView drawing tools allow precise bar and price coordinates; Pine line objects also support evaluating a line beyond its endpoints.
  • Use an arithmetic price rule for the example below. A line fitted in logarithmic price space is a different model; changing the chart display alone does not change this formula.

An illustrative long breakout rule

This example buys a break above falling resistance. It is a hypothetical test specification, not a recommended setting or a measured result. Use standard OHLC bars, evaluate only completed bars, and allow one position at a time. A support bounce or a short break below support needs a separate test.

Fixed rules for a hypothetical trendline breakout test
DecisionRule
Pivot confirmationA pivot high must be strictly higher than the highs of two bars on either side. Reject ties. Confirm it at the close of the second right-hand bar.
Anchor selectionWhile collecting pivots, inspect each consecutive pair of confirmed highs. Accept the first pair at least five bars apart with the second high lower than the first. Do not search older pairs for a better fit.
Activation and toleranceSet epsilon to two minimum price ticks. At second-pivot confirmation, reject the pair if any close from the first anchor through that confirmation bar exceeds L(t) + epsilon. Otherwise activate and freeze the line.
Minimum touchesCount the two anchors as two contacts. Require one later bar, at least three bars after activation, whose high is within epsilon of L(t) and whose close is at or below L(t) + epsilon. Only then arm the setup.
Break and entryOn a bar after the third contact, require a close above L(t) + epsilon and the previous close at or below its own line value plus epsilon. Submit one long market order with a fixed quantity selected before testing.
CancellationA close above the upper boundary before arming cancels the setup. An untraded line expires 40 bars after activation; expiry takes precedence over a signal on that bar.
ExitKeep the original line. Close the long after a bar closes below L(t) - epsilon, or at the close of the tenth bar counting the entry-fill bar as bar one, whichever comes first. Submit a market exit; do not add to the position.
RestartRetire the line after cancellation, expiry, or the trade exit. Collect a fresh pair whose pivot bars occur after retirement. Never trade the same line twice.
  • Under default TradingView strategy timing, market orders fill on the next available tick, usually the next bar open. The break close is a signal price, not a promised fill.
  • This baseline has no intrabar protective stop or profit target. A close-based exit does not cap loss, and a gap can produce a worse fill. Test any added stop as a separate rule.
  • The two-tick tolerance is a reproducible example, not a universal noise filter. Test nearby tolerances without changing the definition after seeing each outcome.

A line can exist on the chart before it exists in the strategy

With two right-hand bars, a high on bar 20 cannot be confirmed until bar 22 closes. Drawing the finished line back to bar 20 does not make it available there. The hypothetical sequence below uses a tick size of 0.10, so epsilon is 0.20. Assume the intervening bars satisfy the pivot and activation rules; the table is a timing illustration, not market history or a backtest.

Hypothetical anchor, confirmation, contact, and order timeline
BarObserved eventInformation available then
10High of 110.00First pivot candidate only
12 closeTwo right-hand bars completedFirst anchor confirmed
20High of 106.00Second pivot candidate; no active line yet
22 closeSecond anchor confirmed; prior-close check passesActivate L(t) = 110 - 0.4 × (t - 10)
25 closeL(25) = 104.00; high 104.10; close 103.90Third contact qualifies; setup becomes armed
26 closeL(26) = 103.60; close 104.10 exceeds 103.80Confirmed break; submit the entry order
27 openNext available tick under default simulation timingEntry can fill at the available price, with modeled slippage

Rebuild the decision bar by bar

Keep a state record for collecting anchors, waiting for a third contact, waiting for a break, and holding a trade. On each completed bar, use only pivots whose confirmation time has arrived. Once a line is active, new pivots do not move it. Advance the state, save the line value and decision, then proceed to the next bar.

  • Log the original pivot bars, confirmation bars, line activation, third contact, signal, and fill separately.
  • Display the tradable line from activation onward. If you also show the segment between the old anchors, label it as historical geometry.
  • Do not credit pre-activation touches toward the third-contact rule or place orders on the original pivot bar.
  • Compare saved decisions before and after a chart reload. A historical drawing that changes without an equivalent recorded state change needs investigation.

Measure failed breaks without redefining them afterward

For this test, label a break as failed if the first close below the original line minus epsilon occurs within five bars after the signal. That is an analytical label, not a claim that every losing trade is a false break. Keep the same definition across all runs, including gaps and trades that have already exited.

  • Compare entry delay, failed-break count, trade count, average net trade, and drawdown across fixed parameter candidates. More touches or a wider tolerance can remove trades as well as delay them.
  • Include commissions and slippage, document spread treatment, and reserve an untouched date range before selecting parameters. Examine both trending and sideways periods.
  • Export the TradingView trade list to Backtest Deep Report to inspect trade outcomes and drawdowns. Keep the bar-by-bar log beside it: a trade CSV does not contain every pivot confirmation or line state, so the report alone cannot verify signal timing or classify all failed breaks.

Pineify next step

Build the rules with their confirmation times

Give Pine Script AI Coding Agent the pivot, contact, expiry, and exit specification, and request diagnostics for each state change. Verify those events in TradingView before exporting the trades to Backtest Deep Report for outcome analysis.

This page is educational and is not investment advice. The example settings and prices are hypothetical and have not been backtested for this page. Trading can lose money; close-based exits do not cap loss. Historical or simulated results do not guarantee future performance.

Frequently Asked Questions