该策略是一个基于相对强弱指标(RSI)的自动化交易系统,主要通过识别市场超卖条件来捕捉潜在的反弹机会。策略采用递进式建仓方式,在RSI低位交叉时逐步建立多个仓位,并通过设定盈利目标进行风险控制。系统设计了灵活的资金管理机制,每次交易使用账户总额的6.6%进行操作,最多允许15次金字塔式加仓。
策略的核心逻辑基于以下几个关键要素: 1. 入场信号:当14周期RSI指标下穿28.5的超卖水平时触发买入信号 2. 仓位管理:单次建仓使用账户权益的6.6%,最多允许15次递进建仓 3. 获利了结:当价格达到建仓均价900%的涨幅时,平掉50%的持仓 4. 可视化展示:在图表上标注买卖信号、RSI曲线、入场价格和目标价格 策略通过观察RSI指标在超卖区域的表现来判断市场走势,当出现超卖信号时逐步建仓,以降低建仓成本。
该策略通过RSI指标识别超卖机会,结合金字塔式加仓和固定比例获利了结,构建了一个完整的交易系统。策略的优势在于系统化操作和风险分散,但需要注意市场趋势和参数设置对策略表现的影响。通过增加动态参数调整、止损机制和市场过滤等优化措施,可以进一步提升策略的稳定性和盈利能力。
/*backtest
start: 2024-09-15 00:00:00
end: 2024-12-10 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("RSI Cross Under Strategy", overlay=true, initial_capital=1500, default_qty_type=strategy.percent_of_equity, default_qty_value=6.6)
// Input parameters
rsiLength = input(14, "RSI Length")
rsiOversold = input(28.5, "RSI Oversold Level")
profitTarget = input(900, "Profit Target (%)")
maxPyramiding = input(15, "Max Pyramiding")
// Calculate RSI
rsi = ta.rsi(close, rsiLength)
// Detect RSI crossunder
rsiCrossunder = ta.crossunder(rsi, rsiOversold)
// Calculate the profit target price
entryPrice = strategy.position_avg_price
targetPrice = entryPrice * (1 + profitTarget / 100)
// Buy condition
if (rsiCrossunder and strategy.position_size <= maxPyramiding * strategy.equity * 0.066)
strategy.entry("Buy", strategy.long)
// Take profit condition
if (strategy.position_size > 0 and high >= targetPrice)
strategy.close("Buy", qty_percent = 50)
// Plot buy signals
plotshape(rsiCrossunder, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
// Plot sell signals (when position is partially closed)
plotshape(strategy.position_size > 0 and high >= targetPrice, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
// Plot RSI
plot(rsi, "RSI", color=color.blue, linewidth=2)
hline(rsiOversold, "RSI Oversold", color=color.red, linestyle=hline.style_dashed)
// Plot entry and target prices
plot(strategy.position_size > 0 ? entryPrice : na, "Entry Price", color=color.green, linewidth=2, style=plot.style_linebr)
plot(strategy.position_size > 0 ? targetPrice : na, "Target Price", color=color.red, linewidth=2, style=plot.style_linebr)
// Display strategy information
var table infoTable = table.new(position.top_right, 3, 6, border_width=1)
table.cell(infoTable, 0, 0, "Strategy Info", bgcolor=color.blue, text_color=color.white)
table.cell(infoTable, 0, 1, "RSI Length: " + str.tostring(rsiLength))
table.cell(infoTable, 0, 2, "RSI Oversold: " + str.tostring(rsiOversold))
table.cell(infoTable, 0, 3, "Profit Target: " + str.tostring(profitTarget) + "%")
table.cell(infoTable, 0, 4, "Order Size: 6.6% of total")
table.cell(infoTable, 0, 5, "Max Pyramiding: " + str.tostring(maxPyramiding) + " times")