OPEN-SOURCE SCRIPT
ที่อัปเดต: CNPS01 MACD

CNPS_01 — MACD Cross Signal is a trend-following strategy designed for VN30F1M (Vietnamese Stock Index Futures), built with Pine Script v5.
📌 Indicators used: MACD (12, 26, 9) — crossover/crossunder of MACD line vs Signal line
📐 Entry Rules:
- Long: MACD line crosses above Signal line
- Short: MACD line crosses below Signal line
- Signal confirmed at candle close → entry executes at next candle open
🚪 Exit Rules:
- Stop Loss: 10 points from entry
- Take Profit: 30 points from entry (optional, can be disabled)
- Natural Exit: position closes automatically when opposite signal fires (MACD crosses back)
- Reverse: if opposite signal is valid, a new position opens immediately after closing
- End of Session: all positions closed when session ends
⏰ Time Filter:
Built-in session filter to avoid ATO (9:00) and ATC (~14:30) periods.
Default: 9:15 – 14:30. Configurable start/end time via inputs.
🔧 Trend Filter (optional):
SMA(200) slope filter — Long only when SMA trending up (Bull), Short only when SMA trending down (Bear). Can be disabled for both-direction trading.
🔀 Trade Direction:
Configurable: Long only / Short only / Both directions.
📊 Note: MACD is not plotted on the price chart (overlay mode). Please add the built-in TradingView "MACD" indicator separately with the same parameters — Fast: 12, Slow: 26, Signal: 9, Source: Close — to visualize entry signals.
📍 Recommended for: VN30F1M intraday traders
🔗 Community: zalo.me/g/jvaykb078
📌 Indicators used: MACD (12, 26, 9) — crossover/crossunder of MACD line vs Signal line
📐 Entry Rules:
- Long: MACD line crosses above Signal line
- Short: MACD line crosses below Signal line
- Signal confirmed at candle close → entry executes at next candle open
🚪 Exit Rules:
- Stop Loss: 10 points from entry
- Take Profit: 30 points from entry (optional, can be disabled)
- Natural Exit: position closes automatically when opposite signal fires (MACD crosses back)
- Reverse: if opposite signal is valid, a new position opens immediately after closing
- End of Session: all positions closed when session ends
⏰ Time Filter:
Built-in session filter to avoid ATO (9:00) and ATC (~14:30) periods.
Default: 9:15 – 14:30. Configurable start/end time via inputs.
🔧 Trend Filter (optional):
SMA(200) slope filter — Long only when SMA trending up (Bull), Short only when SMA trending down (Bear). Can be disabled for both-direction trading.
🔀 Trade Direction:
Configurable: Long only / Short only / Both directions.
📊 Note: MACD is not plotted on the price chart (overlay mode). Please add the built-in TradingView "MACD" indicator separately with the same parameters — Fast: 12, Slow: 26, Signal: 9, Source: Close — to visualize entry signals.
📍 Recommended for: VN30F1M intraday traders
🔗 Community: zalo.me/g/jvaykb078
Release Note
- Vietnamese template- Add more filters for better result: time filter, trend filter.
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน