因此,TradingView 上 Pine 脚本中的以下代码使用 Heikin-Ashi 烛台open价格,而不是策略测试面板中的实际实际开盘价。
有没有办法让策略测试人员使用真实价格?
此链接进一步解释了该问题。
//@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")
Run Code Online (Sandbox Code Playgroud)
小智 9
您可以通过两种方式执行此操作:
所以我建议使用选项(1)。
使用此代码为您的指标拉开/关闭/高/低HA 蜡烛。
openHA = security(heikinashi(tickerid), period, open)
closeHA = security(heikinashi(tickerid), period, close)
highHA = security(heikinashi(tickerid), period, high)
lowHA = security(heikinashi(tickerid), period, low)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5318 次 |
| 最近记录: |