Complete "Lesson 3: Key Indicators — Moving Averages, RSI, and MACD" first to unlock this lesson.Go to previous lesson

Introduction

Support and resistance are the foundation of technical analysis. Support is a price level where buying pressure tends to stop a decline, while resistance is a level where selling pressure tends to stop a rise. These levels are not exact lines — they are zones where price reacts. A trend is the overall direction of price movement, and identifying it correctly helps traders align with the market rather than against it.

Mapping Support and Resistance Levels

To draw support and resistance on a chart, look for areas where price has reversed direction multiple times. The more times price touches a level and bounces, the stronger that level becomes. Use historical swing highs for resistance and swing lows for support. On higher timeframes like the daily or 4-hour chart, these levels carry more weight than on lower timeframes.

python
import pandas as pd
# Load OHLCV data from CSV (columns: timestamp, open, high, low, close, volume)
df = pd.read_csv('btc_usdt_1h.csv', parse_dates=['timestamp'])
# Find swing highs: a candle whose high is higher than the 5 candles before and after
window = 5
df['swing_high'] = df['high'].rolling(window=window*2+1, center=True).apply(
lambda x: x[window] == x.max(), raw=True
)
# Find swing lows: a candle whose low is lower than the 5 candles before and after
df['swing_low'] = df['low'].rolling(window=window*2+1, center=True).apply(
lambda x: x[window] == x.min(), raw=True
)
# Print detected levels
resistance_levels = df[df['swing_high'] == 1][['timestamp', 'high']].tail(10)
support_levels = df[df['swing_low'] == 1][['timestamp', 'low']].tail(10)
print("Recent Resistance Levels:")
print(resistance_levels)
print("\nRecent Support Levels:")
print(support_levels)

The code above scans price data for swing points. Swing highs become candidates for resistance zones, and swing lows become candidates for support zones. A trader can then plot these values on a chart.

diagram showing price chart with horizontal support line below price bounces and horizontal resistance line above price rejections

Identifying Market Structure

Market structure describes how price behaves over time. An uptrend is defined by a sequence of higher highs and higher lows. A downtrend is defined by lower highs and lower lows. A sideways or ranging market shows price moving between roughly parallel support and resistance without a clear directional bias. The first time market structure breaks — for example, an uptrend producing a lower low — it is often called a structure break or trend reversal signal.

python
def detect_trend(df, lookback=20):
"""Classify the latest trend based on swing points."""
recent = df.tail(lookback)
highs = recent[recent['swing_high'] == 1]['high'].tolist()
lows = recent[recent['swing_low'] == 1]['low'].tolist()
if len(highs) < 2 or len(lows) < 2:
return "Insufficient data"
higher_highs = all(highs[i] > highs[i-1] for i in range(1, len(highs)))
higher_lows = all(lows[i] > lows[i-1] for i in range(1, len(lows)))
lower_highs = all(highs[i] < highs[i-1] for i in range(1, len(highs)))
lower_lows = all(lows[i] < lows[i-1] for i in range(1, len(lows)))
if higher_highs and higher_lows:
return "Uptrend"
elif lower_highs and lower_lows:
return "Downtrend"
else:
return "Sideways / Ranging"
trend = detect_trend(df)
print(f"Current market structure: {trend}")

This function checks whether recent swing highs and lows are consistently rising, consistently falling, or mixed. The output tells the trader whether to look for long setups, short setups, or wait for a breakout.

flowchart showing three-branch decision: higher highs and higher lows leads to Uptrend, lower highs and lower lows leads to Downtrend, mixed pattern leads to Sideways

Using Support and Resistance in Trade Planning

Once levels are mapped and the trend is identified, combine the two. In an uptrend, look for long entries near support. In a downtrend, look for short entries near resistance. A breakout above resistance in an uptrend confirms continuation, while a breakdown below support in a downtrend signals further downside. Always place stop-loss orders just beyond the support or resistance level so that a clean break invalidates the trade idea.

python
def plan_trade(entry_price, stop_loss, take_profit):
risk = entry_price - stop_loss
reward = take_profit - entry_price
rr_ratio = reward / risk if risk > 0 else None
return {
"risk_per_unit": round(risk, 2),
"reward_per_unit": round(reward, 2),
"risk_reward_ratio": round(rr_ratio, 2) if rr_ratio else None
}
# Example: long trade at support level with stop just below
trade = plan_trade(entry_price=60000, stop_loss=59500, take_profit=61500)
print(trade)

The output shows the risk-reward ratio for the planned trade. A ratio above 2.0 is generally considered favorable in crypto markets due to their volatility.

Common Mistakes

Traders often draw too many support and resistance lines, cluttering the chart and causing confusion. Focus on the most obvious levels that price has respected multiple times. Another mistake is assuming a level will hold forever — broken support often becomes new resistance, and broken resistance often becomes new support. This role reversal is a key concept.

Summary

Support and resistance are zones where price reacts, drawn from swing highs and lows. Market structure is defined by the sequence of these swings — uptrend, downtrend, or sideways. Combining level mapping with trend identification gives traders a clear framework for planning entries, exits, and stop-loss placement.

Lesson practice

Lesson Checkpoint

Review what you learned and get feedback on your work.

0/1
Answered · 0/1