เข้าสู่ระบบสมัครสมาชิก
หน้าแรกHome / บทความฟรีFree articles / ทดสอบระบบและเทรดแบบมืออาชีพTesting & trading like a pro
ทดสอบระบบและเทรดแบบมืออาชีพTesting & trading like a proขั้นสูงAdvancedอ่าน 4 นาที4 min read6 / 13 ในหมวดนี้6 of 13 in this section

การจำลอง Monte Carlo สำหรับระบบเทรดMonte Carlo Simulation for Trading Systems

สลับลำดับไม้และสุ่มผลซ้ำหลายพันรอบ เพื่อดูว่า drawdown และการแพ้ติดกันที่ "ปกติ" ของระบบอาจหนักกว่าที่เห็นใน backtest แค่ไหนReshuffle and resample your trades thousands of times to see how much worse normal drawdowns and losing streaks could be than the single backtest shows.

กราฟ XAUUSD ประกอบหมวด ทดสอบระบบและเทรดแบบมืออาชีพ / Testing & trading like a pro
ในบทความนี้ · 6
  1. แนวคิดพื้นฐาน
  2. โอกาสแพ้ติดกัน
  3. ทำ Monte Carlo ด้วยสเปรดชีต
  4. ใช้ผลอย่างไร
  5. จุดอ่อน / ข้อผิดพลาดที่พบบ่อย
  6. สรุป
In this article · 6
  1. The basic idea
  2. The odds of losing streaks
  3. Monte Carlo in a spreadsheet
  4. Using the results
  5. Weaknesses / common mistakes
  6. Summary

ผล backtest หนึ่งครั้งคือ "เส้นทางเดียว" ที่ระบบบังเอิญเดินผ่านในอดีต ถ้าไม้ชุดเดิมเกิดในลำดับต่างออกไป กำไรรวมอาจเท่าเดิม แต่ drawdown และการแพ้ติดกันอาจแย่กว่ามาก การจำลอง Monte Carlo (Monte Carlo simulation) คือการสร้างเส้นทางที่เป็นไปได้หลายพันเส้นจากข้อมูลไม้ที่มี เพื่อดูภาพกว้างของความเสี่ยง ไม่ใช่แค่เส้นเดียวที่เกิดขึ้น

แนวคิดพื้นฐาน

สมมติเรามีผลไม้ 200 ไม้จาก backtest แต่ละไม้เป็นตัวเลขเช่น +2R, −1R, +0.5R การจำลองทำได้หลายแบบ

  1. สลับลำดับ (Reshuffle) เอาไม้ทั้ง 200 ไม้มาเรียงใหม่แบบสุ่ม กำไรรวมเท่าเดิมทุกครั้ง แต่ drawdown เปลี่ยน เหมาะกับการดูว่าลำดับที่แย่จะเจ็บแค่ไหน
  2. สุ่มหยิบแบบใส่คืน (Resample / Bootstrap) สุ่มหยิบไม้จากชุดเดิม 200 ครั้ง โดยไม้เดิมถูกหยิบซ้ำได้ ทำให้ทั้งกำไรรวมและ drawdown เปลี่ยน เห็นทั้งกรณีดีและแย่
  3. ใส่ความแย่เพิ่ม เช่น สุ่มข้ามไม้ 10% (จำลองการพลาดสัญญาณ) หรือหักสลิปเพจเพิ่มทุกไม้ เพื่อดูว่าระบบยังรอดไหม

ทำซ้ำหลายพันรอบ แล้วดูการกระจายของผล เช่น drawdown ที่ 95% ของรอบไม่เกินค่าเท่าไหร่ (เปอร์เซ็นไทล์ที่ 95)

ดูภาพด้านล่าง

200 ไม้ชุดเดียวกัน สลับลำดับ 5 รอบ (สมมติ)Same 200 trades, 5 reshuffles (hypothetical)
0R20R40Rทุนเริ่มต้นStartรอบ 1 (สมมติ)Run 1 (hypo.)รอบ 2 (สมมติ)Run 2 (hypo.)รอบ 3 (สมมติ)Run 3 (hypo.)รอบ 4 (สมมติ)Run 4 (hypo.)รอบ 5 (สมมติ)Run 5 (hypo.)ไม้ที่ 0 ถึง 200 (ทีละ 20)Trades 0 to 200 (every 20)
สมมติ: ชนะ 40% ไม้ละ +2R แพ้ 60% ไม้ละ −1R จบ +40R ทุกเส้น แต่ทางเจ็บต่างกันมากHypothetical: 40% at +2R, 60% at −1R; all end +40R, the pain differs
🧮 ไม้ชุดเดียวกัน คนละลำดับ

