Support and resistance trading uses price levels where a market previously turned or paused as reference points for entries, exits or stops. To automate or backtest it, each level needs a reproducible definition, such as a confirmed pivot, the prior day's high or low, a round-number grid or a pivot-point formula. The rule must also define a touch, a break and when the level became known.

Support and resistance levels at a glance
Scroll horizontally to read every column.
| Level type | Reproducible definition | Known when |
|---|---|---|
| Confirmed pivot | A high with a set number of lower highs on each side, or a low with higher lows. | After the right-hand bars close. |
| Prior-day high or low | The completed previous day's high or low. | When the new day starts. |
| Round number | A multiple of a chosen price step. | In advance. |
| Pivot point | P = (previous high + previous low + previous close) ÷ 3. | When the new period starts. |
| Hand-drawn line | A chart drawing placed by a person. | Only when drawn; a Pine script cannot read it. |
Support and resistance is a price-action idea, so the definitions above belong to a strategy specification rather than to one indicator. The trading strategy library places level-based rules beside the other rule families. A breakout rule trades a level being passed; a mean-reversion rule trades a move away from a reference returning.
How do you define a support or resistance level objectively?
“Price bounced off support” hides at least five decisions. Write each one down before coding anything.
- The level: which definition produces the price, with every parameter named.
- Line or zone: a single price, or a band of stated width around it.
- Touch: whether a wick reaching the level counts, or only a close within the zone.
- Break: a close beyond the level or beyond the whole zone, evaluated on a closed bar.
- Expiry: when a level stops being used, for example after a break or a stated number of bars.
TradingView's Pivot Points High Low indicator defines pivots by the number of bars with lower highs, or higher lows, on either side.[1] In Pine Script v6, ta.pivothigh(source, leftbars, rightbars) and ta.pivotlow return the pivot price, or NaN when there is no pivot.[2] A pivot with five right-hand bars is only knowable five bars later. TradingView warns that plotting it back on the pivot bar misrepresents when it was available.[3]
The pivot confirmation guide works through that delay bar by bar.
Worked example: prior-day, pivot-point and round-number levels
Illustrative EURUSD prices, not a recommendation. The completed previous day has high 1.1070, low 1.0950 and close 1.1040. The current price is 1.1037.
- Prior-day levels: resistance reference 1.1070; support reference 1.0950.
- Pivot point: P = (1.1070 + 1.0950 + 1.1040) ÷ 3 = 3.3060 ÷ 3 = 1.1020. TradingView's Pivot Points Standard documents this formula for its traditional type.[5]
- Round-number grid with a 0.0050 step: 1.1037 ÷ 0.0050 = 220.74. Rounding down gives 220 × 0.0050 = 1.1000 below; the next level above is 1.1050.
Now apply two break definitions to the prior-day high of 1.1070. The previous bar closed at 1.1068 and the current bar closes at 1.1074.
- Line break: previous close ≤ 1.1070 and current close > 1.1070. The condition is true.
- Zone break with a ±0.0005 zone: the zone is 1.1065 to 1.1075. A break needs a close above 1.1075, so 1.1074 is not a break.
The same bar passes one rule and fails the other. Neither answer is more correct; they are different strategies and must be tested separately.
When does each level become known?

