金字塔双均线穿越交易系统
-
相关简介:金字塔公式 金字塔模型策略源码: runmode:0; input:period1(20,5,100,5); input:period2(60,5,100,5); variable:myasset=30000; entertime:=time>=092500 and time<=145500; exittime:=time>=150000; ma1:=ma(close,period1); ma2:=ma(close,period2); buycond:=entertime and re
-
文章来源:公式网 发布时间:2015-10-25浏览次数:
金字塔公式 金字塔模型策略源码: runmode:0;
input:period1(20,5,100,5);
input:period2(60,5,100,5);
variable:myasset=30000;
entertime:=time>=092500 and time<=145500;
exittime:=time>=150000;
ma1:=ma(close,period1);
ma2:=ma(close,period2);
buycond:=entertime and ref(cross(ma1,ma2),1);
buyprice:=open;
buyshortcond:=entertime and ref(cross(ma2,ma1),1);
buyshortprice:=open;
if holding=0 and buycond then begin
buy(1,1,limitr,buyprice);
end
if holding=0 and buyshortcond then begin
buyshort(1,1,limitr,buyshortprice);
end
if holding>0 and exittime then begin
sell(1,holding,limitr,close);
end
if holding<0 and exittime then begin
sellshort(1,holding,limitr,close);
end
if exittime then
myasset:=asset;
资产:myasset,noaxis,colormagenta;
次数:totaltrade,linethick0;
收益:(myasset-30000)/30000,linethick0;
胜率:percentwin,linethick0;
出击:totaltrade/(count(date<>ref(date,1),0)+1),linethick0;
连亏:maxseqloss,linethick0;
连赢:maxseqwin,linethick0;
复制上述代码粘贴到到公式管理器
源码解析:
输出RUNMODE:0
输出 INPUT:PERIOD1(20,5,100,5)
输出 INPUT:PERIOD2(60,5,100,5)
输出 VARIABLE:MYASSET=30000
ENTERTIME赋值:TIME>=092500 AND TIME<=145500
EXITTIME赋值:TIME>=150000
MA1赋值:收盘价的PERIOD1日简单移动平均
MA2赋值:收盘价的PERIOD2日简单移动平均
BUYCOND赋值:ENTERTIME AND 昨日MA1上穿MA2
BUYPRICE赋值:开盘价
BUYSHORTCOND赋值:ENTERTIME AND 昨日MA2上穿MA1
BUYSHORTPRICE赋值:开盘价
逻辑判断 HOLDING=0 AND BUYCOND THEN BEGIN BUY(1,1,LIMITR,BUYPRICE)
END 逻辑


现在就去充值积分
加入VIP可下载100以下的所有资源