SiamCafe.net Blog
Technology

the ultimate guide to trend following pdf

the ultimate guide to trend following pdf
the ultimate guide to trend following pdf | SiamCafe Blog
2025-11-17· อ. บอม — SiamCafe.net· 1,582 คำ

The Ultimate Guide to Trend Following — คู่มือเทรดตาม Trend ฉบับสมบูรณ์

Trend Following เป็นกลยุทธ์การเทรดที่เก่าแก่และพิสูจน์แล้วว่าทำกำไรได้จริงในระยะยาว หลักการคือ เข้าซื้อเมื่อราคาเริ่มขึ้น (uptrend) และขายเมื่อราคาเริ่มลง (downtrend) โดยไม่พยายามทำนายจุดสูงสุดหรือต่ำสุด นักเทรดชื่อดังหลายคนเช่น Richard Dennis (Turtle Traders), Ed Seykota และ John W. Henry ใช้ trend following สร้างความมั่งคั่ง บทความนี้สรุปหลักการสำคัญจาก trend following guides พร้อม Python tools สำหรับพัฒนา trading systems

Trend Following Fundamentals

# trend_basics.py — Trend following fundamentals
import json

class TrendFollowingBasics:
    PRINCIPLES = {
        "follow_dont_predict": {
            "name": "Follow, Don't Predict",
            "description": "ไม่ทำนายทิศทาง — รอให้ trend เกิดแล้วค่อยเข้า",
            "quote": "The trend is your friend until it ends.",
        },
        "cut_losses": {
            "name": "Cut Losses Short",
            "description": "ตัดขาดทุนเร็ว — ใช้ stop loss ทุกครั้ง ไม่ถือ losing position",
            "rule": "ขาดทุนไม่เกิน 1-2% ของพอร์ตต่อ trade",
        },
        "let_profits_run": {
            "name": "Let Profits Run",
            "description": "ปล่อยให้กำไรวิ่ง — ไม่รีบปิด winning position",
            "rule": "ใช้ trailing stop แทน fixed target — จับ trend ให้ยาว",
        },
        "risk_management": {
            "name": "Risk Management",
            "description": "จัดการความเสี่ยงก่อนกำไร — position sizing สำคัญที่สุด",
            "rule": "Risk per trade = 1-2% ของทุน, diversify หลายตลาด",
        },
        "systematic": {
            "name": "Systematic & Disciplined",
            "description": "ใช้ระบบ rules-based — ไม่เทรดตามอารมณ์",
            "rule": "เขียน trading plan → ทำตาม plan → review → ปรับปรุง",
        },
    }

    FAMOUS_TRADERS = {
        "richard_dennis": {
            "name": "Richard Dennis (Turtle Traders)",
            "return": "สร้าง $200M จาก $400 — สอน Turtle Trading rules",
        },
        "ed_seykota": {
            "name": "Ed Seykota",
            "return": "250,000% return ใน 16 ปี — pioneer ของ computerized trading",
        },
        "john_henry": {
            "name": "John W. Henry",
            "return": "เจ้าของ Boston Red Sox — สร้างความมั่งคั่งจาก trend following",
        },
        "bill_dunn": {
            "name": "Bill Dunn (Dunn Capital)",
            "return": "50+ ปีใน trend following — ผ่านทุกวิกฤต",
        },
    }

    def show_principles(self):
        print("=== Trend Following Principles ===\n")
        for key, p in self.PRINCIPLES.items():
            print(f"[{p['name']}]")
            print(f"  {p['description']}")
            print(f"  Rule: {p['rule']}" if 'rule' in p else f"  \"{p['quote']}\"")
            print()

    def show_traders(self):
        print("=== Famous Trend Followers ===")
        for key, trader in self.FAMOUS_TRADERS.items():
            print(f"  [{trader['name']}] {trader['return']}")

basics = TrendFollowingBasics()
basics.show_principles()
basics.show_traders()

Trend Detection Methods

# detection.py — Trend detection methods
import json

