资源加载中... loading...

js 中的Parabolic SAR 指标怎么使用Heiken Ashi k线?

Author: gzf445, Created: 2020-02-10 21:39:10, Updated:

sar 指标中使用Heiken Ashi k线,研究好好几个小时了得到的结果都是与原k线结果一直,是因为平台的talib做了什么限制么? 最小值已经发生变化了,为什么sar值还是相同的? 2020-02-10 21:35:43 信息 sar2 9375.691019486052 2020-02-10 21:35:43 信息 sar1 9375.691019486052 2020-02-10 21:35:43 信息 9346.08 9294.560000000001 2020-02-10 21:35:43 信息 9346.08 9300

function harecords (records) {

var harecords = []

for (var i = 0; i < records.length; i++) {
    if (i>0) {
        
    close=(records[i].High+records[i].Low+records[i].Open+records[i].Close)/4
    open=(records[i-1].Open+records[i-1].Close)/2
    high=Math.max(records[i].High,close,open)
    low=Math.min(records[i].Low,close,open)
        
        var currrecords = {
          Time : records[i].Time,
          Open : open,
          High : high,
          Low : low, 
          Close : close,                         
          Volume : records[i].Volume
        }
        }
       else { 
                    continue

           }
      harecords.push(currrecords)
      
    
        
    
}  

return harecords

}

function main() { var records = exchange.GetRecords(PERIOD_H1); //可以填入不同k线周期,比如PERIOD_M1,PERIOD_M30,PERIOD_H1…

  var harecords=harecords(records)
  var h=200
  Log(records[records.length-h].High,records[records.length-h].Low)
  Log(harecords[harecords.length-h].High,harecords[harecords.length-h].Low)
  
  var sar1=talib.SAR(records,0.015,0.2);
  var sar2=talib.SAR(harecords,0.015,0.2);
  Log('sar1',sar1[records.length-h])
  Log('sar2',sar2[harecords.length-h])

}


More

gzf445 用tradingview 看了一下,确实结果是一样的。原因不明,结贴了。谢谢。

小草 嗯,talib用的是官方的库,应该不会有问题