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

Overfitting: ระบบที่เก่งแค่ในอดีตOverfitting: Systems That Only Work in the Past

เข้าใจว่าทำไมการปรับค่าจนกราฟทุนสวยมักพังในตลาดจริง และวิธีทดสอบว่าระบบมีความทนทานจริงหรือแค่จำอดีตได้Why tuning a system until the equity curve looks perfect usually fails live, and how to test whether a system is robust or has just memorised the past.

กราฟ XAUUSD ประกอบหมวด ทดสอบระบบและเทรดแบบมืออาชีพ / Testing & trading like a pro
ในบทความนี้ · 6
  1. Overfitting เกิดขึ้นได้อย่างไร
  2. สัญญาณเตือนว่าระบบอาจ overfit
  3. วิธีป้องกันและตรวจสอบ
  4. จุดอ่อน / ข้อผิดพลาดที่พบบ่อย
  5. ใช้บนมือถือ
  6. สรุป
In this article · 6
  1. How overfitting happens
  2. Warning signs
  3. How to prevent and detect it
  4. Weaknesses / common mistakes
  5. On a phone
  6. Summary

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

Overfitting เกิดขึ้นได้อย่างไร

ข้อมูลราคามีสองส่วนปนกัน คือ สัญญาณ (รูปแบบที่อาจเกิดซ้ำ) และ สัญญาณรบกวน (Noise: ความบังเอิญที่ไม่เกิดซ้ำ) ระบบที่ดีควรจับส่วนแรก แต่ทุกครั้งที่เราเพิ่มเงื่อนไขหรือปรับค่าเพื่อให้ผลอดีตดีขึ้น เราเสี่ยงที่จะไปจับส่วนหลัง

ลองนึกภาพนักเรียนที่ท่องคำตอบข้อสอบเก่าได้ทุกข้อ แต่ไม่เข้าใจวิธีคิด เขาจะได้เต็มในข้อสอบเก่า และสอบตกเมื่อโจทย์เปลี่ยนเล็กน้อย ระบบที่ overfit ก็เป็นแบบนั้น

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

เส้นทุนสมมติ: overfit กับ ทนทานHypothetical equity: overfitted vs robust
0%20%40%60%ทุนเริ่มต้นStartOverfit (สมมติ)Overfitted (hypo.)ทนทาน (สมมติ)Robust (hypo.)ปี 0–7 IS · ปี 7–10 OOSYears 0–7 IS · 7–10 OOS
สมมติ: เส้นที่เรียบที่สุดในอดีตพังเมื่อเจอข้อมูลใหม่Hypothetical: the smoothest past curve breaks on new data

สัญญาณเตือนว่าระบบอาจ overfit

  • พารามิเตอร์เยอะ มีค่าที่ต้องตั้งหลายสิบตัว เช่น ค่าอินดิเคเตอร์หลายตัว ฟิลเตอร์เวลา ฟิลเตอร์วันในสัปดาห์
  • ค่าแปลก ๆ เช่น ค่าเฉลี่ย 37 แท่ง RSI 13 ระดับ 71.5 ซึ่งได้มาจากการลองทุกค่าแล้วเลือกตัวที่ดีที่สุด
  • กราฟทุนเรียบเกินจริง ขึ้นแทบเป็นเส้นตรงหลายปี drawdown น้อยผิดธรรมชาติ
  • ค่าใกล้เคียงให้ผลต่างกันมาก RSI 14 กำไรดี แต่ RSI 13 กับ 15 ขาดทุน แปลว่าเจอ "ยอดแหลม" ของความบังเอิญ
  • จำนวนไม้น้อยเมื่อเทียบกับจำนวนเงื่อนไข กฎ 10 ข้อ แต่มีแค่ 40 ไม้
🧮 ยิ่งลองมาก ยิ่งเจอของปลอม

สมมติแต่ละไอเดียที่ไม่มีความได้เปรียบจริง มีโอกาส 5% ที่จะ "ดูดี" ในการทดสอบเพราะโชค ถ้าลอง 20 ไอเดีย จำนวนที่คาดว่าจะดูดีเพราะโชค = 20 × 0.05 = 1 ไอเดีย ถ้าลอง 200 ไอเดีย = 200 × 0.05 = 10 ไอเดีย ส่วนการปรับค่า: 5 พารามิเตอร์ ลองค่าละ 10 ค่า = 10 × 10 × 10 × 10 × 10 = 100,000 ชุด การเลือกชุดที่ดีที่สุดจากแสนชุด แทบแน่นอนว่าได้ชุดที่โชคดีกับข้อมูลนั้นที่สุด ไม่ใช่ชุดที่ดีที่สุดในอนาคต

