该策略是一个系统化的方法,旨在利用原油期货市场的波动性获利。它测量蜡烛的平均区间范围,如果快速移动平均线高于慢速移动平均线,这意味着蜡烛更大;如果慢速移动平均线高于快速移动平均线,这意味着蜡烛更小。
根据这个原理,识别潜在的长入场点和短入场点。仓位只保持一定的蜡烛数量,这个参数由“Exit after bars”输入控制。
该策略利用突破和回归判断短期趋势,属于波动性策略。通过优化参数设置和加入波动率指标判定,可以减少虚假突破概率,提高盈利水平。同时固定根K线的快速离场机制,可锁定一定利润,有效控制风险。该策略可以作为短线操作的辅助工具,也可通过参数调整获得更长周期的操作信号。
/*backtest start: 2024-02-01 00:00:00 end: 2024-02-29 23:59:59 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Celestial_Logic //@version=5 strategy("Crudeoil Breakout strategy", overlay = true, initial_capital = 20000, default_qty_type = strategy.fixed, default_qty_value = 1) highestCloseLookback = input(9 , title = 'Highest Close lookback') lowestCloseLookback = input(50, title = 'Lowest Close lookback' ) exitAfter = input(10, title = 'Exit after bars') hc = ta.highest(close,highestCloseLookback) lc = ta.lowest(close,lowestCloseLookback) rangeFilter = (ta.sma( (high - low), 5 ) > ta.sma((high-low), 20) ) // Candles getting bigger. longCondition = (close == hc ) and not rangeFilter shortCondition = (close == lc ) and not rangeFilter if longCondition strategy.entry(id = 'long', direction = strategy.long) if shortCondition strategy.entry(id = 'short', direction = strategy.short) var int longsince = 0 var int shortsince = 0 if strategy.position_size > 0 longsince += 1 else longsince := 0 if strategy.position_size < 0 shortsince += 1 else shortsince := 0 if longsince >= exitAfter strategy.close(id = 'long', comment = 'long close') if shortsince >= exitAfter strategy.close(id = 'short', comment = 'short close')