OPEN-SOURCE SCRIPT

Trend Signals with TP/SL + Liquidation Filter

2 201
Trend Signals with TP/SL + Adaptive Liquidation Filter
Research & Educational Framework (Synced v3)

This script is based on the original Trend Signals with TP/SL concept by UAlgo.

The original implementation provides an ATR-based trend detection and risk management structure.
This version preserves the core trend logic while extending it with an adaptive volatility-based liquidation-style filter.

This publication is intended strictly for research and educational purposes.
It should not be considered a finished trading system or financial advice.

🔹 Research Objective

This framework explores the following structural question:

Can trend reversal signals be improved by requiring statistically meaningful price displacement before allowing entries?

The script combines:

A state-driven ATR trend engine

A volatility-adaptive deviation filter

The purpose of this combination is to study whether requiring both directional confirmation and displacement confirmation can reduce entries during low-momentum ranging environments.

The filter is not added for indicator aggregation, but to test interaction between trend state changes and volatility-adjusted extremes.

🔹 Structural Components
1️⃣ Trend Engine (Original Concept)

• Hull-based momentum calculation
• ATR-derived dynamic trailing bands
• State-based trend reversal logic
• Bar-close confirmation (no repainting)

Signals occur only when a full trend flip is confirmed.

2️⃣ Adaptive Deviation Filter (Extension Layer)

• Hybrid SMA + EMA midline
• Volatility-adjusted smoothing lengths via ATR ratio
• Deviation-based extreme detection
• Optional tolerance filtering
• Optional clustering requirement
• Bar-close confirmation

The filter acts as a confirmation layer, not as a standalone signal generator.

3️⃣ Risk & Execution Model

• ATR-based Take Profit and Stop Loss (default)
• Optional percent-based exits
• Fixed position sizing
• No pyramiding

Orders are executed through TradingView’s native strategy engine.

🔹 Reference Backtest Context

To provide structural context, the following test configuration was used:

• Market: XRPUSDT
• Timeframe: 15 minutes
• Initial Capital: 10,000 USD
• Position Size: Fixed 100 USD per trade
• Commission: 0.075%
• Slippage: 0
• Pyramiding: Disabled

One-year sample produced:

• 47 trades
• Profit Factor ≈ 3.6
• Win rate ≈ 68%
• Max drawdown ≈ 0.13%
• Net profit ≈ 143 USD

🔹 Interpretation Notes

This framework is low-frequency by design.

The relatively small trade count reflects:

• Selective filtering
• Conservative position sizing
• State-based trend participation

The low drawdown observed in this configuration is primarily the result of small fixed position sizing relative to total capital.

Results will vary significantly if position sizing, leverage, market, or timeframe are modified.

Users are encouraged to test across:

• Multiple assets
• Extended historical periods
• Alternative volatility conditions

No performance assumptions should be made based solely on the provided sample.

🔹 Intended Use

This script is intended for:

• Developers researching trend-filter interaction
• Traders studying volatility-adaptive filtering
• Educational experimentation with structured risk models

It is not optimized for high-frequency scalping or aggressive leveraged trading.

🔹 Open-Source Purpose

This script is shared to encourage:

• Experimentation
• Methodological improvements
• Regime detection extensions
• Alternative risk models

Constructive modifications and research iterations are welcome.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.