Skip to content
GetProfitable
Search

Translating a chart pattern into rules

Lesson 10 · about 11 min

Chart patterns are the hardest thing to backtest, because the pattern lives in the eye of the person drawing it. Two traders will draw a different "flag" on the same chart and be equally sure they are right. The way to test a pattern is to replace the drawing with a definition that a spreadsheet can evaluate, accept that the definition will not match your eye on every chart, and then see whether the defined version has any edge. This lesson walks through that translation for a bull flag.

Step 1: describe what the eye sees

A bull flag, as most people draw it: a sharp move up (the pole), then a few bars of sideways-to-slightly-down drift on lower volume (the flag), then a break above the flag's upper edge (the trigger). The trade is long on the break, stop below the flag, target roughly the height of the pole.

Every phrase in that description needs a number.

Step 2: assign a measurement to each phrase

Phrase Measurement Chosen definition
"Sharp move up" Percent gain over N bars, relative to volatility Close-to-close gain over 5 bars ≥ 4 × ATR(14)
"The pole" Those N bars The 5-bar window that satisfies the above
"A few bars" Bar count 3 to 8 bars after the pole ends
"Sideways-to-slightly-down drift" Range of the flag relative to the pole Flag high − flag low ≤ 40% of pole height; flag low ≥ pole low + 50% of pole height
"Lower volume" Average volume comparison Mean flag volume < 70% of mean pole volume
"Break above the flag's upper edge" Price crosses a level Buy stop one tick above the highest high of the flag bars
"Stop below the flag" Level One tick below the lowest low of the flag bars
"Target ≈ pole height" Distance Limit at entry + (pole high − pole low)

Every number in the right-hand column is a choice. Each one is a parameter, and Module 6 will explain why too many of them is dangerous. For now, pick values that match what your eye already does, write them down, and resist the urge to tune them.

Step 3: write the rules in order

  1. Pole detection. On bar D, compute gain = close(D) − close(D−5). If gain ≥ 4 × ATR(14) through D, mark D as a pole end; pole height = high over D−5 to D minus low over D−5 to D.
  2. Flag window. For bars D+1 through D+8, compute the running flag high and flag low. The flag is valid on any bar D+k with 3 ≤ k ≤ 8 where flag range ≤ 0.4 × pole height, flag low ≥ pole low + 0.5 × pole height, and mean volume of D+1 through D+k is < 0.7 × mean volume of D−5 through D.
  3. Trigger. On the first valid flag bar, place a buy stop at flag high + 1 tick, valid for the next bar only. If the flag remains valid on the next bar, re-place the order with the updated flag high.
  4. Stop. Flag low − 1 tick.
  5. Target. Entry + pole height.
  6. Time stop. Exit at the close of the 15th bar after entry.
  7. Precedence. Stop before target on a bar touching both.
  8. Sizing. 1% of account ÷ (entry − stop), capped at 25% of account.
  9. Filter. Long only; close on D above the 50-day moving average.

Step 4: check it against your eye

Run the rules on a year of data for one instrument and mark every trade on the chart. Then mark the flags you would have drawn by hand. Three things will be true:

  • Some of your hand-drawn flags will not be detected (the pole was 3.5 ATR, not 4).
  • Some detected flags will look ugly to you (the definition is satisfied but the shape is wrong).
  • The overlap will be somewhere around half to two thirds.

This is normal and not a failure. The question is not whether the rules match your eye; it is whether the rules have an edge. If they do, you have a testable strategy. If the rules have no edge but your eye "would have" done better, you are back to a discretionary strategy and the veto log from the previous lesson.

Key idea: Translating a pattern into rules means replacing every adjective with a measurement. The result will disagree with your eye on some charts. That is the price of being able to test it at all.

A worked signal

Bar Close High Low Volume Note
D−5 50.0 50.4 49.6 1.0M
D 54.2 54.5 53.8 1.6M Gain 4.2; ATR 1.0; pole valid. Pole height 54.5 − 49.6 = 4.9
D+1 53.9 54.3 53.5 0.8M Flag range 0.8 (≤ 1.96 OK); flag low 53.5 ≥ 52.05 OK
D+2 53.6 54.0 53.3 0.7M Range 1.0 OK; volume mean 0.75M < 0.91M OK
D+3 53.8 54.1 53.4 0.6M k = 3, valid; buy stop at 54.31 for D+4
D+4 54.9 55.0 53.7 1.2M Filled at 54.31 (+ slippage). Stop 53.29. Target 54.31 + 4.9 = 59.21

Risk per share is 54.31 − 53.29 = 1.02. Target is 4.9 away: 4.8R planned. Whether it gets there is what the backtest measures.

Try it: Pick any pattern you trade by eye. Write the table from Step 2 for it: every phrase, the measurement, and your chosen number. Count the parameters. If there are more than about six, look for phrases that can share a definition or be dropped.

Recap

  • Patterns are testable only after every descriptive phrase becomes a measurement.
  • Each measurement is a parameter; choose values that match your eye and do not tune them yet.
  • Write the rules in execution order with explicit order types, levels and precedence.
  • Expect the rules to match your hand-drawn patterns only partly; that is normal.
  • The test is whether the defined version has an edge, not whether it looks right.

See it drawn

Original diagrams for the ideas on this page. Illustrative, not real market data.

The spread of outcomes behind an expectancyA histogram of forty trades: a tall block of small losses on the left, a low spread of larger wins on the right, and a line marking the average outcome.NUMBER OF TRADES051024 LOSSES, AVG −$20016 WINS, AVG +$600EXPECTANCY +$120−$400−$200$0+$200+$400+$600+$800PROFIT OR LOSS PER TRADEexpectancy = (40% × $600) − (60% × $200) = +$120 per trade
Expectancy: the average trade. Forty trades sorted by outcome: 24 small losses and 16 larger wins. Weighting each side by how often it happens gives the average result per trade, marked here by the dashed line at +$120.
Risk and reward on one tradeA price scale showing an entry with a stop two points below and a target six points above, so the reward band is three times the risk band.PRICETARGET 106.00ENTRY 100.00STOP 98.00REWARDRISK6.00 pointsthree times the risk2.00 pointsthe most you loserisk : reward = 1 : 3
Risk and reward on one trade. One trade on a price scale: the entry sits 2.00 points above the stop and 6.00 points below the target, so the shaded reward band is three times the risk band. The ratio compares what is lost if the stop is hit with what is gained if the target is reached.
Bull flagA steep rise, a small channel that drifts slightly lower, then a second rise out of the channel.pricetime1. the pole2. the flag3. the continuation
The bull flag. A sharp advance (the pole) followed by a small channel that drifts gently lower (the flag); here the advance then resumes out of the channel. A bear flag is the same shape upside down: a fast drop, then a slow drift higher.

Finished this module? Take the module quiz.