สมมติมี 10 ไม้: ชนะ 4 ไม้ไม้ละ +2R แพ้ 6 ไม้ไม้ละ −1R ผลรวม = 4 × 2 − 6 × 1 = +2R ไม่ว่าเรียงแบบไหน ลำดับ A ชนะ แพ้ ชนะ แพ้ ชนะ แพ้ ชนะ แพ้ แพ้ แพ้ ทุนสะสม: +2, +1, +3, +2, +4, +3, +5, +4, +3, +2 จุดสูงสุด +5 ลงไปต่ำสุด +2 = drawdown 3R ลำดับ B แพ้ 6 ไม้ติดก่อน แล้วชนะ 4 ไม้ ทุนสะสม: −1, −2, −3, −4, −5, −6, −4, −2, 0, +2 = drawdown 6R ถ้าบัญชี $5,000 เสี่ยง 1% ($50) ต่อ 1R: ลำดับ A เจ็บ $150 (3%) ลำดับ B เจ็บ $300 (6%) ผลสุดท้ายเท่ากัน แต่ความเจ็บต่างกันสองเท่า

10 ไม้เดียวกัน คนละลำดับ (สมมติ)Same 10 trades, two orders (hypothetical)
-5R0R5Rทุนเริ่มต้นStartลำดับ A DD 3ROrder A, DD 3Rลำดับ B DD 6ROrder B, DD 6Rไม้ที่ 0 ถึง 10Trade 0 to 10
สมมติ: จบ +2R เท่ากัน แต่ B เจ็บ $300 ส่วน A เจ็บ $150Hypothetical: both end +2R; B hurts $300, A only $150

โอกาสแพ้ติดกัน

คณิตศาสตร์ง่าย ๆ ช่วยตั้งความคาดหวังได้ สมมติระบบมีอัตราแพ้ 60% (ชนะ 40%) และแต่ละไม้ไม่เกี่ยวกัน โอกาสที่ไม้ 8 ไม้ที่กำหนดไว้แพ้ติดกันทั้งหมด = 0.6 ยกกำลัง 8 ≈ 0.0168 หรือประมาณ 1.7%

ฟังดูน้อย แต่นั่นคือโอกาสสำหรับ "ช่วง 8 ไม้ช่วงเดียว" ถ้าเทรดหลายร้อยไม้ จะมีช่วง 8 ไม้ให้เกิดได้หลายร้อยช่วง ทำให้โอกาสเจอแพ้ 8 ไม้ติดสักครั้งสูงขึ้นมาก นี่คือสิ่งที่ Monte Carlo แสดงให้เห็นเป็นตัวเลขได้ชัดกว่าการเดา

โอกาสเจอแพ้ 8 ไม้ติดสักครั้ง (แพ้ 60%)Chance of an 8-loss streak somewhere (60% losses)
8 ไม้ที่กำหนดOne set of 8 trades1.7%ตลอด 100 ไม้Within 100 trades49%ตลอด 200 ไม้Within 200 trades75%ตลอด 500 ไม้Within 500 trades97.1%
คำนวณโดยสมมติว่าแต่ละไม้ไม่เกี่ยวกันCalculated assuming trades are independent

ถ้าเสี่ยง 2% ต่อไม้ แพ้ 8 ไม้ติด ทุนจะเหลือ 0.98 ยกกำลัง 8 ≈ 0.851 หรือลดลงประมาณ 14.9% ดูเรื่องนี้เพิ่มที่ การแพ้ติดกัน และ Risk of Ruin

เสี่ยง 2% ต่อไม้ แพ้ 8 ไม้ติดRisking 2% per trade through 8 losses
85%90%95%100%ทุนเริ่มต้นStarting balanceทุนที่เหลือAccount leftจำนวนไม้ที่แพ้ติดกันLosses in a row
0.98 ยกกำลัง 8 ≈ 0.851 ทุนหายราว 14.9%0.98 to the power 8 ≈ 0.851, about 14.9% gone

