This strategy is a quantitative trading system based on candlestick technical analysis, primarily identifying potential trading opportunities by analyzing the total length of candlestick upper and lower wicks. The core mechanism compares real-time calculated total wick length with an offset-adjusted moving average, generating long signals when the wick length breaks through the moving average. The strategy integrates multiple types of moving averages, including Simple Moving Average (SMA), Exponential Moving Average (EMA), Weighted Moving Average (WMA), and Volume Weighted Moving Average (VWMA), providing traders with flexible parameter selection options.
The core logic includes the following key steps:
This strategy combines classic technical indicators of candlestick wick analysis with modern quantitative trading methods, creating a trading system with clear logic and strong practicality. The core advantages lie in parameter flexibility and comprehensive risk control, though limitations include strong market environment dependency and parameter sensitivity. Significant improvement potential exists through multi-dimensional indicator integration and position management optimization. Overall, it represents a fundamentally sound and logically coherent quantitative trading strategy suitable for further development and optimization.
/*backtest start: 2019-12-23 08:00:00 end: 2025-01-04 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=6 strategy("Daytrading ES Wick Length Strategy", overlay=true) // Input parameters ma_length = input.int(20, title="Moving Average Length", minval=1) ma_type = input.string("VWMA", title="Type of Moving Average", options=["SMA", "EMA", "WMA", "VWMA"]) ma_offset = input.float(10, title="MA Offset (Points)", step=1) hold_periods = input.int(18, title="Holding Period (Bars)", minval=1) // Calculating upper and lower wick lengths upper_wick_length = high - math.max(close, open) lower_wick_length = math.min(close, open) - low // Total wick length (upper + lower) total_wick_length = upper_wick_length + lower_wick_length // Calculate the moving average based on the selected method ma = switch ma_type "SMA" => ta.sma(total_wick_length, ma_length) "EMA" => ta.ema(total_wick_length, ma_length) "WMA" => ta.wma(total_wick_length, ma_length) "VWMA" => ta.vwma(total_wick_length, ma_length) // Add the offset to the moving average ma_with_offset = ma + ma_offset // Entry condition: wick length exceeds MA with offset long_entry_condition = total_wick_length > ma_with_offset // Long entry if (long_entry_condition) strategy.entry("Long", strategy.long) // Automatic exit after holding period if strategy.position_size > 0 and bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1) >= hold_periods strategy.close("Long") // Plot the total wick length as a histogram plot(total_wick_length, color=color.blue, style=plot.style_histogram, linewidth=2, title="Total Wick Length") // Plot the moving average with offset plot(ma_with_offset, color=color.yellow, linewidth=2, title="MA of Wick Length (Offset)")