因此,TradingView上Pine脚本中的以下代码使用了Heikin-Ashi蜡烛线open
的价格,而不是策略测试器面板中的实际真实开盘价。
是否可以让策略测试者使用实际价格?
This link进一步说明了问题。
//@version=2
strategy("haup", overlay=true)
cci20 = cci(close, 20)
sma10 = sma(close, 10)
source = close
sourcea = open
haclose = (open + high + low + close) / 4
haopen = na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2
fromYear = year > 2016
toYear = year < 2019
longCondition = haopen < haclose
if (longCondition and fromYear and toYear)
strategy.entry("Long 1", strategy.long)
closeCondition = haopen > haclose
if (closeCondition)
strategy.close("Long 1")
答案 0 :(得分:3)
您可以通过两种方式执行此操作:
所以我建议使用选项(1)。
使用此代码为您的指标拉动打开/关闭/高/低蜡烛。
openHA = security(heikinashi(tickerid), period, open)
closeHA = security(heikinashi(tickerid), period, close)
highHA = security(heikinashi(tickerid), period, high)
lowHA = security(heikinashi(tickerid), period, low)