//@version=6 strategy( "Volume Profile 买卖策略 v6", overlay = true, max_bars_back = 2000, max_boxes_count = 300, max_labels_count = 200, pyramiding = 0, process_orders_on_close = true, calc_on_order_fills = true, commission_type = strategy.commission.percent, commission_value = 0.10, slippage = 1, initial_capital = 10000, default_qty_type = strategy.fixed, default_qty_value = 1) // ============================================================================= // 重要说明 // 1) 这是滚动范围 Volume Profile:每根 K 线都使用“前 N 根已完成 K 线”计算, // 当前信号 K 线不会被放进 Profile,尽量避免前视偏差。 // 2) 成交量按每根 K 线的 HLC3 归入一个价格行,是 OHLCV 近似,不等于逐笔成交。 // 3) Up / Down Volume 按 K 线涨跌分类,不是真实 Bid / Ask Delta。 // 4) 策略用于研究和回测,不构成投资建议;实盘前请自行做样本外测试。 // ============================================================================= // ── Profile 设置 string G_PROFILE = "1. Volume Profile" int lookbackBars = input.int(120, "滚动范围 K 线数", minval = 20, maxval = 500, group = G_PROFILE) int rows = input.int(36, "价格行数", minval = 12, maxval = 100, group = G_PROFILE) float valueAreaPct = input.float(70.0, "价值区成交量 %", minval = 50, maxval = 95, step = 1, group = G_PROFILE) / 100.0 bool showProfile = input.bool(true, "显示右侧 Profile", group = G_PROFILE) int profileOffset = input.int(5, "右侧偏移", minval = 1, maxval = 100, group = G_PROFILE) int profileWidth = input.int(40, "最大宽度(K 线)", minval = 10, maxval = 100, group = G_PROFILE) color upColor = input.color(color.rgb(0, 188, 212), "上涨量颜色", group = G_PROFILE) color downColor = input.color(color.rgb(233, 30, 99), "下跌量颜色", group = G_PROFILE) int profileTransparency = input.int(25, "透明度", minval = 0, maxval = 90, group = G_PROFILE) // ── 信号设置 string G_SIGNAL = "2. 买卖信号" string signalMode = input.string("VAH/VAL 突破", "信号模式", options = ["VAH/VAL 突破", "边界假突破反转", "POC 重夺/跌破", "自动组合"], group = G_SIGNAL) string tradeMode = input.string("现货:只做多", "交易模式", options = ["现货:只做多", "合约:多空双向"], group = G_SIGNAL) string oppositeAction = input.string("直接反手", "合约相反信号", options = ["直接反手", "只平仓"], group = G_SIGNAL)