ไอเดียที่ "ดูดี" เพราะโชค (โอกาส 5%)Ideas that "look good" by luck (5% chance)
ลอง 20 ไอเดียTry 20 ideas1ลอง 200 ไอเดียTry 200 ideas10
ยิ่งลองมาก ของปลอมที่ผ่านการทดสอบยิ่งมากThe more you try, the more fakes pass the test
ชุดค่าที่ต้องลอง เมื่อแต่ละค่ามี 10 ตัวเลือกCombinations with 10 values per parameter
1 พารามิเตอร์1 parameter102 พารามิเตอร์2 parameters1003 พารามิเตอร์3 parameters1,0004 พารามิเตอร์4 parameters10,0005 พารามิเตอร์5 parameters100,000
เพิ่มทีละพารามิเตอร์ ชุดค่าคูณ 10 เท่าEach extra parameter multiplies the combinations by 10

วิธีป้องกันและตรวจสอบ

1. แบ่งข้อมูล In-sample / Out-of-sample

แบ่งข้อมูลเป็นสองส่วนก่อนเริ่ม เช่น ข้อมูล 10 ปี ใช้ 7 ปีแรก (In-sample) สำหรับสร้างและปรับระบบ แล้วเก็บ 3 ปีหลัง (Out-of-sample) ไว้ทดสอบครั้งเดียวตอนจบ ถ้าดูผลช่วงหลังแล้วกลับไปแก้ระบบ ช่วงนั้นก็ไม่ใช่ out-of-sample อีกต่อไป ใน Strategy Tester ของ MT5 มีช่อง Forward ที่ทำหน้าที่นี้ได้

2. Walk-forward

ทำซ้ำหลายรอบ: ปรับค่าในหน้าต่างข้อมูลหนึ่ง แล้วทดสอบกับช่วงถัดไปที่ยังไม่เห็น จากนั้นเลื่อนหน้าต่างไปเรื่อย ๆ ผลที่ได้จากช่วงที่ "ไม่เห็น" ทั้งหมดเมื่อต่อกันจะใกล้กับการใช้งานจริงมากกว่า

Walk-forward ทีละรอบWalk-forward, round by round
1ปรับค่าในหน้าต่างข้อมูลที่ 1Optimize on data window 12ทดสอบกับช่วงถัดไปที่ยังไม่เห็นTest on the next unseen window3เลื่อนหน้าต่างไปข้างหน้า แล้วทำซ้ำSlide the window forward and repeat4ต่อผลช่วงที่ไม่เห็นทั้งหมดเข้าด้วยกันChain all unseen-window results5ตัดสินจากผลที่ต่อกันนี้เท่านั้นJudge only on the chained result

3. หาที่ราบ ไม่ใช่ยอดแหลม

เวลาปรับค่า ให้ดูตารางผลของค่าข้างเคียง ระบบที่ทนทานจะให้ผลใกล้เคียงกันในช่วงค่ากว้าง ๆ (ที่ราบ) เลือกค่ากลางที่ราบ ไม่ใช่จุดที่สูงที่สุดซึ่งรอบข้างตกฮวบ

ยอดแหลม กับ ที่ราบ (Profit Factor สมมติ)Spike vs plateau (hypothetical PF)
0.81.01.21.5PF 1 = เท่าทุนPF 1 = break-evenยอดแหลม (สมมติ)Spike (hypo.)ที่ราบ (สมมติ)Plateau (hypo.)ค่า RSI 11 ถึง 17RSI period 11 to 17
RSI 14 ดีแต่ 13 กับ 15 ขาดทุน = ยอดแหลมของโชคRSI 14 wins but 13 and 15 lose = a spike of luck

4. ทดสอบในตลาดและช่วงเวลาอื่น

ถ้าแนวคิดมีเหตุผลรองรับจริง มักจะยังทำงานได้พอใช้ในตลาดที่คล้ายกันหรือในกรอบเวลาใกล้เคียง โดยไม่ต้องปรับค่าใหม่ ถ้าใช้ได้แค่ทองคำ H1 ช่วงปีเดียว ให้สงสัยไว้ก่อน

5. ลดจำนวนเงื่อนไข

กฎน้อยข้อที่มีเหตุผลอธิบายได้ ดีกว่ากฎยี่สิบข้อที่ทำให้กราฟสวย ทุกเงื่อนไขที่เพิ่มควรตอบได้ว่า "ทำไมมันควรได้ผล" ไม่ใช่แค่ "เพราะ backtest ดีขึ้น"

6. เผื่อความแย่ลง

แม้ระบบจะไม่ overfit ผลจริงก็มักแย่กว่า backtest เพราะต้นทุนและการส่งคำสั่ง ให้ตั้งความคาดหวังต่ำกว่าผลทดสอบเสมอ แล้วยืนยันด้วย Forward test

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

  • คิดว่า out-of-sample ผ่านหนึ่งครั้งแปลว่าปลอดภัย ถ้าทดสอบหลายระบบกับช่วงเดียวกันแล้วเลือกตัวที่ผ่าน ก็ overfit กับช่วงนั้นได้อีกชั้น
  • ปรับค่าใหม่ทุกครั้งที่ขาดทุน เป็นการไล่ตามสัญญาณรบกวนในตลาดจริง
  • ใช้ Optimization ทุกพารามิเตอร์พร้อมกัน ยิ่งเพิ่มโอกาสเจอชุดบังเอิญ
  • เกลียดระบบที่เรียบง่าย ระบบเรียบง่ายมักดูน่าเบื่อ แต่ทนทานกว่า
  • ไม่นับว่าลองไปกี่ครั้ง ควรจดว่าทดสอบกี่ไอเดียกี่ชุดค่า เพื่อประเมินโอกาสเจอของปลอม
  • แก้ overfit ด้วย overfit เช่น เพิ่มฟิลเตอร์ "ไม่เทรดวันพุธ" เพราะวันพุธในอดีตขาดทุน
ระบบทนทาน กับ ระบบที่จำอดีตRobust system vs memorised past
ทนทานRobust✓กฎน้อยข้อ อธิบายเหตุผลได้Few rules with a reason✓ค่าข้างเคียงให้ผลใกล้กันNeighbour values give similar results✓ใช้ได้กับตลาดหรือกรอบเวลาใกล้เคียงWorks on similar markets or timeframesOverfitOverfitted✗พารามิเตอร์หลายสิบตัว ค่าแปลก ๆDozens of parameters, odd values✗กราฟทุนเรียบเป็นเส้นตรงหลายปีEquity a straight line for years✗กฎ 10 ข้อ แต่มีแค่ 40 ไม้Ten rules, only forty trades

ใช้บนมือถือ

การปรับค่าระบบทำบนมือถือไม่ได้จริงจัง แต่สิ่งที่ทำได้คือจดผลเทรดจริงต่อเนื่อง แล้วเทียบกับ backtest เป็นระยะ ถ้าเห็นว่าผลจริงห่างจาก backtest มากอย่างต่อเนื่อง นั่นอาจเป็นอาการของ overfit ที่ควรกลับไปตรวจบนคอมพิวเตอร์

สรุป

  • Overfitting คือระบบที่จำความบังเอิญในอดีตแทนรูปแบบที่เกิดซ้ำ
  • ยิ่งลองหลายไอเดียหรือหลายชุดค่า โอกาสเจอผลดีเพราะโชคยิ่งสูง
  • กันข้อมูลไว้ทดสอบแยก ใช้ walk-forward และเลือกค่าบนที่ราบ
  • กฎน้อยที่มีเหตุผล ดีกว่ากฎเยอะที่ทำให้กราฟสวย
  • ยืนยันทุกระบบด้วยการทดสอบกับข้อมูลที่ยังไม่เคยเห็น

Overfitting, also called curve fitting, happens when a trading system is tuned so closely to past data that it memorises that data's accidents instead of capturing patterns that repeat. The backtest looks superb, and live results deteriorate almost immediately. It is one of the most common reasons systems that look great on paper fail.

How overfitting happens

Price data mixes two things: signal (patterns that may repeat) and noise (random accidents that will not). A good system captures the first. But every time you add a condition or tweak a value to improve past results, you risk fitting the second.

