Trend Following
Trend Following กลยุทธ์ตามเทรนด์ Moving Average Breakout ADX ATR Risk Management Backtesting หุ้น Forex Crypto
| Strategy | Entry Signal | Exit Signal | Win Rate | Avg R:R | Best Market |
|---|---|---|---|---|---|
| MA Crossover | MA50 > MA200 | MA50 < MA200 | 35-40% | 1:3 | Trending stocks |
| Donchian Breakout | Price > 20-day High | Price < 10-day Low | 30-35% | 1:4 | Futures, Forex |
| ADX + MA | ADX > 25 + Price > MA | ADX < 20 or Price < MA | 40-45% | 1:2.5 | All markets |
| Bollinger Squeeze | Band Squeeze + Breakout | Trailing Stop 2x ATR | 35-40% | 1:3 | Volatile markets |
| Turtle Trading | 55-day Breakout | 20-day Low | 30-35% | 1:5 | Diversified futures |
Technical Indicators
# === Trend Following Indicators ===
from dataclasses import dataclass
@dataclass
class Indicator:
name: str
formula: str
signal: str
setting: str
strength: str
weakness: str
indicators = [
Indicator("SMA (Simple Moving Average)",
"Average of closing prices over N periods",
"Price > SMA = Uptrend, Price < SMA = Downtrend",
"SMA 50, 100, 200 for long-term",
"Simple, reliable for strong trends",
"Lagging, whipsaw in sideways market"),
Indicator("EMA (Exponential Moving Average)",
"Weighted average, recent prices weigh more",
"EMA crossover: fast EMA > slow EMA = Buy",
"EMA 12, 26 (short), EMA 50, 200 (long)",
"Faster response than SMA",
"More false signals in choppy market"),
Indicator("ADX (Average Directional Index)",
"Measures trend strength (0-100)",
"ADX > 25 = Strong trend, < 20 = No trend",
"Period 14, threshold 25",
"Tells strength, not direction",
"Lagging, slow to signal trend start"),
Indicator("ATR (Average True Range)",
"Average of True Range over N periods",
"Higher ATR = More volatile, use for Stop Loss",
"Period 14, Stop = 2x ATR",
"Adapts to volatility automatically",
"Not directional, only measures volatility"),
Indicator("Donchian Channel",
"Highest High and Lowest Low over N periods",
"Break above upper = Buy, Break below lower = Sell",
"Entry: 20 days, Exit: 10 days",
"Simple breakout system, Turtle Trading",
"Late entry, gives back profits on exit"),
Indicator("MACD",
"EMA12 - EMA26, Signal = EMA9 of MACD",
"MACD > Signal = Bullish, MACD < Signal = Bearish",
"12, 26, 9 (default)",
"Trend + Momentum confirmation",
"Lagging in strong trends, false in sideways"),
]
print("=== Trend Indicators ===")
for i in indicators:
print(f" [{i.name}]")
print(f" Formula: {i.formula}")
print(f" Signal: {i.signal}")
print(f" Setting: {i.setting}")
print(f" +: {i.strength} | -: {i.weakness}")
Position Sizing
# === Risk Management Calculator ===
@dataclass
class TradeSetup:
asset: str
portfolio: float
risk_pct: float
entry: float
stop: float
atr: float
def calculate_position(t):
risk_amount = t.portfolio * (t.risk_pct / 100)
risk_per_unit = abs(t.entry - t.stop)
position_size = risk_amount / risk_per_unit
position_value = position_size * t.entry
atr_stop = t.entry - (2 * t.atr)
print(f" [{t.asset}]")
print(f" Portfolio: | Risk: {t.risk_pct}% = ")
print(f" Entry: | Stop: | ATR: ")
print(f" Risk/Unit: ")
print(f" Position Size: {position_size:.0f} units ()")
print(f" ATR Stop (2x): ")
return position_size
trades = [
TradeSetup("AAPL", 100000, 1.0, 180.0, 170.0, 3.5),
TradeSetup("EUR/USD", 100000, 1.0, 1.0850, 1.0750, 0.0060),
TradeSetup("BTC/USD", 100000, 1.0, 65000, 60000, 2500),
TradeSetup("Gold", 100000, 1.0, 2350, 2300, 25),
]
print("=== Position Sizing ===")
for t in trades:
calculate_position(t)
# Portfolio heat map
heat = {
"Max positions": "10-20 across different markets",
"Max risk per trade": "1-2% of portfolio",
"Max portfolio heat": "10-20% total open risk",
"Max correlation": "No more than 3 correlated positions",
"Max drawdown limit": "20% — reduce size at 15%",
}
print(f"\n\nRisk Rules:")
for k, v in heat.items():
print(f" [{k}]: {v}")
Backtesting
# === Backtest Metrics ===
@dataclass
class BacktestResult:
strategy: str
period: str
total_trades: int
win_rate: float
avg_win: float
avg_loss: float
max_drawdown: float
sharpe: float
cagr: float
results = [
BacktestResult("MA 50/200 Crossover", "2010-2024 S&P 500",
85, 38.0, 15.2, -4.8, -18.5, 0.85, 12.3),
BacktestResult("Donchian 20/10", "2010-2024 Futures",
120, 32.0, 18.5, -5.2, -22.0, 0.72, 10.8),
BacktestResult("ADX + EMA", "2010-2024 Forex",
200, 42.0, 8.5, -4.0, -15.0, 0.95, 14.2),
BacktestResult("Turtle Trading", "2010-2024 Diversified",
150, 30.0, 22.0, -6.0, -25.0, 0.65, 9.5),
]
print("=== Backtest Results ===")
for r in results:
print(f" [{r.strategy}] {r.period}")
print(f" Trades: {r.total_trades} | Win: {r.win_rate}%")
print(f" Avg Win: {r.avg_win}% | Avg Loss: {r.avg_loss}%")
print(f" MaxDD: {r.max_drawdown}% | Sharpe: {r.sharpe} | CAGR: {r.cagr}%")
เคล็ดลับ
- System: ทำตามระบบ ไม่ใช้อารมณ์ ขาดทุนบ่อยแต่กำไรมากเมื่อถูก
- Size: Position Sizing สำคัญที่สุด ไม่เสี่ยงเกิน 1-2% ต่อ Trade
- Diversify: กระจายหลายตลาด หลาย Asset ไม่กระจุกตัว
- Patience: Trend Following ต้องอดทน ผลลัพธ์เห็นระยะยาว
- Backtest: Backtest ก่อนใช้จริง ตรวจ Drawdown Sharpe Ratio
การนำความรู้ไปประยุกต์ใช้งานจริง
แหล่งเรียนรู้ที่แนะนำ ได้แก่ Official Documentation ที่อัพเดทล่าสุดเสมอ Online Course จาก Coursera Udemy edX ช่อง YouTube คุณภาพทั้งไทยและอังกฤษ และ Community อย่าง Discord Reddit Stack Overflow ที่ช่วยแลกเปลี่ยนประสบการณ์กับนักพัฒนาทั่วโลก
เปรียบเทียบข้อดีและข้อเสีย
จากตารางเปรียบเทียบจะเห็นว่าข้อดีมีมากกว่าข้อเสียอย่างชัดเจน โดยเฉพาะในแง่ของประสิทธิภาพและความสามารถในการ Scale สำหรับข้อเสียส่วนใหญ่สามารถแก้ไขได้ด้วยการเรียนรู้อย่างเป็นระบบและวางแผนทรัพยากรให้เหมาะสม
Trend Following คืออะไร
เทรดตามเทรนด์ ซื้อขาขึ้น ขายขาลง ไม่ทำนาย MA Breakout ADX Win Rate ต่ำ Risk Reward สูง หุ้น Forex Crypto Commodities
Indicator อะไรบ้าง
MA SMA EMA Golden Cross Death Cross ADX ความแรงเทรนด์ Donchian Channel Breakout MACD Signal ATR Volatility Bollinger Squeeze
Entry Exit ทำอย่างไร
Entry MA50 ตัด MA200 Donchian Breakout ADX 25 Exit Death Cross Donchian 10 วัน Trailing Stop 2x ATR Multi Timeframe Weekly Daily
Risk Management ทำอย่างไร
Position Sizing 1-2% Portfolio ATR Stop Loss กระจายตลาด Drawdown 20% Correlation Filter ทำตามระบบ ไม่ใช้อารมณ์
สรุป
Trend Following MA Breakout ADX ATR Donchian Position Sizing Risk Management Backtest Diversification หุ้น Forex Crypto Production
