该策略是一个结合了技术分析中经典的均线交叉和K线形态识别的智能交易系统。策略通过分析K线的上下影线与实体的关系,结合双均线交叉信号,实现对市场趋势转折点的精准捕捉。系统不仅关注价格走势,还通过计算平均波幅来动态调整交易参数,提高策略的适应性。
策略的核心逻辑分为两个主要部分: 1. K线形态识别模块通过计算上下影线与实体的比例关系来识别潜在的反转信号。系统设定了可调节的影线倍数参数(wickMultiplier)和实体百分比参数(bodyPercentage)用于优化信号质量。当K线出现符合条件的长上影线或长下影线时,系统会发出相应的做多或做空信号。
该策略通过结合K线形态识别和均线交叉系统,构建了一个相对完整的交易决策框架。策略的优势在于其严格的信号筛选机制和灵活的参数调节能力,但同时也需要注意参数优化和市场环境适应性的问题。通过持续优化和完善,该策略有望在不同市场环境下都能保持稳定的表现。
/*backtest
start: 2024-10-28 00:00:00
end: 2024-11-27 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5 indicator("Wick Reversal Setup", overlay=true)
// Input parameters
wickMultiplier = input.float(3.5, title="Wick Multiplier", minval=0.5, maxval=20)
bodyPercentage = input.float(0.25, title="Body Percentage", minval=0.1, maxval=1.0)
// Calculate the average range over 50 periods
avgRange = ta.sma(high - low, 50)
// Define the lengths of wicks and bodies
bodyLength = math.abs(close - open)
upperWickLength = high - math.max(close, open)
lowerWickLength = math.min(close, open) - low
totalRange = high - low
// Long signal conditions
longSignal = (close > open and upperWickLength >= bodyLength * wickMultiplier and upperWickLength <= totalRange * bodyPercentage) or
(close < open and lowerWickLength >= bodyLength * wickMultiplier and upperWickLength <= totalRange * bodyPercentage) or
(close == open and close != high and upperWickLength >= bodyLength * wickMultiplier and upperWickLength <= totalRange * bodyPercentage) or
(open == high and close == high and totalRange >= avgRange)
// Short signal conditions
shortSignal = (close < open and (high - open) >= bodyLength * wickMultiplier and lowerWickLength <= totalRange * bodyPercentage) or
(close > open and (high - close) >= bodyLength * wickMultiplier and lowerWickLength <= totalRange * bodyPercentage) or
(close == open and close != low and lowerWickLength >= bodyLength * wickMultiplier and lowerWickLength <= totalRange * bodyPercentage) or
(open == low and close == low and totalRange >= avgRange)
// Plot signals
plotshape(series=longSignal, location=location.belowbar, color=color.green, style=shape.labelup, text="Long")
plotshape(series=shortSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="Short")
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sahaj_Beriwal
//@version=5
strategy("My strategy", overlay=true, margin_long=100, margin_short=100)
longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if (longCondition)
strategy.entry("L", strategy.long)
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if (shortCondition)
strategy.entry("S", strategy.short)