Think of a student who memorises every answer on last year's exam without understanding the method. Full marks on the old paper, failure the moment the questions change slightly. An overfitted system behaves the same way.

See the chart below.

เส้นทุนสมมติ: overfit กับ ทนทานHypothetical equity: overfitted vs robust
0%20%40%60%ทุนเริ่มต้นStartOverfit (สมมติ)Overfitted (hypo.)ทนทาน (สมมติ)Robust (hypo.)ปี 0–7 IS · ปี 7–10 OOSYears 0–7 IS · 7–10 OOS
สมมติ: เส้นที่เรียบที่สุดในอดีตพังเมื่อเจอข้อมูลใหม่Hypothetical: the smoothest past curve breaks on new data

Warning signs

  • Many parameters. Dozens of settings: several indicator periods, time filters, day-of-week filters.
  • Odd values. A 37-bar average, RSI 13, a level of 71.5, found by trying everything and keeping the best.
  • An equity curve that is too smooth. Almost a straight line for years with unnaturally small drawdowns.
  • Neighbouring values give very different results. RSI 14 is profitable but RSI 13 and 15 lose money. You found a spike of luck.
  • Few trades relative to conditions. Ten rules, forty trades.
🧮 The more you try, the more fakes you find

Suppose any idea with no real edge has a 5% chance of "looking good" in a test purely by luck. Try 20 ideas and the expected number of lucky passes = 20 × 0.05 = 1 idea. Try 200 ideas: 200 × 0.05 = 10 ideas. Now parameters: 5 parameters with 10 values each = 10 × 10 × 10 × 10 × 10 = 100,000 combinations. Picking the best of 100,000 almost guarantees you pick the one that was luckiest on that data, not the one that will be best in the future.

ไอเดียที่ "ดูดี" เพราะโชค (โอกาส 5%)Ideas that "look good" by luck (5% chance)
ลอง 20 ไอเดียTry 20 ideas1ลอง 200 ไอเดียTry 200 ideas10
ยิ่งลองมาก ของปลอมที่ผ่านการทดสอบยิ่งมากThe more you try, the more fakes pass the test
ชุดค่าที่ต้องลอง เมื่อแต่ละค่ามี 10 ตัวเลือกCombinations with 10 values per parameter
1 พารามิเตอร์1 parameter102 พารามิเตอร์2 parameters1003 พารามิเตอร์3 parameters1,0004 พารามิเตอร์4 parameters10,0005 พารามิเตอร์5 parameters100,000
เพิ่มทีละพารามิเตอร์ ชุดค่าคูณ 10 เท่าEach extra parameter multiplies the combinations by 10

How to prevent and detect it

1. Split in-sample and out-of-sample

Split the data before you start. With 10 years of data, for example, build and tune on the first 7 (in-sample) and keep the last 3 (out-of-sample) for a single final test. If you look at the later period and go back to change the system, it is no longer out-of-sample. The MT5 Strategy Tester's Forward option does this split for you.

2. Walk-forward

Repeat the process: optimize on one window, test on the next unseen window, then slide forward. Chained together, the unseen-window results are much closer to what live trading would look like.

Walk-forward ทีละรอบWalk-forward, round by round
1ปรับค่าในหน้าต่างข้อมูลที่ 1Optimize on data window 12ทดสอบกับช่วงถัดไปที่ยังไม่เห็นTest on the next unseen window3เลื่อนหน้าต่างไปข้างหน้า แล้วทำซ้ำSlide the window forward and repeat4ต่อผลช่วงที่ไม่เห็นทั้งหมดเข้าด้วยกันChain all unseen-window results5ตัดสินจากผลที่ต่อกันนี้เท่านั้นJudge only on the chained result

3. Look for plateaus, not spikes

When optimizing, look at how neighbouring values perform. A robust system gives similar results across a broad range of values (a plateau). Pick a value in the middle of the plateau, not the single peak surrounded by cliffs.

ยอดแหลม กับ ที่ราบ (Profit Factor สมมติ)Spike vs plateau (hypothetical PF)
0.81.01.21.5PF 1 = เท่าทุนPF 1 = break-evenยอดแหลม (สมมติ)Spike (hypo.)ที่ราบ (สมมติ)Plateau (hypo.)ค่า RSI 11 ถึง 17RSI period 11 to 17
RSI 14 ดีแต่ 13 กับ 15 ขาดทุน = ยอดแหลมของโชคRSI 14 wins but 13 and 15 lose = a spike of luck

4. Test other markets and periods

If an idea has a sound reason behind it, it often still works reasonably on similar markets or nearby timeframes without re-tuning. If it only works on gold H1 for one particular year, be suspicious.

5. Use fewer conditions

A few rules you can explain beat twenty rules that make the curve pretty. Every added condition should answer "why should this work?", not just "because the backtest improved".

6. Expect degradation

Even without overfitting, live results are usually worse than the backtest because of costs and execution. Always set expectations below the test results and confirm with a forward test.

Weaknesses / common mistakes

  • Thinking one out-of-sample pass makes it safe. Test many systems on the same holdout and keep the winner, and you have overfitted to the holdout.
  • Re-optimizing after every loss. That is chasing noise in real time.
  • Optimizing every parameter at once. It multiplies the chance of a lucky combination.
  • Disliking simple systems. Simple looks boring but tends to be sturdier.
  • Not counting attempts. Record how many ideas and parameter sets you tried, so you can judge the odds of a fake.
  • Fixing overfitting with more overfitting. For example, adding "no trading on Wednesdays" because past Wednesdays lost money.
ระบบทนทาน กับ ระบบที่จำอดีตRobust system vs memorised past
ทนทานRobust✓กฎน้อยข้อ อธิบายเหตุผลได้Few rules with a reason✓ค่าข้างเคียงให้ผลใกล้กันNeighbour values give similar results✓ใช้ได้กับตลาดหรือกรอบเวลาใกล้เคียงWorks on similar markets or timeframesOverfitOverfitted✗พารามิเตอร์หลายสิบตัว ค่าแปลก ๆDozens of parameters, odd values✗กราฟทุนเรียบเป็นเส้นตรงหลายปีEquity a straight line for years✗กฎ 10 ข้อ แต่มีแค่ 40 ไม้Ten rules, only forty trades

On a phone

You cannot seriously optimize a system on a phone. What you can do is keep logging live results and compare them with the backtest regularly. If live results stay far from the backtest, that may be a symptom of overfitting worth investigating on a computer.

Summary

  • Overfitting means a system memorised past accidents instead of repeatable patterns.
  • The more ideas or parameter sets you try, the more likely a good result is luck.
  • Hold data back, use walk-forward, and choose values on a plateau.
  • A few rules with a reason beat many rules that flatter the curve.
  • Confirm every system on data it has never seen.
อยากได้เป็น EA: คลังพรอมต์สร้าง EA ฟรีWant it as an EA: free EA prompt libraryคัดลอกพรอมต์ 37 กลยุทธ์ไปวางใน ChatGPT, Gemini หรือ Claude ให้ AI ของคุณเขียน EA ให้Copy one of 37 strategy prompts into ChatGPT, Gemini or Claude and let your AI write the EA.
เปิดฟรี ›Open free ›

อ่านต่อRead next

กราฟ 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 ประกอบหมวด ทดสอบระบบและเทรดแบบมืออาชีพ / Testing & trading like a pro
ทดสอบระบบและเทรดแบบมืออาชีพTesting & trading like a proกลางIntermediate5 นาที5 min

การทดสอบไปข้างหน้า (Forward Testing)Forward Testing

ทดสอบระบบกับตลาดจริงที่ยังไม่เกิดก่อนใช้เงินก้อนใหญ่ วัดอะไร นานแค่ไหน และเมื่อไหร่ควรหยุดHow to test a system on live, unseen market data before committing real size: what to measure, how long to run it, and when to stop.

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

การจำลอง 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
ทดสอบระบบและเทรดแบบมืออาชีพ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 ประกอบหมวด ทดสอบระบบและเทรดแบบมืออาชีพ / Testing & trading like a pro
ทดสอบระบบและเทรดแบบมืออาชีพTesting & trading like a proกลางIntermediate5 นาที5 min

สร้างระบบเทรดของตัวเองทีละขั้นBuilding a Trading System Step by Step

ขั้นตอนจากไอเดียไปจนถึงระบบที่มีกฎครบ ทดสอบแล้ว และพร้อมใช้ด้วยขนาดไม้เล็ก พร้อมเช็คลิสต์ที่ใช้ได้จริงA practical path from an idea to a complete, tested rule set ready to trade at small size, with a checklist you can actually use.