OPEN-SOURCE SCRIPT

ZLSMA Cross ATR Targets - Enhanced Trading Strategy

114
ZLSMA Cross ATR Targets - Enhanced Trading Strategy

📊 Overview

This indicator combines Zero-Lag Least Squares Moving Average (ZLSMA) crossover signals with ATR-based dynamic risk management to provide precise entry and exit points. Unlike standard moving average crossovers, this system uses a zero-lag implementation to reduce signal delays and incorporates multi-timeframe analysis for improved accuracy.

🎯 What Makes This Script Unique

1. Zero-Lag LSMA Implementation:

Uses a dual-smoothing technique: 2 * SMA(price, length) - SMA(SMA(price, length), length)
This eliminates the typical lag found in standard moving averages
Provides faster reaction to price changes while maintaining smoothness

2. Multi-Timeframe Signal Generation:

Analyzes price action on a higher timeframe (default: 15-min) regardless of chart timeframe
Reduces noise and false signals common in single-timeframe systems
All calculations (ZLSMA, ATR, close price) are synchronized to the signal timeframe

3. Dynamic ATR-Based Risk Management:

Stop Loss: Automatically calculated using ATR multiplier (default: 1.0x)
Take Profit 1: First target at 1.5x ATR (adjustable)
Take Profit 2: Extended target at 3.0x ATR (adjustable)
Risk-Reward ratios are displayed on each trade label for transparency

4. Optional Signal Filters:

Trend Filter: Uses 200 EMA to filter trades - only buys above, sells below (optional)
Volatility Filter: Ensures minimum ATR % to avoid low-volatility false signals (optional)
Both filters can be independently toggled on/off

5. Real-Time Performance Tracking:

Automatically tracks completed trades (TP1, TP2, or SL hits)
Calculates win rate, total P/L, and average P/L per trade
Live P/L displayed for current open position
Performance-based color coding (Green/Blue/Orange/Red)

🔧 How It Works

Signal Generation:

BUY Signal: Triggered when price crosses above ZLSMA on the signal timeframe
SELL Signal: Triggered when price crosses below ZLSMA on the signal timeframe
If filters are enabled, signals are validated against trend direction and volatility conditions

Trade Execution:

Entry price is locked at the close of the crossover bar
SL, TP1, and TP2 are calculated using the ATR value from the signal timeframe
Horizontal lines extend into the future (default: 240 bars) for visual clarity
Labels display all trade parameters including risk-reward ratios

Position Management:

System monitors each bar to detect if price hits SL, TP1, or TP2
Once a target is hit, the trade is marked as complete and statistics update
"Show Only Latest Trade" toggle cleans up historical signals for chart clarity

📈 How to Use

Settings:

Signal Timeframe: Timeframe for ZLSMA and ATR calculations (higher = fewer signals)
ZLSMA Length: Lookback period (100 default, lower = more responsive)
ATR Length: Period for volatility measurement (14 default)
SL/TP Multipliers: Adjust risk-reward profile to your trading style
Filters: Enable/disable trend and volatility filters as needed

Dashboard:

Fixed position (top-right corner) shows:

Current trade status and live P/L
Entry, SL, TP1, TP2 prices
Total performance statistics
Strategy settings summary



Alerts:

Enable alerts in settings to receive notifications on new signals
Each alert includes full trade details (Entry, SL, TP1, TP2)

⚙️ Why This Combination Works

The mashup of ZLSMA, multi-timeframe analysis, ATR-based targets, and optional filters creates a complete trading system:

ZLSMA provides faster signals than traditional moving averages
Higher timeframe reduces noise and improves signal quality
ATR-based targets adapt to current market volatility (no fixed pip targets)
Trend filter keeps you aligned with the bigger picture
Volatility filter avoids choppy, low-conviction setups
Performance tracking allows data-driven strategy optimization

This is not just a combination of existing indicators—it's a complete risk-managed trading framework with built-in analytics.

⚠️ Risk Disclaimer: This indicator is for educational purposes only. Past performance does not guarantee future results. Always use proper risk management and never risk more than you can afford to lose.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.