c# KDJ算法实现
此算法在WP7 个人炒股软件GilStock 中用到
同花顺算法描述:
1 RSV=(CLOSE-LLV(LOW,N))/(HHV(HIGH,N)-LLV(LOW,N))*100;
2 a=SMA(RSV,M1,1);
3 b=SMA(a,M2,1);
4 e=3*a-2*b;
5 IF(a<0) a=0;
6 IF(a>100) a=100;
7 IF(b<0) b=0;
8 IF(b>100) b=100;
9 IF(e<0) e=0;
10 IF(e>100) e=100;
11 K:a;
12 D:b;
13 J:e;
c#实现,理论区间内和新股上市的9天后的KDJ数据才是正确的。
View Code
1 /// <summary>
2 /// KDJ算法
3 /// </summary>
4 /// <param name="N">9</param>
5 /// <param name="M1">3</param>
6 /// <param name="M2">3</param>
7 /// <param name="KLStocklist">K线数据</param>
8 /// <returns></returns>
9 public static List<KLinfo> ComputationKJD(int N, int M1, int M2, List<KLinfo> KLStocklist)
10 {
11
12 for (int i = 0; i < KLStocklist.Count; i++)
13 {
14 double RSV = 0;
15 double a = 0;
16 double b = 0;
17 double e = 0;
18
19 GetMinMaxPirce(i + 1, N, KLStocklist);
20
21 if (KLStocklist[i].KID == 1)
22 {
23 RSV = (KLStocklist[i].ClosePrice - KLStocklist[i].MinPrice) / (KLStocklist[i].MaxPrice - KLStocklist[i].MinPrice) * 100;
24 a= (1 * RSV + (M1 - 1) * 0) / 1;
25 b = (1 * a + (M2 - 1) * 0) / 1;
26 e = 3 * a - 2 * b;
27
28 }
29 else
30 {
31 &
相关新闻>>
- 发表评论
-
- 最新评论 更多>>