ทำ Monte Carlo ด้วยสเปรดชีต

ไม่ต้องเขียนโปรแกรมก็ทำได้

  1. วางผลไม้ทั้งหมด (หน่วย R) ในคอลัมน์ A
  2. คอลัมน์ B ใส่สูตรสุ่ม เช่น =RAND()
  3. เรียงข้อมูลตามคอลัมน์ B จะได้ลำดับใหม่
  4. คอลัมน์ C คำนวณทุนสะสม คอลัมน์ D คำนวณระยะจากจุดสูงสุดก่อนหน้า หาค่าต่ำสุดคือ drawdown ของรอบนั้น
  5. ทำซ้ำหลายสิบรอบด้วยมือ หรือใช้ตารางข้อมูล (Data table) ให้คำนวณหลายร้อยรอบ

ถ้าเขียนโปรแกรมได้ ภาษาอย่าง Python ทำได้หลายหมื่นรอบในไม่กี่วินาที

Monte Carlo ในสเปรดชีตMonte Carlo in a spreadsheet
1คอลัมน์ A ผลทุกไม้เป็นหน่วย RColumn A: every trade result in R2คอลัมน์ B ใส่ =RAND()Column B: =RAND()3เรียงตามคอลัมน์ B ได้ลำดับใหม่Sort by column B for a new order4C ทุนสะสม D ระยะจากจุดสูงสุดC running total, D distance from peak5ค่าต่ำสุดของ D คือ DD รอบนั้นLowest D = that run's drawdown6ทำซ้ำหลายร้อยรอบ ดูกรณีแย่Repeat hundreds of times, study bad cases

ใช้ผลอย่างไร

  • ตั้งความเสี่ยงต่อไม้ ถ้า drawdown ที่เปอร์เซ็นไทล์ 95 คือ 20R และเรายอมรับ drawdown ได้ไม่เกิน 10% ของพอร์ต ความเสี่ยงต่อไม้ไม่ควรเกิน 10% ÷ 20 = 0.5%
  • ตั้งเกณฑ์หยุดระบบ ถ้า drawdown จริงเกินกรอบที่ Monte Carlo บอกว่าแทบไม่เกิด ให้หยุดทบทวน
  • บัญชีกองทุน ดูว่าโอกาสชนขีดขาดทุนรายวันหรือขาดทุนรวมสูงแค่ไหน ลองตัวเลขกับ เครื่องคำนวณ Prop
DD กรณีแย่ 20R เป็นกี่ % ของพอร์ตA 20R bad-case drawdown as % of account
เสี่ยง 0.5% ต่อไม้Risk 0.5% per trade10%เสี่ยง 1% ต่อไม้Risk 1% per trade20%เสี่ยง 2% ต่อไม้Risk 2% per trade40%
ยอมรับ DD ได้ 10% → เสี่ยงไม่เกิน 10% ÷ 20 = 0.5%Accept 10% DD → risk at most 10% ÷ 20 = 0.5%

จุดอ่อน / ข้อผิดพลาดที่พบบ่อย

  • ขยะเข้า ขยะออก ถ้าข้อมูลไม้มาจาก backtest ที่ overfit หรือไม่รวมต้นทุน การสุ่มกี่หมื่นรอบก็ได้ผลที่หลอกตาเหมือนเดิม
  • สมมติว่าแต่ละไม้ไม่เกี่ยวกัน ในความจริงไม้แพ้มักมาเป็นกลุ่มเมื่อตลาดเปลี่ยนสภาพ การสลับแบบสุ่มอาจทำให้ความเสี่ยงดูน้อยกว่าจริง
  • ไม่มีเหตุการณ์ที่ไม่เคยเกิด Monte Carlo สร้างได้แค่จากไม้ที่มี ถ้าไม่เคยเจอกราฟกระโดดข้ามจุด (Gap) ใหญ่ในข้อมูล การจำลองก็จะไม่มี
  • ดูแต่ค่ากลาง ประโยชน์จริงอยู่ที่กรณีแย่ (เปอร์เซ็นไทล์ 95 หรือ 99) ไม่ใช่ค่าเฉลี่ย
  • ตัวอย่างตั้งต้นน้อย ไม้ 30 ไม้มาสุ่มหมื่นรอบ ไม่ได้ทำให้ข้อมูลมากขึ้นจริง

