OPEN-SOURCE SCRIPT

Dskyz (DAFE) MAtrix with ATR-Powered Precision

746
Dskyz (DAFE) MAtrix with ATR-Powered Precision

This cutting‐edge futures trading strategy built to thrive in rapidly changing market conditions. Developed for high-frequency futures trading on instruments such as the CME Mini MNQ, this strategy leverages a matrix of sophisticated moving averages combined with ATR-based filters to pinpoint high-probability entries and exits. Its unique combination of adaptable technical indicators and multi-timeframe trend filtering sets it apart from standard strategies, providing enhanced precision and dynamic responsiveness.
https://imgur.com/a/AAlunm1

Core Functional Components


1. Advanced Moving Averages
A distinguishing feature of the DAFE strategy is its robust, multi-choice moving averages (MAs). Clients can choose from a wide array of MAs—each with specific strengths—in order to fine-tune their trading signals. The code includes user-defined functions for the following MAs:
https://imgur.com/BxGOAxJ

Hull Moving Average (HMA):
The hma(src, len) function calculates the HMA by using weighted moving averages (WMAs) to reduce lag considerably while smoothing price data. This function computes an intermediate WMA of half the specified length, then a full-length WMA, and finally applies a further WMA over the square root of the length. This design allows for rapid adaptation to price changes without the typical delays of traditional moving averages.

Triple Exponential Moving Average (TEMA):
Implemented via tema(src, len), TEMA uses three consecutive exponential moving averages (EMAs) to effectively cancel out lag and capture price momentum. The final formula—3 * (ema1 - ema2) + ema3—produces a highly responsive indicator that filters out short-term noise.

Double Exponential Moving Average (DEMA):
Through the dema(src, len) function, DEMA calculates an EMA and then a second EMA on top of it. Its simplified formula of 2 * ema1 - ema2 provides a smoother curve than a single EMA while maintaining enhanced responsiveness.

Volume Weighted Moving Average (VWMA):
With vwma(src, len), this MA accounts for trading volume by weighting the price, thereby offering a more contextual picture of market activity. This is crucial when volume spikes indicate significant moves.

Zero Lag EMA (ZLEMA):
The zlema(src, len) function applies a correction to reduce the inherent lag found in EMAs. By subtracting a calculated lag (based on half the moving average window), ZLEMA is exceptionally attuned to recent price movements.

Arnaud Legoux Moving Average (ALMA):
The alma(src, len, offset, sigma) function introduces ALMA—a type of moving average designed to be less affected by outliers. With parameters for offset and sigma, it allows customization of the degree to which the MA reacts to market noise.

Kaufman Adaptive Moving Average (KAMA):
The custom kama(src, len) function is noteworthy for its adaptive nature. It computes an efficiency ratio by comparing price change against volatility, then dynamically adjusts its smoothing constant. This results in an MA that quickly responds during trending periods while remaining smoothed during consolidation.

Each of these functions—integrated into the strategy—is selectable by the trader (via the fastMAType and slowMAType inputs). This flexibility permits the tailored application of the MA most suited to current market dynamics and individual risk management preferences.

2. ATR-Based Filters and Risk Controls
ATR Calculation and Volatility Filter:
The strategy computes the Average True Range (ATR) over a user-defined period (atrPeriod). ATR is then used to derive both:

Volatility Assessment: Expressed as a ratio of ATR to closing price, ensuring that trades are taken only when volatility remains within a safe, predefined threshold (volatilityThreshold).

ATR-Based Entry Filters: Implemented as atrFilterLong and atrFilterShort, these conditions ensure that for long entries the price is sufficiently above the slow MA and vice versa for shorts. This acts as an additional confirmation filter.

Dynamic Exit Management:
The exit logic employs a dual approach:

Fixed Stop and Profit Target: Stops and targets are set at multiples of ATR (fixedStopMultiplier and profitTargetATRMult), helping manage risk in volatile markets.

Trailing Stop Adjustments: A trailing stop is calculated using the ATR multiplied by a user-defined offset (trailOffset), which captures additional profits as the trade moves favorably while protecting against reversals.

3. Multi-Timeframe Trend Filtering
The strategy enhances its signal reliability by leveraging a secondary, higher timeframe analysis:

15-Minute Trend Analysis:
By retrieving 15-minute moving averages (fastMA15m and slowMA15m) via request.security, the strategy determines the broader market trend. This secondary filter (enabled or disabled through useTrendFilter) ensures that entries are aligned with the prevailing market direction, thereby reducing the incidence of false signals.

4. Signal and Execution Logic
Combined MA Alignment:
The entry conditions are based primarily on the alignment of the fast and slow MAs. A long condition is triggered when the current price is above both MAs and the fast MA is above the slow MA—complemented by the ATR filter and volume conditions. The reverse applies for a short condition.

Volume and Time Window Validation:
Trades are permitted only if the current volume exceeds a minimum (minVolume) and the current hour falls within the predefined trading window (tradingStartHour to tradingEndHour). An additional volume spike check (comparing current volume to a moving average of past volumes) further filters for optimal market conditions.

Comprehensive Order Execution:
The strategy utilizes flexible order execution functions that allow pyramiding (up to 10 positions), ensuring that it can scale into positions as favorable conditions persist. The use of both market entries and automated exits (with profit targets, stop-losses, and trailing stops) ensures that risk is managed at every step.

5. Integrated Dashboard and Metrics
For transparency and real-time analysis, the strategy includes:

On-Chart Visualizations:
Both fast and slow MAs are plotted on the chart, making it easy to see the market’s technical foundation.

Dynamic Metrics Dashboard:
A built-in table displays crucial performance statistics—including current profit/loss, equity, ATR (both raw and as a percentage), and the percentage gap between the moving averages. These metrics offer immediate insight into the health and performance of the strategy.

Input Parameters: Detailed Breakdown
Every input is meticulously designed to offer granular control:

[MA] Fast & Slow Lengths:
Determine the window size for the fast and slow moving averages. Smaller values yield more sensitivity, while larger values provide a smoother, delayed response.

Fast/Slow MA Types:
Choose the type of moving average for fast and slow signals. The versatility—from basic SMA and EMA to more complex ones like HMA, TEMA, ZLEMA, ALMA, and KAMA—allows customization to fit different market scenarios.

ATR Parameters:
atrPeriod and atrMultiplier shape the volatility assessment, directly affecting entry filters and risk management through stop-loss and profit target levels.

Trend and Volume Filters:
Inputs such as useTrendFilter, minVolume, and the volume spike condition help confirm that a trade occurs in active, trending markets rather than during periods of low liquidity or market noise.

Trading Hours:
Restricting trade execution to specific hours (tradingStartHour and tradingEndHour) helps avoid illiquid or choppy markets outside of prime trading sessions.

Exit Strategies:
Parameters like trailOffset, profitTargetATRMult, and fixedStopMultiplier provide multiple layers of risk management and profit protection by tailoring how exits are generated relative to current market conditions.

Pyramiding and Fixed Trade Quantity:
The strategy supports multiple entries within a trend (up to 10 positions) and sets a predefined trade quantity (fixedQuantity) to maintain consistent exposure and risk per trade.

Dashboard Controls:
The resetDashboard input allows for on-the-fly resetting of performance metrics, keeping the strategy’s performance dashboard accurate and up-to-date.

Why This Strategy is Truly Exceptional

Multi-Faceted Adaptability:
The ability to switch seamlessly between various moving average types—each suited to particular market conditions—enables the strategy to adapt dynamically. This is a testament to the high level of coding sophistication and market insight infused within the system.

Robust Risk Management:
The integration of ATR-based stops, profit targets, and trailing stops ensures that every trade is executed with well-defined risk parameters. The system is designed to mitigate unexpected market swings while optimizing profit capture.

Comprehensive Market Filtering:
By combining moving average crossovers with volume analysis, volatility thresholds, and multi-timeframe trend filters, the strategy only enters trades under the most favorable conditions. This multi-layered filtering reduces noise and enhances signal quality.

-Final Thoughts-
The Dskyz Adaptive Futures Elite (DAFE) MAtrix with ATR-Powered Precision strategy is not just another trading algorithm—it is a multi-dimensional, fully customizable system built on advanced technical principles and sophisticated risk management techniques. Every function and input parameter has been carefully engineered to provide traders with a system that is both powerful and transparent.

For clients seeking a state-of-the-art trading solution that adapts dynamically to market conditions while maintaining strict discipline in risk management, this strategy truly stands in a class of its own.

****Please show support if you enjoyed this strategy. I'll have more coming out in the near future!!

-Dskyz

Caution

DAFE is experimental, not a profit guarantee. Futures trading risks significant losses due to leverage. Backtest, simulate, and monitor actively before live use. All trading decisions are your responsibility.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.