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

ema计算问题

Author: 古德猫宁, Created: 2022-09-24 15:24:02, Updated: 2022-09-24 19:27:32

两小时K线,ETHUSDT合约交易对,在九月13号20点,币安上EMA(3)是1664,fmz这个算出来是1744,K线个数设置为4000和300都试过了 img


More

发明者量化-小小梦 ``` var PreBarTime = 0 function PlotMA_Kline(records, param, isFirst){ var ma = TA.EMA(records, param) $.PlotRecords(records, "K") if(isFirst){ for(var i = records.length - 1; i >= 0; i--){ if(ma[i] !== null){ $.PlotLine("ema", ma[i], records[i].Time) } } PreBarTime = records[records.length - 1].Time } else { if(PreBarTime !== records[records.length - 1].Time){ $.PlotLine("ema", ma[ma.length - 2], records[records.length - 2].Time) PreBarTime = records[records.length - 1].Time } $.PlotLine("ema", ma[ma.length - 1], records[records.length - 1].Time) } } var MaCyc = 3 function main(){ var maCyc = MaCyc var isFirst = true exchange.SetContractType("swap") while(1){ var records = exchange.GetRecords() if(records && records.length > maCyc){ PlotMA_Kline(records, maCyc, isFirst) isFirst = false } Sleep(1000) } } ``` https://www.fmz.com/upload/asset/16753a16fe49ab80837f.png 可以用这个代码测试,测试是一致的。

古德猫宁 多谢大佬,我看看