สรุป

  • backtest หนึ่งครั้งคือเส้นทางเดียว Monte Carlo แสดงเส้นทางที่เป็นไปได้อีกหลายพันเส้น
  • ไม้ชุดเดียวกันต่างลำดับ ให้ drawdown ต่างกันได้มาก
  • ใช้ผลกรณีแย่ (เปอร์เซ็นไทล์ 95 ขึ้นไป) กำหนดความเสี่ยงต่อไม้และเกณฑ์หยุดระบบ
  • ทำได้ด้วยสเปรดชีตธรรมดา
  • ผลดีได้แค่เท่ากับคุณภาพข้อมูลไม้ที่ใส่เข้าไป

A single backtest is one path the system happened to take through history. Had the same trades arrived in a different order, the total profit could be identical while the drawdown and losing streaks were far worse. Monte Carlo simulation builds thousands of possible paths from the trades you have, so you see the range of risk rather than one lucky or unlucky line.

The basic idea

Say you have 200 trades from a backtest, each a number like +2R, −1R or +0.5R. There are several ways to simulate.

  1. Reshuffle. Put all 200 trades in a random order. Total profit is always the same, but drawdown changes. Good for seeing how much a bad sequence can hurt.
  2. Resample (bootstrap). Randomly draw 200 trades from the set, allowing the same trade to be drawn more than once. Both total profit and drawdown vary, showing good and bad cases.
  3. Add stress. Randomly skip 10% of trades (missed signals) or deduct extra slippage from every trade, and see whether the system still survives.

Repeat thousands of times and study the distribution, e.g. the drawdown that 95% of runs stay within (the 95th percentile).

See the chart below.

200 ไม้ชุดเดียวกัน สลับลำดับ 5 รอบ (สมมติ)Same 200 trades, 5 reshuffles (hypothetical)
0R20R40Rทุนเริ่มต้นStartรอบ 1 (สมมติ)Run 1 (hypo.)รอบ 2 (สมมติ)Run 2 (hypo.)รอบ 3 (สมมติ)Run 3 (hypo.)รอบ 4 (สมมติ)Run 4 (hypo.)รอบ 5 (สมมติ)Run 5 (hypo.)ไม้ที่ 0 ถึง 200 (ทีละ 20)Trades 0 to 200 (every 20)
สมมติ: ชนะ 40% ไม้ละ +2R แพ้ 60% ไม้ละ −1R จบ +40R ทุกเส้น แต่ทางเจ็บต่างกันมากHypothetical: 40% at +2R, 60% at −1R; all end +40R, the pain differs
🧮 Same trades, different order

Take 10 trades: 4 winners of +2R and 6 losers of −1R. Total = 4 × 2 − 6 × 1 = +2R whatever the order. Order A: win, loss, win, loss, win, loss, win, loss, loss, loss. Running total: +2, +1, +3, +2, +4, +3, +5, +4, +3, +2. Peak +5, low after it +2 = drawdown 3R. Order B: six losses first, then four wins. Running total: −1, −2, −3, −4, −5, −6, −4, −2, 0, +2 = drawdown 6R. On a $5,000 account risking 1% ($50) per R: order A hurts $150 (3%), order B hurts $300 (6%). Same final result, twice the pain.

10 ไม้เดียวกัน คนละลำดับ (สมมติ)Same 10 trades, two orders (hypothetical)
-5R0R5Rทุนเริ่มต้นStartลำดับ A DD 3ROrder A, DD 3Rลำดับ B DD 6ROrder B, DD 6Rไม้ที่ 0 ถึง 10Trade 0 to 10
สมมติ: จบ +2R เท่ากัน แต่ B เจ็บ $300 ส่วน A เจ็บ $150Hypothetical: both end +2R; B hurts $300, A only $150

The odds of losing streaks

Simple maths sets expectations. Suppose a system loses 60% of the time (wins 40%) and trades are independent. The chance that a given run of 8 trades are all losers = 0.6 to the power 8 ≈ 0.0168, about 1.7%.