A rule may use a level only once the level exists. Each definition has a different availability time:
-
Prior-day levels: TradingView's multi-timeframe documentation shows that a higher-timeframe request with
barmerge.lookahead_onshould offset the series by one bar, such ashigh[1]. Without the offset, historical bars display final values before they were available.[4] The request.security lookahead guide covers the trap in detail. - Daily data versus intraday data: TradingView notes that intraday and daily data on many symbols come from separate feeds with different OHLC values. Its Pivot Points Standard offers a daily-based setting for that reason.[5] Record which data set defines “prior day”.
- Pivots: known only after the right-hand bars close.[3]
- Round numbers: fixed by the step, independent of history.
Why do hand-drawn levels not backtest?
TradingView's Pine documentation says chart drawings made with the drawing tools are unrelated to Pine visuals, and that Pine scripts cannot interact with them.[7] A Pine strategy therefore cannot read a line you drew, and the Strategy Tester has nothing to replay. TradingView's strategy reports come from Pine strategy scripts that simulate trades on historical bars.[8]
Hand-drawn levels also carry hindsight. A line placed today on last month's chart uses turns that were not known last month. Converting it into a pivot, prior-period or round-number definition removes both problems at once.
Drawing alerts still have a live use. TradingView lets you set an alert when a series crosses a horizontal line.[6] The rectangle alert conditions and Fibonacci drawing alerts guides explain those drawing-based conditions. They trigger on live data but provide no rule history to evaluate.
How can a level rule be written in Pine Script?
Illustrative sketch; not compiled or tested. The level and event illustrate the definitions above, not a recommended strategy.
//@version=6
indicator("Prior-day high cross", overlay = true)
[pdh, pdl] = request.security(syminfo.tickerid, "D", [high[1], low[1]], lookahead = barmerge.lookahead_on)
newDay = pdh != pdh[1]
levelCross = ta.crossover(close, pdh)
event = barstate.isconfirmed and not newDay and levelCross
plot(pdh, "Prior-day high")
plot(pdl, "Prior-day low")
alertcondition(event, "Close crossed above prior-day high", "Closed-bar cross above prior-day high")
ta.crossover compares both series on the current and previous bars.[13] On the first bar of a new day the level itself moves, so a “crossing” can appear without price crossing anything. The sketch skips any bar where the level changed. Your specification may treat that bar differently, but it must say how. The crossing is computed on its own line because Pine v6 evaluates and lazily.[14]
alertcondition() only exposes the event; you create the running TradingView alert and choose its frequency.[9] For pivot levels, use the value on the detection bar, not a plot offset into the past.
How does a level event reach an MT5 order?
A level break needs an action specification: direction, broker symbol, volume, stop and target, and what a second break does. Test it on a demo account first, and choose your own symbol, size and rules. PineConnector's setup test separates message processing from the broker trade.[10]
- Condition: the level rule is true on the closed bar.
- Alert: the TradingView alert triggers; check its log.
- Delivery: the webhook carries the message.
- Processing: match it in PineConnector Portal → Bridge.
- EA request: confirm whether an order request was submitted.
- Broker outcome: check acceptance, the deal or deals and the position.
MetaQuotes treats orders, deals and positions as separate records.[11] A stop placed just beyond a support level exists at the broker only if the message sends it; a chart-side exit rule is not a broker stop. TradingView and MT5 can also show different prices for the same level.[12] A level defined on the TradingView feed may not match the broker's quote, so compare both on demo. The stop-loss placement methods guide covers structure-based stops.
What goes wrong with support and resistance rules?
- Choosing levels after the fact. Levels that look obvious on a finished chart were often unknowable in real time.
- Backdating pivots. A pivot plotted on its origin bar was detected later.[3]
- Leaking the current day. A daily request without the one-bar offset shows the final high before it existed.[4]
- Leaving touch and break undefined. Wick, close and zone versions of “break” select different bars.
- Tuning zone widths and lookbacks on the same history. TradingView describes out-of-sample testing as a way to reduce overfitting.[8]
A level that many traders watch is still only a definition. A precise rule makes the idea testable; it does not show that the rule has an edge.
Frequently asked questions
How do you trade support and resistance with rules?
Define each level with a reproducible method, such as a confirmed pivot, the prior day's high or low, or a round-number grid. Then state whether the level is a line or a zone and what counts as a touch, a break or an expiry. Evaluate the conditions on closed bars and test them before any live use.
Can support and resistance be automated?
Yes, when every level comes from a formula a script can calculate from price history. Pivots, prior-period highs and lows, pivot points and round numbers qualify. Hand-drawn lines do not, because Pine scripts cannot interact with chart drawings. Automation executes the defined rule; it does not make that rule profitable.
What is the difference between a TradingView drawing alert and a script condition?
A drawing alert watches a line or shape placed on one chart and triggers on live data when its condition is met. A script condition calculates its level from price history, so the same rule can be replayed on past bars in a strategy. Only the script version can be backtested in TradingView's Strategy Tester.
Why does a prior-day high differ between charts?
Intraday and daily data can come from separate feeds with different highs, lows and closes, as TradingView notes for its pivot-point indicator. Sessions and extended hours can also change which trades count. TradingView and a MetaTrader 5 broker may use different quotes altogether. Record which data set defines the prior day.
Reviewed 25 September 2026. Facts were checked against the linked sources on that date. Nothing in this article was tested on a trading account and no code was compiled.
Related reading
- Trading strategy library
- Breakout trading rules
- SMC and ICT concepts as testable rules
- Pivot confirmation and repainting
- TradingView rectangle alerts
Sources
- TradingView – Pivot Points High Low, accessed 25 September 2026.
- TradingView – Pine Script v6 reference: ta.pivothigh, accessed 25 September 2026.
- TradingView – Repainting: plotting in the past, accessed 25 September 2026.
- TradingView – Other timeframes and data, accessed 25 September 2026.
- TradingView – Pivot Points Standard, accessed 25 September 2026.
- TradingView – Horizontal line drawing tool, accessed 25 September 2026.
- TradingView – Visuals: overview, accessed 25 September 2026.
- TradingView – Strategies, accessed 25 September 2026.
- TradingView – Alerts, accessed 25 September 2026.
- PineConnector – Test your setup, accessed 25 September 2026.
- MetaQuotes – Basic principles: orders, deals and positions, accessed 25 September 2026.
- PineConnector – Frequently asked questions: price differences, accessed 25 September 2026.
- TradingView – Pine Script v6 reference: ta.crossover, accessed 25 September 2026.
- TradingView – Migrating to Pine Script v6: lazy evaluation of conditions, accessed 25 September 2026.
PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.