The "CZ Doji Strategy" combines various technical indicators and custom parameters to detect buy/sell signals, manage risk, and optimize trade entry points. Here's a breakdown of the parameters and components:
1. Key Input Parameters:
Key Value (keyValue): This parameter controls the sensitivity of the ATR trailing stop and risk management. Adjusting it allows fine-tuning of the stop-loss distance.
ATR Period (atrPeriod): Defines the lookback period for the Average True Range (ATR) calculation, which measures market volatility.
SMA Length (smaLength): Defines the period for the Simple Moving Average (SMA) filter, used to determine trend direction.
Risk-Reward Ratio (riskRewardRatio): Helps define the take-profit level relative to the stop-loss size.
Trade Range Multiplier (tradeRangeMultiplier): A multiplier that adjusts the trade range relative to the ATR value. Higher values widen the range of valid trade signals.
Enable High Frequency (enableHighFrequency): When enabled, reduces the lookback periods of certain indicators, making the strategy more reactive (for high-frequency trading).
2. User-Defined Moving Average:
MA Period (maPeriod): Period for calculating the moving average.
MA Shift (maShift): Shifts the moving average forward or backward, influencing entry/exit timing.
MA Method (maMethod): Select from Simple, Exponential, or Weighted moving averages. This flexibility lets users choose which type of MA best suits the market conditions they are trading.
3. Moving Average Calculation:
The script defaults to Simple Moving Average (SMA) but will switch to Exponential (EMA) or Weighted (WMA) based on user selection. The moving average is also shifted based on user input, which helps align the strategy’s signals with the user's preference.
4. HMA (Hull Moving Average) Plots:
20 HMA, 25 HMA, and 200 HMA: These Hull Moving Averages provide smoother trend detection and are used to filter out market noise.
HMA Lengths: These periods are used to plot different Hull MAs on the chart, indicating potential long-term and short-term trends.
5. ATR Trailing Stop:
The ATR Trailing Stop is calculated based on the ATR value and adjusts dynamically based on market volatility. It updates based on price movement and volatility to ensure that stop-loss levels adapt to current conditions.
xATRTrailingStop is the core element that determines if the trailing stop will be tightened (when the market goes in your favor) or loosened (when the market is volatile).
6. Buy/Sell Signal Conditions:
Buy Signal: Triggered when the price crosses over the ATR trailing stop and the price is above the SMA filter. Additionally, the distance between the close and the ATR trailing stop should meet the range multiplier condition.
Sell Signal: Triggered when the price crosses under the ATR trailing stop and the price is below the SMA filter, with a similar range multiplier condition for the short trades.
7. Risk Management:
The stop-loss is based on a multiple of the ATR (nLoss), and the take-profit level is set using the Risk-Reward Ratio. This ensures that trades follow the risk/reward rules set by the user.
Stop-Loss (stopLoss) and Take-Profit (takeProfit) are calculated dynamically based on market conditions.
8. Doji Detection:
A Doji candle is identified when the difference between the open and close prices is minimal, indicating market indecision.
The parameter Doji Size (dojiSize) controls the threshold for detecting Doji candles. If a candle meets the criteria, the strategy plots a "Doji" label on the chart.
9. Visual Elements:
The script plots various moving averages (SMA, HMA), buy/sell signals, and highlights candles where a Doji is detected. Bar colors change based on the trailing stop level, indicating market direction (green for bullish, red for bearish).
10. Alerts:
Buy/Sell Alerts are set to notify the trader when a buy or sell signal is generated based on the crossovers of the ATR trailing stop.
An alert condition is also set for Doji candles, allowing traders to get notified when indecision in the market is detected.
How to Use the Indicator:
Sensitivity Adjustments: Use the Key Value to adjust the sensitivity of the ATR trailing stop. A lower value makes the stop tighter and more reactive, while a higher value gives it more breathing room.
Risk-Reward Settings: Set your desired Risk-Reward Ratio and Trade Range Multiplier to determine your stop-loss and take-profit levels based on your risk tolerance.
Moving Average Settings: Choose between SMA, EMA, or WMA for the moving average filter, based on the trading style and market conditions.
Doji Alerts: Monitor for Doji candles if you want to trade around market indecision points.
High-Frequency Mode: Enable the High-Frequency Mode if you want a faster-reacting strategy for more frequent trading.
This strategy can be particularly useful for traders who want to optimize risk management while also identifying potential trend reversals or continuation points through the use of Doji candles, ATR trailing stops, and multiple moving averages.