using System;
using System.Collections.Generic;
public class Program {
static void Main() {
// 准备输入数据
List<double> closePrices = new List<double> { 10.2, 10.4, 10.6, 10.7, 10.5, 10.3, 10.1, 10.0, 9.8, 9.9 };
// 计算EMA12和EMA26
List<double> ema12Values = CalculateEMA(closePrices, 12);
List<double> ema26Values = CalculateEMA(closePrices, 26);
// 计算DIF
List<double> difValues = new List<double>();
for (int i = 0; i < closePrices.Count; i++) {
double dif = ema12Values[i] - ema26Values[i];
difValues.Add(dif);
}
// 计算DEA
List<double> deaValues = CalculateEMA(difValues, 9);
// 计算MACD
List<double> macdValues = new List<double>();
for (int i = 0; i < closePrices.Count; i++) {
double macd = (difValue
C#实现走势图macd算法 案例
最新推荐文章于 2024-04-25 18:32:24 发布