[DAOL] Trend Pullback Strategy

60
⏺️ What is it?

[DAOL] Trend Pullback Strategy is a rule-based backtesting strategy that looks for price to resume the direction of an EMA-defined trend after a pullback.

It combines:

🔹 EMA 20 / EMA 50 — identify trend direction
🔹 Price reclaim of EMA 20 — identify an entry setup
🔹 ATR 14 — determine a fixed stop distance
🔹 R-multiple target — define the profit target relative to that distance

The strategy holds one position at a time. After a trade ends, a new qualifying pullback must occur while flat before another entry is allowed.

⏺️ กลยุทธ์นี้คืออะไร?

[DAOL] Trend Pullback Strategy เป็นกลยุทธ์สำหรับทดสอบย้อนหลัง โดยรอให้ราคาย่อในแนวโน้ม แล้วปิดกลับข้าม EMA 20 ในทิศทางของแนวโน้มนั้น

ผสมหลักการ:

🔹 EMA 20 / EMA 50 — ระบุทิศทางแนวโน้ม
🔹 ราคาปิดกลับข้าม EMA 20 — ระบุจังหวะเข้า
🔹 ATR 14 — กำหนดระยะ Stop คงที่
🔹 เป้าหมายแบบ R — กำหนดระยะเป้าหมายเทียบกับ Stop

ถือครั้งละหนึ่งสถานะ หลังจบเทรดต้องเกิดการย่อที่เข้าเงื่อนไขรอบใหม่ขณะไม่มีสถานะ จึงจะเข้าอีกครั้งได้

⏺️ Entry rules

Long:

EMA 20 is above EMA 50.

While flat and eligible, a bar closes below EMA 20 to arm the setup.

A later bar closes above EMA 20, with the preceding close strictly below its EMA 20.

The upward EMA relationship remains valid.

Short uses the opposite conditions.

Signals are evaluated on closed bars. Market entries normally fill at the next bar’s open under the default broker-emulator settings.

⏺️ เงื่อนไขเข้าเทรด

Long:

EMA 20 อยู่เหนือ EMA 50

ขณะไม่มีสถานะและระบบพร้อมรับ Setup มีแท่งปิดใต้ EMA 20

แท่งถัดมาปิดกลับเหนือ EMA 20 โดยราคาปิดแท่งก่อนหน้าต้องอยู่ใต้ EMA 20 ของแท่งนั้นอย่างชัดเจน

EMA 20 ยังอยู่เหนือ EMA 50

Short ใช้เงื่อนไขกลับด้าน

ประเมินสัญญาณเมื่อแท่งปิด และโดยปกติจำลองเข้า ณ ราคาเปิดแท่งถัดไปตามค่าตั้งเริ่มต้น

ราคาปิดเท่ากับ EMA 20 ไม่นับเป็นแท่งย่อที่เข้าเงื่อนไข การย่อระหว่างถือสถานะจะไม่ถูกเก็บไว้ใช้เข้าใหม่หลังจบเทรด

⏺️ Stop and target

Default settings:

🔹 Stop distance — 1.5 × ATR 14
🔹 Profit target — 2 × stop distance, or 2R

ATR is sampled at the signal close. The stop distance is rounded upward to whole ticks, and the target is rounded to whole ticks.

Both distances are measured from the actual simulated entry fill and remain fixed during the trade.

The strategy exits through its stop, target, or a market-exit request when the test window ends. It does not include a trailing stop, trend-change exit, or automatic end-of-day liquidation.

⏺️ Stop และเป้าหมาย

ค่าเริ่มต้น:

🔹 ระยะ Stop — 1.5 × ATR 14
🔹 ระยะเป้าหมาย — 2 เท่าของระยะ Stop หรือ 2R

ใช้ ATR ณ แท่งสัญญาณปิด โดยปัดระยะ Stop ขึ้นเป็นจำนวน Tick เต็ม และปัดเป้าหมายเป็นจำนวน Tick เต็ม

วัดระยะทั้งสองจาก ราคาเข้าที่ระบบจำลองได้ และคงระยะตลอดเทรด การปัด Tick อาจทำให้ R จริงต่างจากค่าที่เลือกเล็กน้อย

ออกด้วย Stop, Target หรือคำสั่งปิดเมื่อสิ้นสุดช่วงทดสอบ ไม่มี Trailing Stop การออกเมื่อ EMA เปลี่ยนทิศทาง หรือการปิดสิ้นวันอัตโนมัติ จึงอาจถือข้ามคืนได้

ระยะ Stop ที่กำหนดไม่ใช่การรับประกันขาดทุนสูงสุด เพราะ Gap และ Slippage อาจทำให้ราคาออกต่างจากระดับที่ตั้งไว้

⏺️ One entry per pullback

The setup is consumed when an entry order is submitted. Pullbacks occurring during an open position are ignored.

After the position closes, the strategy requires a new qualifying pullback bar while flat. It does not immediately re-enter simply because the trend remains unchanged.

⏺️ หนึ่งครั้งต่อรอบการย่อ

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

หลังปิดเทรด ต้องเกิดแท่งย่อใหม่ขณะไม่มีสถานะก่อน จึงไม่เข้าใหม่ทันทีเพียงเพราะแนวโน้มยังเป็นทิศทางเดิม

⏺️ Chart display and settings

🔹 Blue line — EMA 20
🔹 Gold line — EMA 50
🔹 L / S markers — signal bars that submit entry orders
🔹 Red line — fixed stop level
🔹 Green line — fixed target level
🔹 Dashboard — current setup or position status

EMA lengths are fixed at 20 and 50, and ATR length is fixed at 14.

User inputs:

🔹 Contracts / units — default 1
🔹 Stop distance — default 1.5 ATR
🔹 Target — default 2R
🔹 Trade side — Both, Long only, or Short only
🔹 Test start / end dates

Stop and target plots appear when a position remains open at script evaluation. An entry and exit occurring within the same bar may therefore have no visible level plots; inspect the trade list.

⏺️ การแสดงผลและค่าตั้ง

🔹 เส้นน้ำเงิน — EMA 20
🔹 เส้นทอง — EMA 50
🔹 เครื่องหมาย L / S — แท่งสัญญาณที่ส่งคำสั่งเข้า
🔹 เส้นแดง — ระดับ Stop คงที่
🔹 เส้นเขียว — ระดับ Target คงที่
🔹 Dashboard — สถานะรอเข้า หรือสถานะที่ถืออยู่

EMA ใช้ 20 และ 50 ส่วน ATR ใช้ 14 โดยคงค่าไว้เพื่อให้เริ่มใช้งานง่าย

Input ที่ปรับได้:

🔹 จำนวนสัญญา — ค่าเริ่มต้น 1
🔹 ระยะ Stop — ค่าเริ่มต้น 1.5 ATR
🔹 Target — ค่าเริ่มต้น 2R
🔹 ฝั่งการซื้อขาย — Both, Long only หรือ Short only
🔹 วันเริ่มและสิ้นสุดการทดสอบ

เส้น Stop/Target แสดงเมื่อยังมีสถานะตอนระบบคำนวณ หากเข้าและออกภายในแท่งเดียวกัน อาจไม่มีเส้นแสดง ให้ตรวจในรายการเทรด

⏺️ Backtesting properties

The supplied test defaults are:

🔹 Initial capital — 1,000,000 account-currency units
🔹 Commission — 50 account-currency units per contract per fill
🔹 Slippage — 1 tick
🔹 Margin — 100% of notional value for both directions
🔹 Pyramiding — disabled
🔹 Every-tick, after-fill, and bar-close-fill options — disabled

These are test placeholders, not actual TFEX costs or margin requirements. Adjust them to match the instrument and account assumptions before interpreting results.

The Contracts / units input controls entry size. Insufficient buying power can prevent trades despite visible entry signals.

⏺️ ค่าตั้งสำหรับ Backtest

ค่าตัวอย่างในโค้ด:

