macd function to ask for values

Author: 13957180801, Created: 2018-09-28 15:31:17, Updated:

exchange.SetRate();
exchange.SetContractType("quarter");
exchange.SetMarginLevel(20);    
Log("PERIOD_M15");    
var records2 = exchange.GetRecords(PERIOD_M15);
var macd = TA.MACD(records2, 12, 26, 9);
Log(macd[0].length);
Log("dif0="+_N(macd[0][macd[0].length-1],4));
Log("dif1="+_N(macd[0][macd[0].length-2],4));
Log("dif2="+_N(macd[0][macd[0].length-3],4));    
Log(macd[1].length);
Log("dea0="+_N(macd[1][macd[1].length-1],4));
Log("dea1="+_N(macd[1][macd[1].length-2],4));
Log("dea2="+_N(macd[1][macd[1].length-3],4));    
Log(macd[2].length);
Log("macd0="+_N(macd[2][macd[2].length-1],4));
Log("macd1="+_N(macd[2][macd[2].length-2],4));
Log("macd2="+_N(macd[2][macd[2].length-3],4));

测试代码如下,输出来的数据和交易所网站上的macd的dif,dea,macd都不一样,是怎么回事啊?哪个地方弄错了吗?

More

The Little DreamThere are many reasons for this problem: 1, determine if the same contract, determine if the same K-line cycle, determine if the same pricing method (USD or CNY pricing), simply compare if the K-line data you get is the same as the exchange. The closing price of the last column of the K line is a real-time change, so the corresponding indicator value of this position is also a real-time change, and may be different. 3, indicator library algorithm: Some MACDs have a dif-dea column, some have a dif-dea column of 2 times, this is an algorithmic difference, although dif dea should be the same algorithm. 4, Data volume problem, the more K-line data for some indicators, the more accurately they are calculated (mostly iterative, recursive algorithms), so the given K-line data volume is not the same, and the calculated numerical values may also be different.