Williams Alligator-RSI Multi-Confirmation Trading Strategy

RSI SMA 威廉鳄鱼指标 相对强弱指标 交叉确认
Created on: 2025-08-19 12:00:45 Modified on: 2025-08-19 12:00:45
Copy: 0 Number of hits: 274
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 Williams Alligator-RSI Multi-Confirmation Trading Strategy  Williams Alligator-RSI Multi-Confirmation Trading Strategy

Overview

This strategy is a multi-confirmation trading system based on the Williams Alligator indicator and the Relative Strength Index (RSI), specifically designed for a 15-minute timeframe. The strategy generates trading signals by analyzing the position relationships between price and the Alligator’s three lines (Lips, Teeth, and Jaw) along with RSI values. A buy signal requires four conditions: closing price above the Lips line, Lips above Teeth, Teeth above Jaw, and RSI greater than 55. Conversely, a sell signal requires closing price below Lips, Lips below Teeth, Teeth below Jaw, and RSI less than 45. The strategy also includes strict stop-loss and take-profit rules to ensure controlled risk and timely profit realization.

Strategy Principles

The core principle of this strategy is based on the combined use of the Williams Alligator indicator and RSI. The Williams Alligator consists of three moving averages: Jaw (blue, 13-period SMA, offset by 8 periods), Teeth (red, 8-period SMA, offset by 5 periods), and Lips (green, 5-period SMA, offset by 3 periods). The arrangement of these three lines and price crossovers can indicate the direction and strength of market trends.

When the Lips line is above the Teeth line, and the Teeth line is above the Jaw line, it indicates an uptrend; conversely, when the Lips line is below the Teeth line, and the Teeth line is below the Jaw line, it indicates a downtrend. Additionally, the strategy incorporates RSI for confirmation, with values above 55 supporting long positions and values below 45 supporting short positions, providing additional confirmation signals for trading decisions.

During strategy execution, the system monitors multiple stop-loss conditions: for long positions, stop-loss triggers when RSI drops below 50, closing price falls below the Teeth line, or the Lips line falls below the Teeth line; for short positions, stop-loss triggers when RSI rises above 50, closing price breaks above the Teeth line, or the Lips line rises above the Teeth line. Take-profit is set at 2 ticks above or below the entry price.

Strategy Advantages

  1. Multiple Confirmation Mechanism: The strategy requires four conditions to be simultaneously met for entry, effectively reducing false signals and improving trade quality. The arrangement of the Alligator’s three lines confirms the trend direction, while the RSI value confirms momentum.

  2. Clear Entry and Exit Rules: The strategy provides clear entry signals and exit conditions, reducing subjective judgment and making the trading process more standardized and disciplined.

  3. Comprehensive Risk Control: The strategy sets multiple stop-loss conditions, including RSI reversal signals, changes in price relationship with the Teeth line, and changes in the relative position of Lips and Teeth lines. This multi-layered risk control mechanism helps to cut losses timely and control the maximum risk of a single trade.

  4. Visual Feedback: The strategy marks buy signals, sell signals, stop-losses, and take-profits on the chart, and displays the status of various conditions in real-time through a table, greatly enhancing the visualization of the trading process.

  5. High Adaptability: Although the strategy parameters have default settings, all key parameters can be adjusted through inputs, allowing traders to optimize according to different market environments or personal preferences.

Strategy Risks

  1. Frequent Trading in Choppy Markets: In markets with small fluctuations, prices may frequently cross the Alligator lines, and RSI may fluctuate around threshold values, leading to excessive trading signals and frequent entries/exits, increasing transaction costs. The solution is to add confirmation conditions or extend the observation period.

  2. Slippage Risk in Rapid Large Movements: In cases of sudden major market news causing rapid and significant price movements, the actual execution price may differ substantially from the price at signal triggering, increasing slippage risk. It is advisable to use caution or temporarily suspend the strategy before major data releases.

  3. Conservative Profit Targets: The strategy sets profit targets at just 2 ticks, which may be too conservative in volatile markets, failing to fully capitalize on trending markets. Consider dynamically adjusting profit targets based on market volatility or implementing a scaled exit strategy.

  4. Indicator Lag: Both the Williams Alligator and RSI have inherent lag, which may fail to capture turning points timely in rapidly changing markets. It is recommended to combine with other leading indicators or price action analysis for auxiliary judgment.

  5. Parameter Sensitivity: Strategy performance is sensitive to parameter settings, especially RSI threshold values. Different parameter combinations may perform differently in various market environments, requiring backtesting to find the optimal parameter set.

