OPEN-SOURCE SCRIPT

Adaptive Trend Breaks

179
Adaptive Trend Breaks

## WHAT IT DOES

This script is a modified and enhanced version of "Trendline Breakouts With Targets" concept by ChartPrime.

Adaptive Trend Breaks (ATB) is a trendline breakout system optimized for scalping liquid futures contracts. The indicator automatically draws dynamic support and resistance trendlines based on pivot points, then generates trade signals when price breaks through these levels with confirmation filters. It includes automated target and stop-loss placement with real-time P&L tracking in dollars.

## HOW IT WORKS

**Trendline Detection Method:**
The indicator uses pivot high/low detection to identify significant price turning points. When a new pivot forms, it calculates the slope between consecutive pivots to draw dynamic trendlines. These lines extend forward based on the established trend angle, creating actionable support and resistance zones.

**Band System:**
Around each trendline, the script creates a "band" using a volatility-adjusted calculation: `ATR(14) * 0.2 * bandwidth multiplier / 2`. This adaptive band accounts for current market conditions - wider during volatile periods, tighter during quiet markets.

**Breakout Logic:**
A breakout signal triggers when:
1. Price closes beyond the trendline + band zone
2. Volume exceeds the 20-period moving average by your set multiplier (default 1.2x)
3. Price is within Regular Trading Hours (9:30-16:00 EST) if session filter enabled
4. Current ATR meets minimum volatility threshold (prevents trading dead markets)

**Target & Stop Calculation:**
Upon breakout confirmation:
- **Entry**: Trendline breach point
- **Target**: Entry ± (bandwidth × target multiplier) - default 8x for quick scalps
- **Stop**: Entry ± (bandwidth × stop multiplier) - default 8x for 1:1 risk/reward
- Multipliers adjust automatically to market volatility through the ATR-based band

**P&L Conversion:**
The script converts point movements to dollars using:
```
Dollar P&L = (Price Points × Contract Point Value × Quantity)
```
For example, a 10-point NQ move with 2 contracts = 10 × $20 × 2 = $400

## HOW TO USE IT

**Setup:**
1. Select your instrument (NQ/ES/YM/RTY) - point values auto-configure
2. Set contract quantity for accurate dollar P&L
3. Choose pivot period (lower = more signals but more noise, default 5 for scalping)
4. Adjust bandwidth multiplier if trendlines are too tight/loose (1-5 range)

**Filters Configuration:**
- **Volume Filter**: Requires breakout volume > moving average × multiplier. Increase multiplier (1.5-2.0) for higher conviction trades
- **Session Filter**: Enable to trade only RTH. Disable for 24-hour trading
- **ATR Filter**: Prevents signals during low volatility. Increase minimum % for more active markets only

**Risk Management:**
- Set target/stop multipliers based on your risk tolerance
- 8x bandwidth = approximately 1:1 risk/reward for most liquid futures
- Enable trailing stops for trend-following approach (moves stop to protect profits)
- Adjust line length to see targets further into the future

**Statistics Table:**
- Choose timeframe to analyze: all-time, today, this week, custom days
- Monitor win rate, profit factor, and net P&L in dollars
- Track long vs short performance separately
- See real-time unrealized P&L on active trades

**Reading Signals:**
- **Green triangle below bar** = Long breakout (resistance broken)
- **Red triangle above bar** = Short breakout (support broken)
- **White dashed line** = Entry price
- **Orange line** = Take profit target with dollar value
- **Red line** = Stop loss with dollar value
- **Green checkmark (✓)** = Target hit, winning trade
- **Red X (✗)** = Stop hit, losing trade

## WHAT IT DOES NOT DO

**Limitations to Understand:**
- Does not predict future trendline formations - it reacts to breakouts after they occur
- Historical trendlines disappear after breakout (not kept on chart for clarity)
- Requires sufficient volatility - may not signal in extremely quiet markets
- Volume filter requires exchange volume data (not available on all symbols)
- Statistics are indicator-based simulations, not actual trading results
- Does not account for slippage, commissions, or order fills

