You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TradingView策略切换Heiken Ashi蜡烛图后交易时点疑问

TradingView切换Heiken Ashi蜡烛图后的交易价格说明
  • 指标计算逻辑:当你把图表显示切换为Heiken Ashi蜡烛图后,策略里的所有内置指标(比如示例中的ta.supertrend)都会自动基于Heiken Ashi的K线数据计算——因为TradingView会把当前图表展示的K线数据源同步给策略引擎。
  • 交易进场/离场价格:策略执行strategy.entry这类交易指令时,默认用的是真实市场的原始蜡烛图开盘价(或对应成交市场价),和Heiken Ashi蜡烛的价格无关。毕竟Heiken Ashi是经过公式计算的衍生K线,并非真实市场的成交数据,策略引擎默认对接真实成交数据来执行交易动作。

看你提供的示例代码:
这段策略直接调用strategy.entry触发多空单,没有指定自定义价格参数,所以完全遵循默认规则——用真实市场的原始K线价格完成交易,和Heiken Ashi的开盘价没有关系。

如果确实需要用Heiken Ashi的价格来执行交易,得手动计算Heiken Ashi的价格,并在交易指令里指定,比如:

//@version=5
strategy("Supertrend Strategy with HA Price", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=15)

atrPeriod = input(10, "ATR Length")
factor = input.float(3.0, "Factor", step = 0.01)

// 手动计算Heiken Ashi开盘价
ha_open = ta.sma(open + close, 2)
[_, direction] = ta.supertrend(factor, atrPeriod)

if ta.change(direction) < 0
    // 指定用Heiken Ashi开盘价作为限价进场
    strategy.entry("My Long Entry Id", strategy.long, limit=ha_open)

if ta.change(direction) > 0
    strategy.entry("My Short Entry Id", strategy.short, limit=ha_open)

内容的提问来源于stack exchange,提问作者Антон Емельянов

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 08:22:14