class TrendDetection:
    METHODS = {
        "moving_average": {
            "name": "Moving Average Crossover",
            "description": "เมื่อ fast MA ตัดขึ้นเหนือ slow MA = uptrend signal",
            "common_pairs": "EMA 20/50, EMA 50/200, SMA 10/30",
            "entry": "Fast MA > Slow MA → Buy",
            "exit": "Fast MA < Slow MA → Sell",
        },
        "donchian": {
            "name": "Donchian Channel Breakout",
            "description": "ราคาทะลุ high สูงสุดใน N วัน = uptrend (Turtle Trading system)",
            "common_settings": "20-day breakout entry, 10-day breakout exit",
            "entry": "Price > 20-day high → Buy",
            "exit": "Price < 10-day low → Sell",
        },
        "atr_trailing": {
            "name": "ATR Trailing Stop",
            "description": "ใช้ ATR (Average True Range) กำหนด trailing stop distance",
            "common_settings": "3x ATR trailing stop",
            "entry": "ใช้ร่วมกับ breakout/MA signal",
            "exit": "Price ลงมาถึง trailing stop → exit",
        },
        "adx": {
            "name": "ADX (Average Directional Index)",
            "description": "วัดความแรงของ trend — ADX > 25 = trending, < 20 = ranging",
            "entry": "ADX > 25 + DI+ > DI- → Buy (strong uptrend)",
            "exit": "ADX < 20 หรือ DI+ < DI-",
        },
    }

    def show_methods(self):
        print("=== Trend Detection Methods ===\n")
        for key, method in self.METHODS.items():
            print(f"[{method['name']}]")
            print(f"  {method['description']}")
            print(f"  Entry: {method['entry']}")
            print(f"  Exit: {method['exit']}")
            print()

detection = TrendDetection()
detection.show_methods()

Python Trend Following System

# system.py — Python trend following system
import json

class TrendSystem:
    CODE = """
# trend_following.py — Complete trend following system
import pandas as pd
import numpy as np

class TrendFollowingSystem:
    def __init__(self, capital=100000, risk_per_trade=0.02):
        self.capital = capital
        self.risk_per_trade = risk_per_trade
        self.positions = {}
    
    def calculate_atr(self, df, period=20):
        '''Calculate Average True Range'''
        high = df['high']
        low = df['low']
        close = df['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 donchian_channel(self, df, entry_period=20, exit_period=10):
        '''Donchian Channel (Turtle Trading)'''
        df['entry_high'] = df['high'].rolling(entry_period).max()
        df['entry_low'] = df['low'].rolling(entry_period).min()
        df['exit_high'] = df['high'].rolling(exit_period).max()
        df['exit_low'] = df['low'].rolling(exit_period).min()
        return df
    
    def position_size(self, atr_value):
        '''Calculate position size based on ATR'''
        risk_amount = self.capital * self.risk_per_trade
        dollar_risk = 2 * atr_value  # 2 ATR stop
        
        if dollar_risk == 0:
            return 0
        
        units = int(risk_amount / dollar_risk)
        return max(units, 0)
    
    def generate_signals(self, df):
        '''Generate trend following signals'''
        df = self.donchian_channel(df.copy())
        df['atr'] = self.calculate_atr(df)
        df['ema_50'] = df['close'].ewm(span=50).mean()
        df['ema_200'] = df['close'].ewm(span=200).mean()
        
        signals = []
        position = 0  # 0=flat, 1=long, -1=short
        entry_price = 0
        stop_loss = 0
        
        for i in range(200, len(df)):
            row = df.iloc[i]
            prev = df.iloc[i-1]
            
            if position == 0:
                # Long entry: breakout above 20-day high + EMA filter
                if row['close'] > prev['entry_high'] and row['ema_50'] > row['ema_200']:
                    position = 1
                    entry_price = row['close']
                    stop_loss = entry_price - 2 * row['atr']
                    size = self.position_size(row['atr'])
                    signals.append({
                        'date': df.index[i],
                        'action': 'BUY',
                        'price': entry_price,
                        'stop_loss': round(stop_loss, 2),
                        'size': size,
                        'atr': round(row['atr'], 2),
                    })
                
                # Short entry: breakout below 20-day low
                elif row['close'] < prev['entry_low'] and row['ema_50'] < row['ema_200']:
                    position = -1
                    entry_price = row['close']
                    stop_loss = entry_price + 2 * row['atr']
                    size = self.position_size(row['atr'])
                    signals.append({
                        'date': df.index[i],
                        'action': 'SELL_SHORT',
                        'price': entry_price,
                        'stop_loss': round(stop_loss, 2),
                        'size': size,
                    })
            
            elif position == 1:
                # Trailing stop: update stop loss
                new_stop = row['close'] - 2 * row['atr']
                stop_loss = max(stop_loss, new_stop)
                
                # Exit long
                if row['close'] < stop_loss or row['close'] < prev['exit_low']:
                    pnl = (row['close'] - entry_price) / entry_price * 100
                    signals.append({
                        'date': df.index[i],
                        'action': 'SELL',
                        'price': row['close'],
                        'pnl_pct': round(pnl, 2),
                    })
                    position = 0
            
            elif position == -1:
                new_stop = row['close'] + 2 * row['atr']
                stop_loss = min(stop_loss, new_stop)
                
                if row['close'] > stop_loss or row['close'] > prev['exit_high']:
                    pnl = (entry_price - row['close']) / entry_price * 100
                    signals.append({
                        'date': df.index[i],
                        'action': 'COVER',
                        'price': row['close'],
                        'pnl_pct': round(pnl, 2),
                    })
                    position = 0
        
        return signals

# import yfinance as yf
# data = yf.download("AAPL", period="2y")
# system = TrendFollowingSystem(capital=100000)
# signals = system.generate_signals(data)
"""

    def show_code(self):
        print("=== Trend Following System ===")
        print(self.CODE[:600])

