金字塔公式 金字塔模型策略源码:
//------------------------------------------------------------------------
// 简称: openrangbreak
// 名称: 开盘区间突破策略
// by: 财富游戏
//------------------------------------------------------------------------
input:percentofrange(0.5,0,1,0.1); //多头突破波动比例
input:lots(1,0,9,1);
highd:=callstock(stklabel,vthigh,6,-1);
lowd:=callstock(stklabel,vtlow,6,-1);
opend:=valuewhen(date<>ref(date,1),open);
ranget:= highd-lowd;
upperband: opend +percentofrange*ranget;
lowerband: opend -percentofrange*ranget;
if (holding=0) then begin
if (high>=upperband) then begin
buy(holding=0,lots,limitr,max(open,upperband));
end
if (low<=lowerband) then begin
buyshort(holding=0,lots,limitr,min(open,lowerband));
end
end
if (holding<0) then begin
if (high>=upperband) then begin
sellshort(holding<0,lots,limitr,max(open,upperband));
buy(holding=0,lots,limitr,max(open,upperband));
end
end
if (holding>0) then begin
if (low<=lowerband) then begin
sell(holding>0,lots,limitr,min(open,lowerband));
buyshort(holding=0,lots,limitr,min(open,lowerband));
end
end
持仓:holding,noaxis ,linethick0 ;
盈亏:asset-1000000,noaxis,coloryellow,linethick2;
//1、range break www.gszb.com
//波动区间突破交易,根据昨天波动幅度的一定百分比,来触发当日的趋势交易,
//如果昨天的波动幅度是异常的,应当对该波动幅度进行必要的调整,以保持合理性