Technical Analysis Stocks — คู่มือวิเคราะห์หุ้นทางเทคนิค 2026
Technical Analysis (TA) คือการวิเคราะห์หุ้นโดยใช้กราฟราคาและ indicators ทางสถิติ เพื่อคาดการณ์ทิศทางราคาในอนาคต แตกต่างจาก Fundamental Analysis ที่ดูงบการเงิน TA เชื่อว่าราคาสะท้อนทุกอย่างแล้ว (price discounts everything) และ patterns ในอดีตมีแนวโน้มเกิดซ้ำ การเรียนรู้ Technical Analysis เป็นทักษะสำคัญสำหรับนักลงทุนและนักเทรดทุกระดับ บทความนี้อธิบายหลักการ TA ครบ พร้อม indicators สำคัญและ Python tools สำหรับวิเคราะห์
หลักการพื้นฐาน Technical Analysis
# ta_basics.py — Technical Analysis fundamentals
import json
class TABasics:
PRINCIPLES = {
"price_discounts": {
"name": "Price Discounts Everything",
"description": "ราคาหุ้นสะท้อนทุกข้อมูลแล้ว — ข่าว, งบการเงิน, sentiment ทุกอย่าง",
},
"trends": {
"name": "Prices Move in Trends",
"description": "ราคาเคลื่อนที่เป็นแนวโน้ม (trend) — uptrend, downtrend, sideways",
},
"history_repeats": {
"name": "History Repeats Itself",
"description": "Patterns ในอดีตมีแนวโน้มเกิดซ้ำ — เพราะ human psychology ไม่เปลี่ยน",
},
}
CHART_TYPES = {
"candlestick": {
"name": "Candlestick Chart (แท่งเทียน)",
"description": "แสดง Open, High, Low, Close — อ่าน pattern ได้ง่าย",
"popular": True,
},
"line": {
"name": "Line Chart",
"description": "เส้นเชื่อมราคาปิด — ดูภาพรวม trend ง่าย",
"popular": False,
},
"bar": {
"name": "Bar Chart (OHLC)",
"description": "แสดง Open, High, Low, Close ด้วยแท่ง — คล้าย candlestick",
"popular": False,
},
}
TRENDS = {
"uptrend": "Higher Highs + Higher Lows — ราคาทำจุดสูงสุดและต่ำสุดที่สูงขึ้นเรื่อยๆ",
"downtrend": "Lower Highs + Lower Lows — ราคาทำจุดสูงสุดและต่ำสุดที่ต่ำลงเรื่อยๆ",
"sideways": "Range-bound — ราคาเคลื่อนที่อยู่ในกรอบ support/resistance",
}
def show_principles(self):
print("=== TA Principles ===\n")
for key, p in self.PRINCIPLES.items():
print(f"[{p['name']}]")
print(f" {p['description']}")
print()
def show_trends(self):
print("=== Trend Types ===")
for trend, desc in self.TRENDS.items():
print(f" [{trend}] {desc}")
basics = TABasics()
basics.show_principles()
basics.show_trends()
Indicators สำคัญ
# indicators.py — Essential technical indicators
import json
class TechnicalIndicators:
TREND = {
"sma": {
"name": "SMA (Simple Moving Average)",
"description": "ค่าเฉลี่ยราคาปิด N วัน — ดู trend direction",
"popular": "SMA 50, SMA 200 — Golden Cross (bullish) / Death Cross (bearish)",
"signal": "ราคา > SMA = bullish, ราคา < SMA = bearish",
},
"ema": {
"name": "EMA (Exponential Moving Average)",
"description": "ค่าเฉลี่ยถ่วงน้ำหนัก — ตอบสนองราคาล่าสุดเร็วกว่า SMA",
"popular": "EMA 12, EMA 26 (ใช้ใน MACD)",
"signal": "EMA สั้นตัด EMA ยาวขึ้น = buy, ตัดลง = sell",
},
"macd": {
"name": "MACD (Moving Average Convergence Divergence)",
"description": "ผลต่างของ EMA 12 - EMA 26 + Signal line (EMA 9 ของ MACD)",
"signal": "MACD ตัด Signal ขึ้น = buy, ตัดลง = sell, Divergence = reversal",
},
}
MOMENTUM = {
"rsi": {
"name": "RSI (Relative Strength Index)",
"description": "วัดความแรงของราคา 0-100 — Overbought/Oversold",
"signal": "RSI > 70 = Overbought (อาจลง), RSI < 30 = Oversold (อาจขึ้น)",
},
"stochastic": {
"name": "Stochastic Oscillator",
"description": "เปรียบเทียบราคาปิดกับ range ของ N วัน — %K และ %D lines",
"signal": "%K ตัด %D ขึ้นใน oversold zone = buy",
},
}
VOLUME = {
"obv": {
"name": "OBV (On-Balance Volume)",
"description": "สะสม volume — up day = +volume, down day = -volume",
"signal": "OBV rising + price rising = strong trend confirmation",
},
"vwap": {
"name": "VWAP (Volume Weighted Average Price)",
"description": "ราคาเฉลี่ยถ่วงน้ำหนักด้วย volume — benchmark สำหรับ intraday",
"signal": "ราคา > VWAP = bullish, ราคา < VWAP = bearish",
},
}
VOLATILITY = {
"bollinger": {
"name": "Bollinger Bands",
"description": "SMA 20 ± 2 Standard Deviations — วัด volatility",
"signal": "ราคาชน upper band = overbought, ชน lower band = oversold, squeeze = breakout coming",
},
"atr": {
"name": "ATR (Average True Range)",
"description": "วัด volatility เฉลี่ย — ใช้ตั้ง stop loss",
"signal": "ATR สูง = volatile, ATR ต่ำ = quiet market, Stop = 2x ATR",
},
}
def show_all(self):
categories = [
("Trend", self.TREND),
("Momentum", self.MOMENTUM),
("Volume", self.VOLUME),
("Volatility", self.VOLATILITY),
]
for cat_name, indicators in categories:
print(f"\n=== {cat_name} Indicators ===")
for key, ind in indicators.items():
print(f"\n[{ind['name']}]")
print(f" {ind['description']}")
print(f" Signal: {ind['signal']}")
indicators = TechnicalIndicators()
indicators.show_all()
Python Technical Analysis
# python_ta.py — Python technical analysis implementation
import json
class PythonTA:
CODE = """
# stock_analyzer.py — Technical analysis with Python
import pandas as pd
import numpy as np
class StockAnalyzer:
def __init__(self, data):
'''data: DataFrame with OHLCV columns'''
self.data = data.copy()
def sma(self, period=20):
return self.data['Close'].rolling(period).mean()
def ema(self, period=20):
return self.data['Close'].ewm(span=period, adjust=False).mean()
def rsi(self, period=14):
delta = self.data['Close'].diff()
gain = (delta.where(delta > 0, 0)).rolling(period).mean()
loss = (-delta.where(delta < 0, 0)).rolling(period).mean()
rs = gain / loss
return 100 - (100 / (1 + rs))
def macd(self, fast=12, slow=26, signal=9):
ema_fast = self.ema(fast)
ema_slow = self.ema(slow)
macd_line = ema_fast - ema_slow
signal_line = macd_line.ewm(span=signal, adjust=False).mean()
histogram = macd_line - signal_line
return macd_line, signal_line, histogram
def bollinger_bands(self, period=20, std_dev=2):
sma = self.sma(period)
std = self.data['Close'].rolling(period).std()
upper = sma + (std * std_dev)
lower = sma - (std * std_dev)
return upper, sma, lower
def atr(self, period=14):
high = self.data['High']
low = self.data['Low']
close = self.data['Close'].shift(1)
tr = pd.DataFrame({
'hl': high - low,
'hc': abs(high - close),
'lc': abs(low - close),
}).max(axis=1)
return tr.rolling(period).mean()
def support_resistance(self, window=20, num_levels=5):
'''Find support and resistance levels'''
highs = self.data['High'].rolling(window, center=True).max()
lows = self.data['Low'].rolling(window, center=True).min()
# Find pivot points
pivots_high = self.data['High'][self.data['High'] == highs].dropna()
pivots_low = self.data['Low'][self.data['Low'] == lows].dropna()
resistance = sorted(pivots_high.unique(), reverse=True)[:num_levels]
support = sorted(pivots_low.unique())[:num_levels]
return {'resistance': resistance, 'support': support}
def generate_signals(self):
'''Generate buy/sell signals'''
df = self.data.copy()
df['SMA_50'] = self.sma(50)
df['SMA_200'] = self.sma(200)
df['RSI'] = self.rsi(14)
macd_line, signal_line, _ = self.macd()
df['MACD'] = macd_line
df['Signal'] = signal_line
signals = []
# Golden Cross
if df['SMA_50'].iloc[-1] > df['SMA_200'].iloc[-1] and df['SMA_50'].iloc[-2] <= df['SMA_200'].iloc[-2]:
signals.append({'type': 'BUY', 'reason': 'Golden Cross (SMA 50 > SMA 200)'})
# Death Cross
if df['SMA_50'].iloc[-1] < df['SMA_200'].iloc[-1] and df['SMA_50'].iloc[-2] >= df['SMA_200'].iloc[-2]:
signals.append({'type': 'SELL', 'reason': 'Death Cross (SMA 50 < SMA 200)'})
# RSI Oversold
if df['RSI'].iloc[-1] < 30:
signals.append({'type': 'BUY', 'reason': f"RSI Oversold ({df['RSI'].iloc[-1]:.1f})"})
# RSI Overbought
if df['RSI'].iloc[-1] > 70:
signals.append({'type': 'SELL', 'reason': f"RSI Overbought ({df['RSI'].iloc[-1]:.1f})"})
# MACD Cross
if df['MACD'].iloc[-1] > df['Signal'].iloc[-1] and df['MACD'].iloc[-2] <= df['Signal'].iloc[-2]:
signals.append({'type': 'BUY', 'reason': 'MACD Bullish Crossover'})
return {
'current_price': round(df['Close'].iloc[-1], 2),
'sma_50': round(df['SMA_50'].iloc[-1], 2),
'sma_200': round(df['SMA_200'].iloc[-1], 2),
'rsi': round(df['RSI'].iloc[-1], 1),
'signals': signals if signals else [{'type': 'HOLD', 'reason': 'No clear signal'}],
}
# import yfinance as yf
# data = yf.download("AAPL", start="2023-01-01")
# analyzer = StockAnalyzer(data)
# signals = analyzer.generate_signals()
"""
def show_code(self):
print("=== Python TA ===")
print(self.CODE[:600])
ta = PythonTA()
ta.show_code()
Chart Patterns
# patterns.py — Common chart patterns
import json
class ChartPatterns:
REVERSAL = {
"head_shoulders": {
"name": "Head and Shoulders",
"type": "Bearish reversal",
"description": "3 peaks: left shoulder, head (สูงสุด), right shoulder — break neckline = sell",
},
"double_top": {
"name": "Double Top",
"type": "Bearish reversal",
"description": "ราคาขึ้นชน resistance 2 ครั้งแล้วลง — M shape",
},
"double_bottom": {
"name": "Double Bottom",
"type": "Bullish reversal",
"description": "ราคาลงชน support 2 ครั้งแล้วขึ้น — W shape",
},
}
CONTINUATION = {
"triangle": {
"name": "Triangle (Ascending/Descending/Symmetrical)",
"type": "Continuation",
"description": "ราคา converge เข้าหากัน → breakout ตาม trend เดิม",
},
"flag": {
"name": "Bull/Bear Flag",
"type": "Continuation",
"description": "Sharp move + consolidation (flag) → continue ทิศทางเดิม",
},
"cup_handle": {
"name": "Cup and Handle",
"type": "Bullish continuation",
"description": "U-shape (cup) + small consolidation (handle) → breakout up",
},
}
CANDLESTICK = {
"doji": "Doji — Open = Close (ตัดสินใจไม่ได้) → possible reversal",
"hammer": "Hammer — lower shadow ยาว, body เล็กบน → bullish reversal",
"engulfing": "Engulfing — แท่งใหม่กลืนแท่งเก่า → strong reversal signal",
"morning_star": "Morning Star — 3 แท่ง: bearish + doji + bullish → bullish reversal",
}
def show_patterns(self):
print("=== Reversal Patterns ===")
for key, p in self.REVERSAL.items():
print(f" [{p['name']}] {p['type']} — {p['description']}")
print(f"\n=== Continuation Patterns ===")
for key, p in self.CONTINUATION.items():
print(f" [{p['name']}] {p['type']} — {p['description']}")
print(f"\n=== Candlestick Patterns ===")
for name, desc in self.CANDLESTICK.items():
print(f" {desc}")
patterns = ChartPatterns()
patterns.show_patterns()
Trading Strategies
# strategies.py — Trading strategies using TA
import json
class TradingStrategies:
STRATEGIES = {
"trend_following": {
"name": "Trend Following",
"indicators": "SMA 50/200, MACD, ADX",
"entry": "Buy เมื่อ price > SMA 200 + MACD bullish + ADX > 25",
"exit": "Sell เมื่อ price < SMA 50 หรือ trailing stop 2x ATR",
"timeframe": "Daily, Weekly",
"best_for": "หุ้นที่มี strong trend — SET50, US large caps",
},
"mean_reversion": {
"name": "Mean Reversion",
"indicators": "RSI, Bollinger Bands, Stochastic",
"entry": "Buy เมื่อ RSI < 30 + price ชน lower Bollinger Band",
"exit": "Sell เมื่อ RSI > 50 หรือ price ถึง SMA 20",
"timeframe": "Daily",
"best_for": "หุ้นที่เคลื่อนที่ใน range — sideways markets",
},
"breakout": {
"name": "Breakout Trading",
"indicators": "Support/Resistance, Volume, Bollinger Squeeze",
"entry": "Buy เมื่อ price break resistance + volume spike",
"exit": "Stop loss ใต้ breakout level, target = previous range height",
"timeframe": "Daily, 4H",
"best_for": "หุ้นที่ consolidate นาน → break ออก",
},
"swing": {
"name": "Swing Trading",
"indicators": "EMA 9/21, RSI, Fibonacci retracement",
"entry": "Buy เมื่อ pullback ถึง EMA 21 + RSI > 40 ใน uptrend",
"exit": "Sell ที่ previous high หรือ Fibonacci extension",
"timeframe": "Daily, 4H",
"best_for": "จับ swings 3-10 วัน ใน trending markets",
},
}
def show_strategies(self):
print("=== Trading Strategies ===\n")
for key, s in self.STRATEGIES.items():
print(f"[{s['name']}]")
print(f" Indicators: {s['indicators']}")
print(f" Entry: {s['entry']}")
print(f" Best for: {s['best_for']}")
print()
strategies = TradingStrategies()
strategies.show_strategies()
การนำความรู้ไปประยุกต์ใช้งานจริง
แหล่งเรียนรู้ที่แนะนำ ได้แก่ Official Documentation ที่อัพเดทล่าสุดเสมอ Online Course จาก Coursera Udemy edX ช่อง YouTube คุณภาพทั้งไทยและอังกฤษ และ Community อย่าง Discord Reddit Stack Overflow ที่ช่วยแลกเปลี่ยนประสบการณ์กับนักพัฒนาทั่วโลก
FAQ - คำถามที่พบบ่อย
Q: Technical Analysis ใช้ได้จริงไหม?
A: ใช้ได้ — แต่ไม่ 100%: TA ให้ probability ไม่ใช่ certainty TA ดีสำหรับ: timing entry/exit, risk management, identifying trends TA ไม่ดีสำหรับ: predict exact price, fundamental events (earnings, news) Best practice: ใช้ TA + FA ร่วมกัน — FA เลือกหุ้น, TA เลือกจังหวะ สำคัญ: risk management สำคัญกว่า indicators — ใช้ stop loss เสมอ
Q: เริ่มเรียน TA ควรเรียนอะไรก่อน?
A: ลำดับแนะนำ: 1) อ่านกราฟ candlestick + trend lines 2) Support/Resistance 3) Moving Averages (SMA/EMA) 4) RSI + MACD 5) Volume analysis 6) Chart patterns 7) Risk management + position sizing ใช้เวลา: 3-6 เดือนเรียน + 6 เดือน paper trading ก่อนใช้เงินจริง
Q: Indicator ตัวไหนดีที่สุด?
A: ไม่มี indicator ที่ดีที่สุด — แต่ละตัวเหมาะกับสถานการณ์ต่างกัน Trending market: Moving Averages, MACD, ADX Range-bound: RSI, Stochastic, Bollinger Bands Breakout: Volume, ATR, Bollinger Squeeze แนะนำ: ใช้ 2-3 indicators ร่วมกัน (ไม่เกิน) — ใช้มากไป = analysis paralysis
Q: TA ใช้กับหุ้นไทย (SET) ได้ไหม?
A: ได้ — TA ใช้ได้กับทุกตลาดที่มีสภาพคล่อง SET50: สภาพคล่องดี TA ทำงานดี หุ้นเล็ก (mai): สภาพคล่องต่ำ — TA อาจไม่แม่นเท่า เพราะ volume น้อย Timeframe: Daily chart เหมาะสำหรับ SET, Weekly สำหรับ long-term Tools: TradingView (ฟรี), Settrade Streaming (มี TA tools), Python + yfinance