system = TrendSystem()
system.show_code()

Risk Management & Position Sizing

# risk.py — Risk management for trend following
import json

class RiskManagement:
    RULES = {
        "percent_risk": {
            "name": "1-2% Rule",
            "description": "ขาดทุนไม่เกิน 1-2% ของทุนต่อ trade",
            "example": "ทุน 100,000 → risk ต่อ trade = 1,000-2,000 บาท",
        },
        "position_sizing": {
            "name": "ATR-Based Position Sizing",
            "description": "ขนาด position ตาม volatility — หุ้น volatile ซื้อน้อย",
            "formula": "Units = (Capital × Risk%) / (N × ATR)",
        },
        "correlation": {
            "name": "Correlation Risk",
            "description": "ไม่ถือ positions ที่ correlate กันเยอะเกินไป",
            "rule": "Max 4 units ใน market เดียว, max 10 units ใน correlated markets",
        },
        "max_drawdown": {
            "name": "Max Drawdown Limit",
            "description": "หยุดเทรดถ้า drawdown เกินกำหนด",
            "rule": "Drawdown > 20% → ลด position size ลงครึ่ง, > 30% → หยุดเทรด",
        },
    }

    TURTLE_SIZING = """
# Turtle Trading Position Sizing
# N = 20-day ATR
# Dollar Volatility = N × Point Value
# Unit Size = (1% of Capital) / Dollar Volatility

# Example:
# Capital = $1,000,000
# Crude Oil N = $1.20
# Point Value = $1,000 (per contract)
# Dollar Volatility = $1.20 × $1,000 = $1,200
# Unit Size = ($1,000,000 × 0.01) / $1,200 = 8 contracts

# Max positions:
# Single market: 4 units
# Closely correlated: 6 units
# Loosely correlated: 10 units
# Single direction: 12 units
"""

    def show_rules(self):
        print("=== Risk Management Rules ===\n")
        for key, rule in self.RULES.items():
            print(f"[{rule['name']}]")
            print(f"  {rule['description']}")
            if 'formula' in rule:
                print(f"  Formula: {rule['formula']}")
            elif 'rule' in rule:
                print(f"  Rule: {rule['rule']}")
            print()

    def show_turtle(self):
        print("=== Turtle Position Sizing ===")
        print(self.TURTLE_SIZING[:400])

risk = RiskManagement()
risk.show_rules()
risk.show_turtle()

Backtesting & Performance

# backtest.py — Backtesting trend following
import json
import random