That sounds small, but it is the chance for one particular 8-trade window. Over several hundred trades there are hundreds of such windows, so the chance of meeting an 8-loss streak somewhere becomes much higher. Monte Carlo puts a number on that instead of a guess.

โอกาสเจอแพ้ 8 ไม้ติดสักครั้ง (แพ้ 60%)Chance of an 8-loss streak somewhere (60% losses)
8 ไม้ที่กำหนดOne set of 8 trades1.7%ตลอด 100 ไม้Within 100 trades49%ตลอด 200 ไม้Within 200 trades75%ตลอด 500 ไม้Within 500 trades97.1%
คำนวณโดยสมมติว่าแต่ละไม้ไม่เกี่ยวกันCalculated assuming trades are independent

Risking 2% per trade, eight straight losses leave 0.98 to the power 8 ≈ 0.851 of the account, a fall of about 14.9%. See also Losing streaks and Risk of ruin.

เสี่ยง 2% ต่อไม้ แพ้ 8 ไม้ติดRisking 2% per trade through 8 losses
85%90%95%100%ทุนเริ่มต้นStarting balanceทุนที่เหลือAccount leftจำนวนไม้ที่แพ้ติดกันLosses in a row
0.98 ยกกำลัง 8 ≈ 0.851 ทุนหายราว 14.9%0.98 to the power 8 ≈ 0.851, about 14.9% gone

Monte Carlo in a spreadsheet

No coding required.

  1. Paste all trade results (in R) into column A.
  2. In column B enter a random formula such as =RAND().
  3. Sort by column B to get a new order.
  4. Column C holds the running total; column D the distance from the previous peak. Its minimum is that run's drawdown.
  5. Repeat a few dozen times by hand, or use a data table to calculate hundreds of runs.

If you code, a language like Python can run tens of thousands of simulations in seconds.

Monte Carlo ในสเปรดชีตMonte Carlo in a spreadsheet
1คอลัมน์ A ผลทุกไม้เป็นหน่วย RColumn A: every trade result in R2คอลัมน์ B ใส่ =RAND()Column B: =RAND()3เรียงตามคอลัมน์ B ได้ลำดับใหม่Sort by column B for a new order4C ทุนสะสม D ระยะจากจุดสูงสุดC running total, D distance from peak5ค่าต่ำสุดของ D คือ DD รอบนั้นLowest D = that run's drawdown6ทำซ้ำหลายร้อยรอบ ดูกรณีแย่Repeat hundreds of times, study bad cases

Using the results

  • Set risk per trade. If the 95th-percentile drawdown is 20R and you can accept at most a 10% account drawdown, risk per trade should be no more than 10% ÷ 20 = 0.5%.
  • Set a stop rule for the system. If the live drawdown exceeds what the simulation says almost never happens, stop and review.
  • Funded accounts. Estimate how likely you are to hit a daily or overall loss limit. Try the numbers in the prop calculator.
DD กรณีแย่ 20R เป็นกี่ % ของพอร์ตA 20R bad-case drawdown as % of account
เสี่ยง 0.5% ต่อไม้Risk 0.5% per trade10%เสี่ยง 1% ต่อไม้Risk 1% per trade20%เสี่ยง 2% ต่อไม้Risk 2% per trade40%
ยอมรับ DD ได้ 10% → เสี่ยงไม่เกิน 10% ÷ 20 = 0.5%Accept 10% DD → risk at most 10% ÷ 20 = 0.5%

Weaknesses / common mistakes

  • Garbage in, garbage out. If the trades come from an overfitted backtest or exclude costs, ten thousand simulations will be just as misleading.
  • Assuming trades are independent. In reality losses often cluster when the market changes regime. Random shuffling can make risk look smaller than it is.
  • Nothing that never happened. The simulation only recombines trades you have. If your data never contained a large price gap, neither will the simulation.
  • Looking only at the middle. The value lies in the bad cases (95th or 99th percentile), not the average.
  • A small starting sample. Shuffling 30 trades ten thousand times does not create more information.

Summary

  • One backtest is one path; Monte Carlo shows thousands of other possible paths.
  • The same trades in a different order can produce very different drawdowns.
  • Use the bad cases (95th percentile and beyond) to set risk per trade and stop rules.
  • An ordinary spreadsheet is enough to start.
  • Results are only as good as the trade data you feed in.
