double 函数(int 均线周期, int 价格种类, int shift) //LSMA
{
int j;
double price;
double n;
double 单;
int K = 均线周期;
double sum = 0;
for (int i = K; i >= 1; i--)
{
n = K + 1;
n /= 3.0;
单 = 0;
j = K - i + shift;
switch (价格种类)
{
case 0:
price = Close[j];
break;
case 1:
price = Open[j];
break;
case 2:
price = High[j];
break;
case 3:
price = Low[j];
break;
case 4:
price = (High[j] + Low[j]) / 2.0;
break;
case 5:
price = (High[j] + Low[j] + Close[j]) / 3.0;
break;
case 6:
price = (High[j] + Low[j] + 2.0 * Close[j]) / 4.0;
}
单 = (i - n) * price;
sum += 单;
}
double ans = MathFloor(6.0 * sum / (K * (K + 1)) / Point) * Point;
return (ans);
}
发表评论