This strategy is a quantitative trading system based on price range breakouts. It operates by dynamically setting upper and lower price limits and executing trades when prices break through these key levels. The core concept is to capture trending opportunities when the market breaks out of established price ranges while adapting to market changes through dynamic adjustment of price zones. The strategy employs flexible position management, allowing additional trades in the same direction to maximize profits from major trends.
The strategy operates based on the following core mechanisms: First, it sets appropriate step sizes for different trading instruments, typically around 1.5% of the instrument’s price. The system establishes price zones above and below the current price, triggering long signals when prices break above the upper limit and short signals when breaking below the lower limit. After each breakout, the price zones adjust to adapt to the new market environment. The strategy supports adding positions in the same direction, allowing up to 200 positions, enabling profit maximization during strong trends. Order processing includes multiple safeguards, including processing at bar close, recalculating after trade execution, and computing at every price tick.
This is a well-designed trend following strategy with clear logic. Through dynamic price zone settings and adjustments, combined with flexible position management, the strategy can effectively capture market trending opportunities. While there is room for optimization, overall, the strategy provides a robust quantitative trading framework. Through continuous optimization and improvement, strategy performance can be further enhanced. The strategy design thoroughly considers various aspects of practical trading, including order processing and computational efficiency, demonstrating strong practicality.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-09 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // @version=5 // 每个图表上画对应间隔的横线,自己手画吧 // 同方向追加20单,订单成交后重新计算,每个tick重新计算,变量保存1000个周期,k线结束后再处理一次订单,按照代码顺序来绘制plot strategy("Price Level Breakout Strategy", overlay=true, pyramiding=200, calc_on_order_fills=true, calc_on_every_tick=true, max_bars_back=1000, process_orders_on_close=true, explicit_plot_zorder=true) // var创建持久性变量,:=是更新变量,不重新声明 // 这个是全局变量 // a = array.new<string>(200) // array.push(a, "a") // plot(close, color = array.get(a, close > open ? 1 : 0)) string ticker = syminfo.ticker var float step_size = 1000 // label.new(x=bar_index, y=close, text="当前品种代码: " + ticker) // 根据定值画1.5的平行线 if ticker == "000300" step_size := 4000 * 0.015 if ticker == "XAUUSD" step_size := 3000 * 0.016 if ticker == "BTCUSD" step_size := 60000 * 0.015 if ticker == "SILVER" step_size := 50 * 0.015 if ticker == "UKOIL" step_size := 150 * 0.015 if ticker == "GBPUSD" step_size := 1.6 * 0.015 if ticker == "EURUSD" step_size := 1.1 * 0.015 // 从0开始画200条间隔线 if ticker == "USDJPY" step_size := 100 * 0.015 var float start_value = close var float up_number = close + step_size var float low_number = close - step_size // hline(3.14, title='Pi', color=color.blue, linestyle=hline.style_dotted, linewidth=2) // plot(1) // 当价格突破上限,产生买入信号 if close > up_number // 生成买入信号 strategy.entry(id = "Buy", direction = strategy.long) // 更新新的价格区间 start_value := start_value + step_size up_number := start_value + step_size low_number := start_value - step_size strategy.close(id = "Sell") // 当价格跌破下限,产生卖出信号 if close < low_number // 生成卖出信号 strategy.entry("Sell", strategy.short) // 更新新的价格区间 start_value := start_value - step_size up_number := start_value + step_size low_number := start_value - step_size strategy.close(id = "Buy")