股票——通达信:
代码:
{############通达信自带的标准偏差函数不好用,需要自己根据算法来算############}
TYPICAL_PRICE:=(H+L+C)/3;
METHOD:=EMA(TYPICAL_PRICE,N);
APPLY_TO:=TYPICAL_PRICE;
MYSTDDEV:=SQRT(SUM(POW(APPLY_TO-METHOD,2),N)/N);
MAXB:=HHV(MYSTDDEV,M);
MINB:=LLV(MYSTDDEV,M);
vix:100*(MYSTDDEV-MINB)/(MAXB-MINB);
10,DOTLINE,COLORGREEN;
50,DOTLINE,COLORYELLOW;
90,DOTLINE,COLORMAGENTA;样图:
期货——盘立方:
代码:
Params
//参数定义
Integer N(14);
Integer M(50);
GlobalVars
//全局变量定义
Vars
//局部变量定义
Begin
//策略执行区
Numeric TYPICAL_PRICE = (H+L+C)/3;
Numeric METHOD = EMA(TYPICAL_PRICE,N);
Numeric APPLY_TO = TYPICAL_PRICE;
Numeric MYSTDDEV = Sqrt(Summation(Power(APPLY_TO-METHOD,2),N)/N);
Numeric MAXB = Highest(MYSTDDEV,M);
Numeric MINB = Lowest(MYSTDDEV,M);
PlotNumeric("VIX",100*(MYSTDDEV-MINB)/(MAXB-MINB));
PlotHorzLine(10,Green,2);
//PlotHorzLine(50,Yellow);
PlotHorzLine(90,Magenta);
End样图:
注:这篇文章同步发布在我的技术博客里:https://blog.51cto.com/noican |
|