คำนวณให้เลย: เครื่องคำนวณสอบกองทุนฟรีDo the maths for you: free prop challenge calculatorใส่ยอดบัญชีและกติกา รู้ทันทีว่าวันนี้เสียได้อีกเท่าไร ล็อตไม่ควรเกินเท่าไร และโอกาสผ่านจากอัตราชนะของคุณEnter your balance and rules to see today's loss room, your max lot and your pass chance from your own win rate.
เปิดฟรี ›Open free ›

อ่านต่อRead next

กราฟ XAUUSD ประกอบหมวด ทดสอบระบบและเทรดแบบมืออาชีพ / Testing & trading like a pro
ทดสอบระบบและเทรดแบบมืออาชีพTesting & trading like a proกลางIntermediate5 นาที5 min

ตัวชี้วัดผลงานระบบเทรด (Profit Factor, Expectancy, Drawdown, Sharpe)Trading Performance Metrics (Profit Factor, Expectancy, Drawdown, Sharpe)

อ่านรายงานผลเทรดให้เป็น รู้ว่าแต่ละตัวเลขบอกอะไร คำนวณอย่างไร และตัวไหนหลอกตาได้ง่ายLearn to read a trading report: what each number tells you, how it is calculated, and which ones mislead easily.

กราฟ XAUUSD ประกอบหมวด การบริหารเงิน (Money Management) / Money management
การบริหารเงิน (Money Management)Money managementกลางIntermediate4 นาที4 min

ความเสี่ยงที่พอร์ตจะพัง (Risk of Ruin)Risk of Ruin

ทำความเข้าใจโอกาสที่พอร์ตจะลดลงถึงจุดที่เทรดต่อไม่ได้ ผ่านการคิดเลขแพ้ติดกันและสูตรพื้นฐาน เพื่อเลือกความเสี่ยงต่อไม้อย่างมีเหตุผลBuild an intuition for the chance of losing so much you cannot keep trading, using losing-streak arithmetic and a basic formula, so you can pick risk per trade sensibly.

กราฟ XAUUSD ประกอบหมวด จิตวิทยาการเทรด / Trading psychology
จิตวิทยาการเทรดTrading psychologyกลางIntermediate4 นาที4 min

รับมือกับช่วงแพ้ติดกัน (Losing Streaks)Handling Losing Streaks

ทำไมการแพ้ติดกันเป็นเรื่องปกติแม้ระบบจะดี คำนวณให้เห็นว่าความเสี่ยงต่อไม้กำหนดความเสียหายอย่างไร และแผนรับมือแบบเป็นขั้นตอนWhy losing streaks are normal even for a sound method, how risk per trade decides the damage, and a step-by-step plan for getting through one.

กราฟ XAUUSD ประกอบหมวด ทดสอบระบบและเทรดแบบมืออาชีพ / Testing & trading like a pro
ทดสอบระบบและเทรดแบบมืออาชีพTesting & trading like a proกลางIntermediate5 นาที5 min

การทดสอบย้อนหลัง (Backtesting) และ Strategy Tester ของ MT5Backtesting and the MT5 Strategy Tester

วิธีทดสอบกฎการเทรดกับข้อมูลในอดีตให้ได้ผลที่เชื่อถือได้ ทั้งแบบมือและด้วย Strategy Tester ของ MT5 พร้อมกับดักที่ทำให้ผลสวยเกินจริงHow to test trading rules on past data in a way you can trust, by hand and with the MT5 Strategy Tester, plus the traps that make results look better than they are.

กราฟ XAUUSD ประกอบหมวด การบริหารเงิน (Money Management) / Money management
การบริหารเงิน (Money Management)Money managementเริ่มต้นBeginner4 นาที4 min

คณิตศาสตร์การฟื้นจากขาดทุน (Drawdown Recovery)Drawdown Recovery Math

ทำไมขาดทุน 50% ต้องกำไร 100% ถึงจะกลับมาที่เดิม พร้อมตารางและสูตรที่ทำให้เห็นว่าการป้องกันพอร์ตสำคัญกว่าการไล่กำไรWhy a 50% loss needs a 100% gain to get back, with the table and formula that show protecting capital matters more than chasing gains.