Strategy Optimization Directions

  1. Dynamic RSI Thresholds: The current strategy uses fixed RSI thresholds (55 and 45). Consider dynamically adjusting these thresholds based on market volatility—using looser thresholds in high-volatility markets and stricter thresholds in low-volatility markets to adapt to different market environments.

  2. Add Trading Filters: Introduce volume confirmation, volatility filters, or trend strength indicators to filter out weak signals in choppy markets and only enter when trends are clear, improving win rates.

  3. Optimize Take-Profit Strategy: The current fixed 2-tick take-profit strategy is overly simplistic. Consider implementing a dynamic take-profit strategy, such as trailing stops or ATR-based (Average True Range) take-profits, to capture more gains in strong trending markets.

  4. Time Filtering: Add time filtering functionality to avoid periods of insufficient liquidity or abnormal volatility, such as 15 minutes before and after market opening or during important data release periods, to reduce unnecessary risks.

  5. Capital Management Optimization: The current strategy uses a fixed percentage (100%) of equity for trading. Consider dynamically adjusting position sizes based on market volatility or changes in account equity to implement more scientific capital management.

Summary

The Williams Alligator-RSI Multi-Confirmation Trading Strategy is a well-structured and logically clear trading system that integrates the trend identification capabilities of the Williams Alligator indicator with the momentum confirmation function of RSI to establish a multi-layered trading decision framework. The main advantages of this strategy lie in its multiple confirmation mechanisms and comprehensive risk control, but it also faces challenges such as excessive signals in choppy markets, slippage risk, and conservative profit targets.

Through optimizations such as dynamic RSI threshold adjustment, adding trading filters, improving take-profit strategies, incorporating time filtering, and enhancing capital management, this strategy has the potential to further improve its stability and profitability. Overall, this is a practical quantitative trading strategy suitable for traders who have a certain understanding of technical indicators and hope to achieve stable returns in the futures market.

Strategy source code
/*backtest
start: 2024-08-19 00:00:00
end: 2025-08-18 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_OKX","currency":"ETH_USDT","balance":5000}]
*/

