SiamCafe.net Blog
Technology

trend following

trend following
trend following | SiamCafe Blog
2025-06-05· อ. บอม — SiamCafe.net· 8,861 คำ

Trend Following

Trend Following กลยุทธ์ตามเทรนด์ Moving Average Breakout ADX ATR Risk Management Backtesting หุ้น Forex Crypto

StrategyEntry SignalExit SignalWin RateAvg R:RBest Market
MA CrossoverMA50 > MA200MA50 < MA20035-40%1:3Trending stocks
Donchian BreakoutPrice > 20-day HighPrice < 10-day Low30-35%1:4Futures, Forex
ADX + MAADX > 25 + Price > MAADX < 20 or Price < MA40-45%1:2.5All markets
Bollinger SqueezeBand Squeeze + BreakoutTrailing Stop 2x ATR35-40%1:3Volatile markets
Turtle Trading55-day Breakout20-day Low30-35%1:5Diversified 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}%")

เคล็ดลับ

การนำความรู้ไปประยุกต์ใช้งานจริง

แหล่งเรียนรู้ที่แนะนำ ได้แก่ Official Documentation ที่อัพเดทล่าสุดเสมอ Online Course จาก Coursera Udemy edX ช่อง YouTube คุณภาพทั้งไทยและอังกฤษ และ Community อย่าง Discord Reddit Stack Overflow ที่ช่วยแลกเปลี่ยนประสบการณ์กับนักพัฒนาทั่วโลก

เปรียบเทียบข้อดีและข้อเสีย

ข้อดีข้อเสีย
ประสิทธิภาพสูง ทำงานได้เร็วและแม่นยำ ลดเวลาทำงานซ้ำซ้อนต้องใช้เวลาเรียนรู้เบื้องต้นพอสมควร มี Learning Curve สูง
มี Community ขนาดใหญ่ มีคนช่วยเหลือและแหล่งเรียนรู้มากมายบางฟีเจอร์อาจยังไม่เสถียร หรือมีการเปลี่ยนแปลงบ่อยในเวอร์ชันใหม่
รองรับ Integration กับเครื่องมือและบริการอื่นได้หลากหลายต้นทุนอาจสูงสำหรับ Enterprise License หรือ Cloud Service
เป็น Open Source หรือมีเวอร์ชันฟรีให้เริ่มต้นใช้งานต้องการ Hardware หรือ Infrastructure ที่เพียงพอ

จากตารางเปรียบเทียบจะเห็นว่าข้อดีมีมากกว่าข้อเสียอย่างชัดเจน โดยเฉพาะในแง่ของประสิทธิภาพและความสามารถในการ 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

📖 บทความที่เกี่ยวข้อง

trend following ebookอ่านบทความ → indicator trend followingอ่านบทความ → trend following là gìอ่านบทความ → trend following pdf tiếng việtอ่านบทความ → the ultimate trend following guide pdfอ่านบทความ →

📚 ดูบทความทั้งหมด →