这是一个基于内部强度指标(Internal Bar Strength, IBS)的做空策略,主要通过监测收盘价在日内价格区间中的位置来识别交易机会。当IBS指标显示超买状态时,策略会在满足特定条件下开启做空仓位,并在IBS达到超卖水平时平仓出场。该策略专门设计用于股票和ETF市场的日线级别交易。
策略的核心是通过IBS指标来衡量收盘价在当天高低点范围内的位置。IBS的计算公式为:(收盘价-最低价)/(最高价-最低价)。当IBS值大于等于0.9时,表明收盘价接近当天最高点,被认为是超买状态;当IBS值小于等于0.3时,表明收盘价接近当天最低点,被认为是超卖状态。策略在以下条件全部满足时进场做空: 1. IBS值达到或超过上限阈值(默认0.9) 2. 收盘价高于前一根K线的最高价 3. 当前时间在设定的交易时间窗口内 当IBS值降至下限阈值(默认0.3)以下时,策略会平掉所有仓位。
这是一个基于均值回归思想的做空策略,通过IBS指标捕捉价格超买后的回落机会。策略设计简洁,操作明确,但仍需要根据具体交易品种和市场环境进行优化。建议在实盘交易前,充分测试不同参数组合,并结合其他技术指标来提高策略的稳定性。同时,必须注意风险控制,特别是在强势市场中的应用。
/*backtest
start: 2024-06-01 00:00:00
end: 2025-02-18 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Botnet101
//@version=6
strategy('[SHORT ONLY] Internal Bar Strength (IBS) Mean Reversion Strategy', overlay = false, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, margin_long = 5, margin_short = 5, process_orders_on_close = true, precision = 4)
//#region INPUTS SECTION
// ============================================
//#region IBS Thresholds
upperThresholdInput = input.float(defval = 0.9, title = 'Upper Threshold', step = 0.1, maxval=1, group = 'IBS Settings')
lowerThresholdInput = input.float(defval = 0.3, title = 'Lower Threshold', step = 0.1, minval=0, group = 'IBS Settings')
//#endregion
//#endregion
//#region IBS CALCULATION
// ============================================
// IBS Value Calculation
// ============================================
internalBarStrength = (close - low) / (high - low)
//#endregion
//#region TRADING CONDITIONS
// ============================================
// Entry/Exit Logic
// ============================================
shortCondition = internalBarStrength >= upperThresholdInput and close>high[1]
exitCondition = internalBarStrength <= lowerThresholdInput
//#endregion
//#region STRATEGY EXECUTION
// ============================================
// Order Management
// ============================================
if shortCondition
strategy.entry('short', strategy.short)
if exitCondition
strategy.close_all()
//#endregion
//#region PLOTTING
// ============================================
// Visual Components
// ============================================
plot(internalBarStrength, color = color.white, title = "IBS Value")
plot(upperThresholdInput, color = color.yellow, title = "Upper Threshold")
plot(lowerThresholdInput, color = color.yellow, title = "Lower Threshold")
//#endregion