Params
Numeric Begintime(9.30);
Numeric endtime(14.55);
Numeric lots(1);
Numeric enFilter(1); // 1为使用窄幅过滤,其他为不使用过滤
Numeric RANGE_LENGTH(7);
Numeric PERCENT_OF_RANGE(1.10);
Numeric ratio(0.7);
Numeric InitialStop(5); // 初始止损(千分之N)
Numeric BreakEvenStop(5); // 保本止损(千分之N)
Numeric TrailingStop(5); // 追踪止损(千分之N)
Vars
NumericSeries Upperprice;
NumericSeries lowerprice;
NumericSeries higherafterentry;
NumericSeries lowerafterentry;
BoolSeries cond;
Numeric avgRange;
NumericSeries preDayRangezf;
Numeric yy;
Numeric MyPrice;
NumericSeries stopline;
BoolSeries bLongStoped(false); // 多头止损情况
BoolSeries bShortStoped(false); // 空头止损情况
Begin
if(day<>day[1] || CurrentBar==0)
{
Upperprice=high;
lowerprice=low;
bLongStoped = False;
bshortStoped = False;
}else if(time<=Begintime/100 || CurrentBar<30)
{
Upperprice=max(upperprice[1],high);
lowerprice=min(Lowerprice[1],low);
}Else
{
Upperprice=upperprice[1];
lowerprice=Lowerprice[1];
}
if(BarsSinceEntry==1)
{
higherafterentry=AvgEntryPrice;
lowerafterentry=AvgEntryPrice;
}else if(BarsSinceEntry>1)
{
higherafterentry=max(higherafterentry[1],high[1]);
lowerafterentry=min(lowerafterentry[1],low[1]);
}
If (enFilter==1)
{
avgRange = 0;
For yy=1 To RANGE_LENGTH
{
avgRange = avgRange+(highd(yy)-LowD(yy));
}
avgRange = avgRange/RANGE_LENGTH;
preDayRangezf = HighD(1) - LowD(1);
cond=(preDayRangezf<=PERCENT_OF_RANGE*avgRange);
}
Else cond = True;
求高手将上面TB 改成金字塔? 谢谢~~~~~~~~
你的不是完整的模型
要的是不是 3级止损啊?论坛上有
http://www.weistock.com/bbs/dispbbs.asp?BoardID=11&ID=7320&skin=0
平均振幅的算法 可采用引用
新建一个指标 名称为 zf 内容如下:avgRange:ma(h-l,20);zf:h-l;
则:avgRange:=stkindi(stklabel,'zf.avgRange',0,6,-1);
zf:=stkindi(stklabel,'zf.zf',0,6,-1);
至于开盘后一定周期内的高低点的写法:
nn:=barslast(date<>ref(date,1) or barpos=1)+1;
yl:=ref(hhv(h,nn),1);
zc:=ref(llv(l,nn),1);