## BEST PRACTICES

**Recommended Settings by Market:**
- **NQ (Nasdaq)**: Default settings work well, consider volume multiplier 1.3-1.5
- **ES (S&P 500)**: Slightly slower, try period 7-8, volume 1.2
- **YM (Dow)**: Lower volatility, reduce bandwidth to 1.5-2
- **RTY (Russell)**: Higher volatility, increase bandwidth to 3-4

**Risk Management:**
- Never risk more than 2-3% of account per trade
- Use contract quantity calculator: Max Risk $ ÷ (Stop Distance × Point Value)
- Start with 1 contract while learning the system
- Backtest your specific timeframe and instrument before live trading

**Optimization Tips:**
- Increase pivot period (7-10) for fewer but higher-quality signals
- Raise volume multiplier (1.5-2.0) in choppy markets
- Lower target/stop multipliers (5-6x) for tighter profit taking
- Use trailing stops in strong trending conditions
- Disable session filter for overnight gaps and Asia session moves

## TECHNICAL DETAILS

**Key Calculations:**
- Pivot Detection: `ta.pivothigh(high, period, period/2)` and `ta.pivotlow(low, period, period/2)`
- Slope Calculation: `(newPivot - oldPivot) / (newTime - oldTime)`
- Adaptive Band: `min(ATR(14) * 0.2, close * 0.002) * multiplier / 2`
- Breakout Confirmation: Price crosses trendline + 10% of band threshold

**Data Requirements:**
- Minimum bars in view: 500 for proper pivot calculation
- Volume data required for volume filter accuracy
- Intraday timeframes recommended (1min - 15min) for scalping
- Works on any timeframe but optimized for fast execution

**Performance Metrics:**
All statistics calculate based on indicator signals:
- Tracks every signal as a trade from entry to TP/SL
- P&L in actual contract dollar values
- Win rate = (Winning trades / Total trades) × 100
- Profit factor = Gross profit / Gross loss
- Separates long/short performance for bias analysis

## IDEAL FOR

- Futures scalpers and day traders
- Traders who prefer visual trendline breakouts
- Those wanting automated TP/SL placement
- Traders tracking performance in dollar terms
- Multiple timeframe analysis (compare 1min vs 5min signals)

## NOT SUITABLE FOR

- Swing trading (targets too close)
- Stocks/forex without modifying point values
- Extremely low timeframes (<30 seconds) - too much noise
- Markets without volume data if using volume filter
- Illiquid contracts (signals may not execute at shown prices)

---

**Settings Summary:**
- Core: Period, bandwidth, extension, trendline style
- Filters: Volume, RTH session, ATR volatility
- Risk: R:R ratio, target/stop multipliers, trailing stop
- Display: Stats table position, size, colors
- Stats: Timeframe selection (all-time to custom days)

**License:** This indicator is published open-source under Mozilla Public License 2.0. You may use and modify the code with proper attribution.

**Disclaimer:** This indicator is for educational purposes. Past performance does not guarantee future results. Always practice proper risk management and test thoroughly before live trading.

---

## CREDITS & ATTRIBUTION

This script builds upon the "Trendline Breakouts With Targets" concept by ChartPrime with significant enhancements:

**Major Improvements Added:**
- **Futures-Specific Calculations**: Automated dollar P&L conversion using actual contract point values (NQ=$20, ES=$50, YM=$5, RTY=$50)
- **Advanced Statistics Engine**: Comprehensive performance tracking with customizable timeframe analysis (today, week, month, custom ranges)
- **Multi-Layer Filtering System**: Volume confirmation, RTH session filter, and ATR volatility filter to reduce false signals
- **Professional Trade Management**: Enhanced visual trade tracking with separate TP/SL lines, dollar value labels, and optional trailing stops
- **Optimized for Scalping**: Faster pivot periods (5 vs 10), tighter bands, and reduced extension bars for quick entries

Original trendline detection methodology by ChartPrime - used with modification under Mozilla Public License 2.0.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.