🔹 เงินทุนเริ่มต้น — 1,000,000 หน่วยสกุลเงินบัญชี
🔹 Commission — 50 หน่วยสกุลเงินบัญชีต่อสัญญาต่อครั้งที่คำสั่งถูกจับคู่
🔹 Slippage — 1 Tick
🔹 Margin — 100% ของมูลค่าสัญญาทั้ง Long และ Short
🔹 ไม่เพิ่มไม้
🔹 ปิดการคำนวณทุก Tick การคำนวณหลัง Order Fill และการจับคู่ที่แท่งปิด

ค่าเหล่านี้ ไม่ใช่ต้นทุนหรือหลักประกันจริงของ TFEX ต้องปรับให้เหมาะกับสินค้าและบัญชีทดสอบก่อนอ่านผล

จำนวนสัญญาใช้ค่าจาก Input “Contracts / units” หากเงินทุนไม่พอ อาจมีเครื่องหมายสัญญาณแต่ไม่มีเทรดเกิดขึ้น

⏺️ Development and references

This Pine Script v6 implementation was written for this project without copying Community script source.

EMA pullbacks and ATR-based risk management are established methods. The implementation adds explicit flat-only setup tracking, setup resets, one entry per qualifying pullback, and fixed tick-based exits from the simulated fill.

These choices make the rules inspectable; they are not a claim of an entirely new trading theory or superiority over other strategies.

References:

TradingView — Exponential Moving Average
tradingview.com/support/solutions/43000592270-exponential-moving-average/

TradingView — Average True Range
tradingview.com/support/solutions/43000501823-average-true-range-atr/

TradingView — Pine Script Strategies
tradingview.com/pine-script-docs/concepts/strategies/

⏺️ การพัฒนาและอ้างอิง

เขียนด้วย Pine Script v6 สำหรับโครงการนี้ โดยไม่คัดลอกโค้ดจากสคริปต์ Community

EMA Pullback และการจัดการระยะ Stop ด้วย ATR เป็นหลักการที่มีอยู่แล้ว ส่วนการพัฒนาคือกำหนดการรอ Setup ขณะไม่มีสถานะ การล้าง Setup หนึ่งครั้งต่อรอบการย่อ และคำสั่งออกที่วัดระยะจากราคา Fill

เป็นการทำกติกาให้ตรวจสอบได้ ไม่ได้อ้างว่าเป็นทฤษฎีใหม่ทั้งหมดหรือให้ผลดีกว่ากลยุทธ์อื่น

⏺️ Limitations and disclaimer

🔹 Sideways markets can produce repeated losing trades.
🔹 EMA signals lag price and do not guarantee trend continuation.
🔹 Gaps, costs, contract rolls and data quality affect results.
🔹 Intrabar fills depend on broker-emulator assumptions and available data.
🔹 An open trade or pending order at the end of available history may remain unresolved.
🔹 Numerical logic checks have been completed; TradingView compilation and market-data backtesting remain pending.
🔹 This is a testing candidate. Complete validation and prepare a representative report before public publication.
🔹 For educational and informational purposes only. No investment advice or return guarantee is provided.

⏺️ ข้อจำกัดและคำชี้แจง

🔹 ตลาด Sideway อาจทำให้เกิดเทรดขาดทุนต่อเนื่อง
🔹 EMA ตอบสนองช้ากว่าราคา และไม่รับประกันว่าเทรนด์จะดำเนินต่อ
🔹 Gap ต้นทุน รอยต่อสัญญา และคุณภาพข้อมูลมีผลต่อผลทดสอบ
🔹 การจับคู่ภายในแท่งขึ้นกับสมมติฐานของระบบจำลองและข้อมูลที่มี
🔹 สถานะหรือคำสั่งที่ปลายประวัติอาจยังไม่จบหากไม่มี Tick ถัดไป
🔹 ตรวจตรรกะเชิงตัวเลขแล้ว แต่ยังไม่ได้ Compile ใน TradingView หรือ Backtest ข้อมูลตลาดจริง
🔹 เป็นฉบับสำหรับทดสอบ ต้องตรวจสอบและจัดทำรายงานที่เหมาะสมก่อนเผยแพร่ Public
🔹 ใช้เพื่อการศึกษา ไม่ใช่คำแนะนำการลงทุนหรือการรับประกันผลตอบแทน

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.