OPEN-SOURCE SCRIPT
VIOP Scalping - Original

VIOP Scalping – Original is a rule-based scalping strategy ported from an original C# logic set. It aims to trade only when trend direction, momentum, and trend strength align, then manages the position using fixed take-profit/stop-loss percentages with an optional trailing mechanism to protect gains during favorable moves.
This strategy is provided for educational and backtesting purposes only. It is not financial advice and does not guarantee profitability. Always test thoroughly before any live usage.
How the Strategy Works
Inputs and Settings
Trend and Indicator Settings
Threshold Settings
Risk Management Settings
Time Filter
Entry Logic
No-Trade Time Filter
Long Entry Conditions
Short Entry Conditions
Strong Trend Logic (Dynamic TP Selection)
Exit Management (TP/SL + Trailing)
What You See on the Chart
Recommended Use
Important Notes
This strategy is provided for educational and backtesting purposes only. It is not financial advice and does not guarantee profitability. Always test thoroughly before any live usage.
Core Concept
Follow the dominant WMA trend, confirm momentum with EMA separation, filter conditions with RSI + ADX, then exit using fixed TP/SL with trailing behavior after a defined profit threshold.
How the Strategy Works
- Trend Direction is defined by WMA: above WMA = long bias, below WMA = short bias.
- Momentum is measured via Fast EMA vs Slow EMA and the EMA difference.
- Trend Strength is confirmed using ADX (must exceed a threshold).
- RSI filters trades to avoid entering when momentum is likely overextended or weak.
- A no-trade session blocks entries during a predefined time window (default 09:30–10:05).
- Exit logic uses fixed percent TP/SL, with an optional trailing mechanism that activates after a profit threshold.
Inputs and Settings
Trend and Indicator Settings
- Main Trend WMA: Determines directional bias (price above = long, price below = short).
- Fast EMA / Slow EMA: Used to measure momentum and directional separation.
- RSI Period: Filters entries based on RSI range constraints.
- ADX Period: Measures trend strength (must exceed threshold to allow entries).
Threshold Settings
- EMA Difference Threshold: Minimum EMA separation required to validate momentum.
- ADX Threshold: Minimum ADX required to confirm trend strength.
- RSI Long Ceiling: RSI must remain below this value for long entries.
- RSI Short Floor: RSI must remain above this value for short entries.
Risk Management Settings
- Take Profit %: Default TP distance in percent.
- Strong Trend Take Profit %: Higher TP used when a “strong trend” condition is detected.
- Stop Loss %: Fixed SL distance in percent.
- Trailing Activation %: Profit threshold at which trailing starts.
- Trailing Distance %: Trailing offset distance used once trailing is active.
Time Filter
- No-Trade Hours: Default session is 09:30–10:05. During this window, the strategy does not open new trades.
Entry Logic
No-Trade Time Filter
- If the current bar falls inside the no-trade session, entries are blocked.
Long Entry Conditions
- Price is above the WMA trend line.
- EMA difference is positive and greater than the EMA Difference Threshold.
- EMA momentum is increasing (current EMA diff > previous EMA diff).
- RSI is within the defined range (RSI > 48 and RSI < RSI Long Ceiling).
- Close is higher than the previous close.
- ADX is above the ADX Threshold.
Short Entry Conditions
- Price is below the WMA trend line.
- EMA difference is negative and lower than -EMA Difference Threshold.
- Bearish momentum is increasing (current EMA diff < previous EMA diff).
- RSI is within the defined range (RSI < 52 and RSI > RSI Short Floor).
- Close is lower than the previous close.
- ADX is above the ADX Threshold.
Strong Trend Logic (Dynamic TP Selection)
- If price is far from the WMA (absolute distance > 20 points) AND EMA separation is strong (absolute EMA diff > 1.5 points), the strategy treats the environment as a strong trend.
- In strong trend mode, the strategy uses “Strong Trend Take Profit %” instead of the default “Take Profit %”.
Exit Management (TP/SL + Trailing)
- The strategy uses fixed percentage-based TP and SL levels.
- Trailing logic is enabled via strategy.exit and activates only after price moves in profit by the defined Trailing Activation %.
- Once activated, trailing follows price using the defined Trailing Distance % offset.
- This is designed to secure partial gains during extended moves while still allowing room for continuation.
What You See on the Chart
- WMA Trend Line (Main Trend Filter).
- Fast EMA and Slow EMA (Momentum Confirmation).
- Strategy entry/exit markers generated by TradingView.
Recommended Use
- Scalping systems that rely on trend-following and momentum confirmation.
- Markets where ADX filtering helps avoid choppy conditions.
- Traders who want a simple, parameter-driven TP/SL system with trailing after confirmation.
Important Notes
- The no-trade session depends on your chart/session settings. Ensure your symbol/session configuration matches your intended market hours.
- Percent-based exits scale with price; results will vary across instruments and volatility regimes.
- Always validate behavior using bar replay, forward testing, and realistic commission/slippage assumptions.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน