INVITE-ONLY SCRIPT

GKD-M Stepped Baseline Optimizer [Loxx]

Updated
The Giga Kaleidoscope GKD-M Stepped Baseline Optimizer is a Metamorphosis module included in the "Giga Kaleidoscope Modularized Trading System."

█ Introduction

The GKD-M Stepped Baseline Optimizer is an advanced component of the Giga Kaleidoscope Modularized Trading System (GKD), designed to enhance trading strategy development by dynamically optimizing Baseline moving averages. This tool allows traders to evaluate over 65 moving averages, adjusting them across multiple periods to identify which settings yield the highest win rates for their trading strategies. The optimizer systematically tests these moving averages across specified timeframes and intervals, offering insights into net profit, total closed trades, win percentages, and other critical metrics for both long and short positions. Traders can define the initial period and incrementally adjust this value to explore a wide range of periods, thus fine-tuning their strategies with precision. What sets the GKD-M Stepped Baseline Optimizer apart is its unique capability to adapt the baseline moving average according to the highest win rates identified during backtesting, at each trading candle. This win-rate adaptive approach ensures that the trading system is always aligned with the most effective period settings for the selected moving average, enhancing the system's overall performance. Moreover, the 'stepped' aspect of this optimizer introduces a filtering process based ons, significantly reducing market noise and ensuring that identified trends are both significant and reliable. This feature is critical for traders looking to mitigate the risks associated with volatile market conditions and to capitalize on genuine market movements.In essence, the GKD-M Stepped Baseline Optimizer is tailored for traders who utilize the GKD trading system, offering a sophisticated tool to refine their baseline indicators dynamically, ensuring that their trading strategies are continuously optimized for maximum efficacy.

**the backtest data rendered to the chart above uses $5 commission per trade and 10% equity per trade with $1 million initial capital. Each backtest result for each ticker assumes these same inputs. The results are NOT cumulative, they are separate and isolated per ticker and trading side, long or short**

█ Core Features

Stepped Baseline for Noise Reduction

One of the hallmark features of the GKD-M Stepped Baseline Optimizer is its stepped baseline capability. This advanced functionality employs volatility filters to refine the selection of moving averages, significantly reducing market noise. The optimizer ensures that only substantial and reliable trends are considered, eliminating the false signals often caused by minor price fluctuations. This stepped approach to baseline optimization is critical for traders aiming to develop strategies that are both resilient and responsive to genuine market movements.

Dynamic Win Rate Adaptive Capability

Another cornerstone feature is the optimizer’s dynamic win rate adaptive capability. This unique aspect allows the optimizer to adjust the moving average period settings in real-time, based on the highest win rates derived from backtesting over a predefined range. At every trading candle, the optimizer evaluates a comprehensive set of backtesting data to ascertain the optimal period settings for the moving average in use. To perform the backtesting, the trader selects an initial period input (default is 60) and a skip value that increments the initial period input up to seven times. For instance, if a skip value of 5 is chosen, the Baseline Optimizer will run the backtest for the selected moving average on periods such as 60, 65, 70, 75, and so on, up to 90. If the user selects an initial period input of 45 and a skip value of 2, the Baseline Optimizer will conduct backtests for the chosen moving average on periods like 45, 47, 49, 51, and so forth, up to 57. The GKD-M Stepped Baseline Optimizer then exports the baseline with the highest cumulative win rate per candle to any baseline-enabled GKD backtest. This ensures that the baseline indicator remains continually aligned with the most efficacious parameters, dynamically adapting to changing market conditions.

Comprehensive Moving Averages Evaluation

The optimizer’s ability to test over 65 different moving averages across multiple periods stands as a testament to its comprehensive analytical capability. Traders have the flexibility to explore a wide array of moving averages, from traditional ones like the Simple Moving Average (SMA) and Exponential Moving Average (EMA) to more complex types such as the Hull Moving Average (HMA) and Adaptive Moving Average (AMA). This extensive evaluation allows traders to pinpoint the moving average that best aligns with their trading strategy and market conditions, further enhancing the system’s adaptability and effectiveness.

Volatility Filtering and Ticker Volatility Types

Incorporating a wide range of volatility types, including the option to utilize external volatility tickers like the VIX for filtering, adds another layer of sophistication to the optimizer. This feature allows traders to calibrate their baseline according to externals, providing an additional dimension of customization. Whether using standard deviation, ATR, or external volatility indices, traders can fine-tune their strategies to be responsive to the broader market sentiment and volatility trends.

█ Key Inputs

Baseline Settings

Baseline Source: Determines the price data (Open, High, Low, Close) used for moving average calculations.
Baseline Period: The starting period for moving average calculation.
Backtest Skip: Incremental steps for period adjustments in the optimization process.
Baseline Filter Type: Selection from over 65 moving averages for baseline calculation.

Volatility and Filter Settings

Price Filter Type & Moving Average Filter Type: Defines thement applied to the price or the moving average, enhancing filter specificity.
Filter Options: Allows users to select the application area of the volatility filter (price, moving average, or both).
Filter Multiplier & Period: Configures the intensity and temporal scope of the filter, fine-tuning sensitivity to market volatility.

Backtest Configuration

Window Period: Specifies the length of the backtesting window in days.
Backtest Type: Chooses between a fixed window or cumulative data approach for backtesting.
Initial Capital, Order Size, & Type: Sets the financial parameters for backtesting, including starting equity and the scale of trades.
Commission per Order: Accounts for trading costs within backtest profitability calculations.

Date and Time Range

From/Thru Year/Month/Day: Defines the historical period for strategy testing.
Entry Time: Specifies the time frame during which trades can be initiated, crucial for strategies sensitive to market timing.

Volatility Measurements for Goldie Locks Volatility Qualifiers

Mean Type & Period: Chooses the moving average type and period for volatility assessment.
Inner/Outer Volatility Qualifier Multipliers: Adjusts the boundaries for volatility-based trade qualification.
Activate Qualifier Boundaries: Enables or disables the upper and lower volatility qualifiers.

Advanced Volatility Inputs

Volatility Ticker Selection & Trading Days: Incorporates external volatility indices (e.g., VIX) into the strategy, adjusting for market volatility.
Static Percent, MAD Internal Filter Period, etc.: Provides fixed or adaptive volatility thresholds for filtering.

UI Customization

Baseline Width & Table Display Options: Customizes the visual representation of the baseline and the display of optimization results.
Table Header/Content Color & Text Size: Enhances readability and user interface aesthetics.

Export Options

Export Data: Selects the specific metric to be exported from the script, such as net profit or average profit per trade.

Moving Average Specific Parameters

Specific inputs tailored to the characteristics of selected moving averages (e.g., Fractal Adjusted (FRAMA), Least Squares Moving Average (LSMA), T3, etc.), allowing users to fine-tune the behavior of these averages based on unique formula requirements.

█ Indicator UI

snapshot

Long and Short Baselines: The optimizer differentiates trends through two distinct baselines: a green line for long (uptrend) baselines and a red line for short (downtrend) baselines. These baselines alternate activation based on the current trend direction as determined by the moving average plus length combination for the candle in view.

Ambiguity in market direction, when an uptrend and downtrend are concurrently indicated, is visually represented by yellow lines.
snapshot

Stepping Mechanism for Trend Visualization: Adjusting the source input and the moving average output based on volatility, the indicator exhibits a stepped appearance on the chart. This mechanism ensures that only substantial market movements, surpassing a specified volatility threshold, are recognized as trend changes.

Stepping Activated
snapshot

Goldilocks Zone: Beyond the long and short baselines, the Goldilocks zone introduces a distinct moving average that closely follows the selected price or source input, aiming to strike the perfect balance between not too much and not too little market movement for trading. The upper limit of the Goldilocks zone indicates a market stretch too far for advantageous trading (overextension), while the lower limit suggests inadequate market movement for entry (underextension). Trading within the Goldilocks zone is deemed optimal, as it signifies sufficient but not excessive volatility for entering trades, aligning with either the long or short baseline recommendations. Moreover, the mean of the Goldilocks zone serves as a critical indicator, offering a median reference point that aligns closely with the market's current state. This mean is pivotal for traders, as it represents a 'just right' condition for market entry, embodying the essence of the Goldilocks principle in financial trading strategies.

Signal Indicators and Entry Points: The chart includes with green or red dots to signify valid price points within the Goldilocks zone, indicative of conducive trading conditions. Furthermore, small directional arrows at the chart's bottom highlight potential long or short entry points, validated by the Goldilocks zone's parameters.

Data Table: A table presenting real-time statistics from the current candle backward through the chosen range offers insights into win rates and other relevant data, aiding in informed decision-making. This table adapts with each new candle, highlighting the most favorable win rates for both long and short positions.

█ Optimizing Strategy with Backtesting

Optimizing a trading strategy with backtesting involves rigorously testing the strategy on historical data to evaluate its performance and robustness before applying it in live markets. The GKD-M Stepped Baseline Optimizer incorporates advanced backtesting capabilities, offering both cumulative and rolling window types of backtests. Here's how each backtest type operates and the insights they provide for refining trading strategies:

Cumulative Backtest

Overview: A cumulative backtest evaluates a strategy's performance over a continuous period without resetting the strategy parameters or the simulated trading capital at the beginning of each new period.
Utility: This type is useful for understanding a strategy's long-term viability, assessing how it adapts to different market conditions over an extended timeframe.
Interpreting Statistics: Cumulative backtest results often focus on overall return, drawdowns, win rate, and the Sharpe ratio. A strategy with consistent returns, manageable drawdowns, a high win rate, and a favorable Sharpe ratio is considered robust.

Rolling Window Backtest

Overview: Unlike the cumulative approach, a rolling window backtest divides the historical data into smaller, overlapping or non-overlapping periods (windows), running the strategy separately on each. After each window, the strategy parameters and simulated trading capital are reset.
Utility: This method is invaluable for assessing a strategy's consistency and adaptability to various market phases. It helps identify if the strategy's performance is dependent on specific market conditions.
Interpreting Statistics: For rolling window backtests, consistency is key. Look for similar performance metrics (returns, drawdowns, win rate) across different windows. Variability in performance indicates sensitivity to market conditions, suggesting the need for strategy adjustments.

Strategy Refinement Through Backtest Statistics

Net Profit and Loss: Measures the strategy’s overall effectiveness. Consistent profitability across different market conditions is a positive indicator.
Win Rate and Profit Factor: High win rates and profit factors indicate a strategy's efficiency in capturing gains over losses.
Average Profit per Trade: Understanding the strategy's ability to generate profit on a per-trade basis can highlight its operational efficiency.
Average Number of Bars in Trade: This metric helps understand the strategy's market exposure and timing efficiency.

█ Exporting Data and Integration with GKD Backtests

The GKD-M Stepped Baseline Optimizer seamlessly integrates with the broader GKD trading system, allowing traders to export the optimization data and leverage it within the various GKD backtest modules. This feature allows users to forward the GKD-M Stepped Baseline Optimizer adaptive signals to a GKD backtest to be used as a Baseline component in a GKD trading system.

█ Moving Averages included in the Stepped Baseline Optimizer

The GKD-M Stepped Baseline Optimizer incorporates an extensive array of over 65 moving averages, each with unique characteristics and implications for trading strategy development. This comprehensive suite enables traders to conduct nuanced analysis and optimization, ensuring the selection of the most effective moving average for Baseline input into their GKD trading system.

Adaptive Moving Average - AMA
ADXvma - Average Directional Volatility Moving Average
Ahrens Moving Average
Alexander Moving Average - ALXMA
Coral
Deviation Scaled Moving Average - DSMA
Donchian
Double Exponential Moving Average - DEMA
Double Smoothed Exponential Moving Average - DSEMA
Double Smoothed FEMA - DSFEMA
Double Smoothed Range Weighted EMA - DSRWEMA
Double Smoothed Wilders EMA - DSWEMA
Double Weighted Moving Average - DWMA
Ehlers Optimal Tracking Filter - EOTF
Exponential Moving Average - EMA
Fast Exponential Moving Average - FEMA
Fractal Adaptive Moving Average - FRAMA
Generalized DEMA - GDEMA
Generalized Double DEMA - GDDEMA
Geometric Mean Moving Average
Hull Moving Average (Type 1) - HMA1
Hull Moving Average (Type 2) - HMA2
Hull Moving Average (Type 3) - HMA3
Hull Moving Average (Type 4) - HMA4
IE/2 - Early T3 by Tim Tilson
Integral of Linear Regression Slope - ILRS
Instantaneous Trendline
Kalman Filter
Kaufman Adaptive Moving Average - KAMA
Laguerre Filter
Leader Exponential Moving Average
Linear Regression Value - LSMA (Least Squares Moving Average)
Linear Weighted Moving Average - LWMA
McGinley Dynamic
McNicholl EMA
Non-Lag Moving Average
Ocean NMA Moving Average - ONMAMA
One More Moving Average - OMA
Parabolic Weighted Moving Average
Probability Density Function Moving Average - PDFMA
Quadratic Regression Moving Average - QRMA
Range Filter
Range Weighted EMA - RWEMA
Recursive Moving Trendline
Regularized EMA - REMA
Simple Decycler - SDEC
Simple Loxx Moving Average - SLMA
Simple Moving Average - SMA
Sine Weighted Moving Average
Smoothed LWMA - SLWMA
Smoothed Moving Average - SMMA
Smoother
Super Smoother
T3
Tether Lines
Three-pole Ehlers Butterworth
Three-pole Ehlers Smoother
Triangular Moving Average - TMA
Triangle Moving Average Generalized
Triple Exponential Moving Average - TEMA
Two-pole Ehlers Butterworth
Two-pole Ehlers smoother
Ultimate Smoother
Variable Index Dynamic Average - VIDYA
Variable Moving Average - VMA
Volume Weighted EMA - VEMA
Volume Weighted Moving Average - VWMA
Zero-Lag DEMA - Zero Lag Double Exponential Moving Average
Zero-Lag Moving Average
Zero Lag TEMA - Zero Lag Triple Exponential Moving Average

█ Volatility Types and Filtering

The GKD-M Stepped Baseline Optimizer features a comprehensive selection of over 15 volatility types, each tailored to capture different aspects of market behavior and risk.

Volatility Ticker Selection: Enables direct incorporation of external volatility indicators like VIX and EUVIX into the script for market sentiment analysis, signal filtering enhancement, and real-time risk management adjustments.

Standard Deviation of Logarithmic Returns: Quantifies asset volatility using the standard deviation applied to logarithmic returns, capturing symmetric price movements and financial returns' compound nature.

Exponential Weighted Moving Average (EWMA) for Volatility: Focuses on recent market information by applying exponentially decreasing weights to squared logarithmic returns, offering a dynamic view of market volatility.

Roger-Satchell Volatility Measure: Estimates asset volatility by analyzing the high, low, open, and close prices, providing a nuanced view of intraday volatility and market dynamics.

Close-to-Close Volatility Measure: Calculates volatility based on the closing prices of stocks, offering a streamlined but limited perspective on market behavior.

Parkinson Volatility Measure: Enhances volatility estimation by including high and low prices of the trading day, capturing a more accurate reflection of intraday market movements.

Garman-Klass Volatility Measure: Incorporates open, high, low, and close prices for a comprehensive daily volatility measure, capturing significant price movements and market activity.

Yang-Zhang Volatility Measure: Offers an efficient estimation of stock market volatility by combining overnight and intraday price movements, capturing opening jumps and overall market dynamics.

Garman-Klass-Yang-Zhang Volatility Measure: Merges the benefits of Garman-Klass and Yang-Zhang measures, providing a fuller picture of market volatility including opening market reactions.

Pseudo GARCH(2,2) Volatility Model: Mimics a GARCH(2,2) process using exponential moving averages of squared returns, highlighting volatility shocks and their future impact.

ER-Adaptive Average True Range (ATR): Adjusts the ATR period length based on market efficiency, offering a volatility measure that adapts to changing market conditions.

Adaptive Deviation: Dynamically adjusts its calculation period to offer a nuanced measure of volatility that responds to the market's intrinsic rhythms.

Median Absolute Deviation (MAD): Provides a robust measure of statistical variability, focusing on deviations from the median price, offering resilience against outliers.

Mean Absolute Deviation (MAD): Measures the average magnitude of deviations from the mean price, facilitating a straightforward understanding of volatility.

ATR (Average True Range): Finds the average of true ranges over a specified period, indicating the expected price movement and market volatility.

True Range Double (TRD): Offers a nuanced view of volatility by considering a broader range of price movements, identifying significant market sentiment shifts.
Release Notes
Fixed signal error when exporting to backtest.
Release Notes
Small UI fix.
Release Notes
Fixed small signal error.
Release Notes
Updated HMA calculation
Release Notes
Updated stepping function.
backtestingbaselinegigakaleidoscopeGKDgkdmloxxmetamorphosisMoving Averagesstepped

Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact loxx for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases, you can find a good open-source alternative for free in our Community Scripts.

Author's instructions

This indicator is only available to ALGX Trading VIP group members. For instructions on how to access, send me a private message here on TradingView or message me using the contact information listed in my TradingView profile.

Want to use this script on a chart?

Warning: please read before requesting access.

Public Telegram Group, t.me/algxtrading_public

VIP Membership Info: patreon.com/algxtrading/membership
Also on:

Disclaimer