//@version=5
strategy("Natural Gas Alligator RSI Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// =====================================
// INPUTS
// =====================================
// Williams Alligator Settings (default)
jaw_length = input.int(13, title="Jaw Length", minval=1)
jaw_offset = input.int(8, title="Jaw Offset", minval=0)
teeth_length = input.int(8, title="Teeth Length", minval=1)
teeth_offset = input.int(5, title="Teeth Offset", minval=0)
lips_length = input.int(5, title="Lips Length", minval=1)
lips_offset = input.int(3, title="Lips Offset", minval=0)

// RSI Settings (default)
rsi_length = input.int(14, title="RSI Length", minval=1)

// Natural Gas tick size (typically 0.001)
tick_size = input.float(0.001, title="Tick Size", minval=0.0001, step=0.0001)

// =====================================
// INDICATORS
// =====================================
// Williams Alligator
jaw = ta.sma(hl2, jaw_length)[jaw_offset]
teeth = ta.sma(hl2, teeth_length)[teeth_offset]
lips = ta.sma(hl2, lips_length)[lips_offset]

// RSI
rsi = ta.rsi(close, rsi_length)

// =====================================
// PLOT INDICATORS
// =====================================
plot(jaw, "Alligator Jaw", color=color.blue, linewidth=2)
plot(teeth, "Alligator Teeth", color=color.red, linewidth=2)
plot(lips, "Alligator Lips", color=color.green, linewidth=2)

// RSI (plotted in separate pane)
hline(50, "RSI Mid Line", color=color.gray, linestyle=hline.style_dashed)
hline(55, "RSI Buy Level", color=color.green, linestyle=hline.style_dotted)
hline(45, "RSI Sell Level", color=color.red, linestyle=hline.style_dotted)
plot(rsi, "RSI", color=color.purple)

// =====================================
// STRATEGY CONDITIONS
// =====================================

// Buy Conditions
buy_condition_1 = close > lips
buy_condition_2 = lips > teeth
buy_condition_3 = teeth > jaw
buy_condition_4 = rsi > 55

buy_signal = buy_condition_1 and buy_condition_2 and buy_condition_3 and buy_condition_4

// Sell Conditions
sell_condition_1 = close < lips
sell_condition_2 = lips < teeth
sell_condition_3 = teeth < jaw
sell_condition_4 = rsi < 45

sell_signal = sell_condition_1 and sell_condition_2 and sell_condition_3 and sell_condition_4

// Stop Loss Conditions for Long Position
long_stop_condition_1 = rsi < 50
long_stop_condition_2 = ta.crossunder(close, teeth)
long_stop_condition_3 = lips < teeth

long_stop_loss = long_stop_condition_1 or long_stop_condition_2 or long_stop_condition_3

// Stop Loss Conditions for Short Position
short_stop_condition_1 = rsi > 50
short_stop_condition_2 = ta.crossover(close, teeth)
short_stop_condition_3 = lips > teeth

short_stop_loss = short_stop_condition_1 or short_stop_condition_2 or short_stop_condition_3

// =====================================
// STRATEGY EXECUTION
// =====================================

// Variables to track entry prices
var float long_entry_price = na
var float short_entry_price = na

// Long Entry
if buy_signal and strategy.position_size == 0
    strategy.entry("Long", strategy.long)
    long_entry_price := close
    alert("Buy Signal Generated", alert.freq_once_per_bar)

// Short Entry
if sell_signal and strategy.position_size == 0
    strategy.entry("Short", strategy.short)
    short_entry_price := close
    alert("Sell Signal Generated", alert.freq_once_per_bar)

// Long Exit Conditions
if strategy.position_size > 0
    // Take Profit: 2 ticks above entry
    long_take_profit = long_entry_price + (2 * tick_size)
    
    if close >= long_take_profit
        strategy.close("Long", comment="Take Profit")
        alert("Take Profit - Long Position Closed", alert.freq_once_per_bar)
        long_entry_price := na
    
    // Stop Loss
    if long_stop_loss
        strategy.close("Long", comment="Stop Loss")
        alert("Stop Loss - Long Position Closed", alert.freq_once_per_bar)
        long_entry_price := na

// Short Exit Conditions
if strategy.position_size < 0
    // Take Profit: 2 ticks below entry
    short_take_profit = short_entry_price - (2 * tick_size)
    
    if close <= short_take_profit
        strategy.close("Short", comment="Take Profit")
        alert("Take Profit - Short Position Closed", alert.freq_once_per_bar)
        short_entry_price := na
    
    // Stop Loss
    if short_stop_loss
        strategy.close("Short", comment="Stop Loss")
        alert("Stop Loss - Short Position Closed", alert.freq_once_per_bar)
        short_entry_price := na

// =====================================
// CHART LABELS AND ALERTS
// =====================================

// Buy Signal Label
if buy_signal and strategy.position_size == 0
    label.new(bar_index, low - (high - low) * 0.1, "BUY\nSIGNAL", 
              color=color.green, style=label.style_label_up, 
              textcolor=color.white, size=size.small)

// Sell Signal Label
if sell_signal and strategy.position_size == 0
    label.new(bar_index, high + (high - low) * 0.1, "SELL\nSIGNAL", 
              color=color.red, style=label.style_label_down, 
              textcolor=color.white, size=size.small)

// Stop Loss Labels
if strategy.position_size > 0 and long_stop_loss
    label.new(bar_index, high + (high - low) * 0.1, "STOP\nLOSS", 
              color=color.orange, style=label.style_label_down, 
              textcolor=color.white, size=size.small)

if strategy.position_size < 0 and short_stop_loss
    label.new(bar_index, low - (high - low) * 0.1, "STOP\nLOSS", 
              color=color.orange, style=label.style_label_up, 
              textcolor=color.white, size=size.small)

// Take Profit Labels
if strategy.position_size > 0 and not na(long_entry_price) and close >= (long_entry_price + (2 * tick_size))
    label.new(bar_index, high + (high - low) * 0.1, "TAKE\nPROFIT", 
              color=color.blue, style=label.style_label_down, 
              textcolor=color.white, size=size.small)

if strategy.position_size < 0 and not na(short_entry_price) and close <= (short_entry_price - (2 * tick_size))
    label.new(bar_index, low - (high - low) * 0.1, "TAKE\nPROFIT", 
              color=color.blue, style=label.style_label_up, 
              textcolor=color.white, size=size.small)

// =====================================
// TABLE FOR CURRENT CONDITIONS
// =====================================
var table info_table = table.new(position.top_right, 2, 8, bgcolor=color.white, border_width=1)

if barstate.islast
    table.cell(info_table, 0, 0, "Condition", bgcolor=color.gray, text_color=color.white)
    table.cell(info_table, 1, 0, "Status", bgcolor=color.gray, text_color=color.white)
    
    table.cell(info_table, 0, 1, "Close > Lips", bgcolor=color.white)
    table.cell(info_table, 1, 1, buy_condition_1 ? "✓" : "✗", text_color=buy_condition_1 ? color.green : color.red)
    
    table.cell(info_table, 0, 2, "Lips > Teeth", bgcolor=color.white)
    table.cell(info_table, 1, 2, buy_condition_2 ? "✓" : "✗", text_color=buy_condition_2 ? color.green : color.red)
    
    table.cell(info_table, 0, 3, "Teeth > Jaw", bgcolor=color.white)
    table.cell(info_table, 1, 3, buy_condition_3 ? "✓" : "✗", text_color=buy_condition_3 ? color.green : color.red)
    
    table.cell(info_table, 0, 4, "RSI > 55", bgcolor=color.white)
    table.cell(info_table, 1, 4, buy_condition_4 ? "✓" : "✗", text_color=buy_condition_4 ? color.green : color.red)
    
    table.cell(info_table, 0, 5, "RSI < 45", bgcolor=color.white)
    table.cell(info_table, 1, 5, sell_condition_4 ? "✓" : "✗", text_color=sell_condition_4 ? color.red : color.green)
    
    table.cell(info_table, 0, 6, "Current RSI", bgcolor=color.white)
    table.cell(info_table, 1, 6, str.tostring(math.round(rsi, 2)), text_color=color.black)
    
    table.cell(info_table, 0, 7, "Position", bgcolor=color.white)
    position_text = strategy.position_size > 0 ? "LONG" : strategy.position_size < 0 ? "SHORT" : "NONE"
    position_color = strategy.position_size > 0 ? color.green : strategy.position_size < 0 ? color.red : color.gray
    table.cell(info_table, 1, 7, position_text, text_color=position_color)