class Backtesting:
    METRICS = {
        "total_return": "ผลตอบแทนรวม — กำไร/ขาดทุนทั้งหมด",
        "cagr": "CAGR (Compound Annual Growth Rate) — ผลตอบแทนต่อปี",
        "max_drawdown": "Max Drawdown — ขาดทุนสูงสุดจากจุดสูงสุด",
        "sharpe_ratio": "Sharpe Ratio — ผลตอบแทนเทียบกับความเสี่ยง (> 1.0 = ดี)",
        "win_rate": "Win Rate — % ของ trades ที่กำไร (trend following: 30-40%)",
        "profit_factor": "Profit Factor — กำไรรวม / ขาดทุนรวม (> 1.5 = ดี)",
        "avg_win_loss": "Average Win / Average Loss — trend following: 3:1 ขึ้นไป",
    }

    CHARACTERISTICS = [
        "Win rate ต่ำ (30-40%) แต่ average win >> average loss",
        "Drawdown ยาว — อาจขาดทุนต่อเนื่อง 6-12 เดือน ก่อนจับ big trend",
        "กำไรส่วนใหญ่มาจาก trades ไม่กี่ตัว — fat tail distribution",
        "ทำกำไรดีในตลาด trending — ขาดทุนในตลาด sideways/choppy",
        "ต้องมี discipline สูง — อดทนต่อ losing streaks",
    ]

    def show_metrics(self):
        print("=== Performance Metrics ===\n")
        for metric, desc in self.METRICS.items():
            print(f"  [{metric}] {desc}")

    def show_characteristics(self):
        print(f"\n=== Trend Following Characteristics ===")
        for c in self.CHARACTERISTICS:
            print(f"  • {c}")

    def sample_results(self):
        print(f"\n=== Sample Backtest Results (10 years) ===")
        print(f"  CAGR: {random.uniform(8, 18):.1f}%")
        print(f"  Max Drawdown: -{random.uniform(15, 35):.1f}%")
        print(f"  Sharpe Ratio: {random.uniform(0.6, 1.5):.2f}")
        print(f"  Win Rate: {random.uniform(30, 42):.1f}%")
        print(f"  Profit Factor: {random.uniform(1.3, 2.5):.2f}")
        print(f"  Avg Win/Loss Ratio: {random.uniform(2.5, 5.0):.1f}:1")
        print(f"  Total Trades: {random.randint(200, 600)}")

bt = Backtesting()
bt.show_metrics()
bt.show_characteristics()
bt.sample_results()

FAQ - คำถามที่พบบ่อย

Q: Trend following ยังใช้ได้ในปี 2026 ไหม?

A: ใช้ได้ — trend following ทำกำไรมาตลอด 100+ ปี เพราะ markets มี trends เสมอ (เศรษฐกิจ, เทคโนโลยี, วัฏจักร) ปี 2022-2023: commodity trend followers ทำกำไรมหาศาลจาก inflation trends ข้อควรรู้: มีช่วง drawdown ยาว (sideways markets) — ต้องอดทน ปรับปรุง: ใช้ multi-market diversification + modern risk management

Q: Win rate 30-40% ไม่ต่ำเกินไปหรือ?

A: ไม่ — trend following ไม่ได้ชนะบ่อย แต่ชนะเยอะ ตัวอย่าง: ขาดทุน 7 ใน 10 trades (loss เฉลี่ย 1%) แต่กำไร 3 trades (กำไรเฉลี่ย 10%) ผลรวม: -7% + 30% = +23% กุญแจ: Average Win ต้อง >> Average Loss (ratio 3:1 ขึ้นไป) ต้องมี discipline: อย่าตัดกำไรเร็ว อย่าถือขาดทุนนาน

Q: Trend following เหมาะกับตลาดไหน?

A: เหมาะที่สุด: Commodities (น้ำมัน, ทอง, เกษตร) — trends ยาวและชัด ดี: Forex (major pairs) — trends ตาม economic cycles ใช้ได้: หุ้น (index + large cap) — ต้อง filter ด้วย market regime ท้าทาย: Crypto — volatile มาก, trend เร็วและสั้น, ต้องปรับ parameters แนะนำ: diversify หลายตลาด — ลด drawdown, เพิ่ม opportunity

Q: เริ่มต้นด้วยทุนเท่าไหร่?

A: ขึ้นกับตลาด: Forex: 10,000-50,000 บาท (micro lots, leverage) หุ้นไทย: 50,000-100,000 บาท (ซื้อได้หลายตัว, diversify) Futures: 500,000+ บาท (margin requirements สูง) สำคัญ: ทุนต้องเพียงพอสำหรับ diversification + withstand drawdowns เริ่มจาก: Paper trading 3-6 เดือน → เริ่มด้วยทุนน้อย → ค่อยเพิ่มเมื่อมั่นใจ

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

the ultimate trend following guide pdfอ่านบทความ → trend following ebooktrend following algorithmอ่านบทความ → the trend following bible pdfอ่านบทความ →

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