https://www.weistock.com/bbs/for ... &extra=page%3D1
分时均价用这个算法实现下。但是这个只能在1分钟周期上,否则计算是有偏差的。其他周期调用这个指标在1分钟周期上的计算结果就可以了。
[PEL] 复制代码 //以下代码在1分钟上计算有效,其他周期请跨周期调用
n1:=todaybar;
dm:=4-INTPART(LOG(C));
结算价:ROUNDS(IF(sum(vol,n1)=0,C,sum(C*vol,n1)/sum(vol,n1)),2+dm),colorred;
kd:cross(c,结算价);
kk:cross(结算价,c);
if kd then
begin
sellshort(1,holding,market);
buy(holding=0,1,market);
end
if kk then
begin
sell(1,holding,market);
buyshort(holding=0,1,market);
end
//多止盈
IF C-AVGENTERPRICE>100*MINDIFF THEN BEGIN
SELL(1,HOLDING,MARKET);
END
//多止损
IF AVGENTERPRICE-C>50*MINDIFF THEN BEGIN
SELL(1,HOLDING,MARKET);
END
//空止盈
IF AVGENTERPRICE-c>100*MINDIFF THEN BEGIN
sellshort(1,holding,market);
END
//空止损
IF c-AVGENTERPRICE>50*MINDIFF THEN BEGIN
sellshort(1,holding,market);
END
|