以下为TB四周法则原代码第一部分:
Params
Numeric B_Length1(22);// 长周期突破
Numeric B_Length2(4);
Numeric B_ATRLength(32);// 多头ATR周期
Numeric B_TrailStopNumATR(1.80);//多头 追踪止损,回撤Average ATR的倍数
Numeric S_Length1(8);
Numeric S_Length2(30);
Numeric S_ATRLength(12);// 空头ATR周期
Numeric S_TrailStopNumATR(4);// 空头追踪止损
Numeric lots(1);// 头寸大小
Vars
Numeric HiBand1;
Numeric HiBand2;
Numeric LoBand1;
Numeric LoBand2;
NumericSeries ATRValue;
Numeric MyPrice;
Numeric StopLine;
NumericSeries HigherAfterEntry;
NumericSeries LowerAfterEntry;
//以下多头
Begin
// 记录开仓后盈利峰值价
If(BarsSinceEntry == 1)
{
HigherAfterEntry = AvgEntryPrice;
}Else If(BarsSinceEntry > 1)
{
HigherAfterEntry = Max(HigherAfterEntry[1],High[1]);
}Else
{
HigherAfterEntry = HigherAfterEntry[1];
}
Commentary("HigherAfterEntry="+Text(HigherAfterEntry));
ATRValue = AvgTrueRange(B_ATRLength);
Commentary("ATRValue="+text(ATRValue));
HiBand1 = highest(high[1],B_Length1);
LoBand1 = lowest(low[1],B_Length1);
HiBand2 = highest(high[1],B_Length2);
LoBand2 = lowest(low[1],B_Length2);
PlotNumeric("HiBand1",HiBand1);
PlotNumeric("LoBand1",LoBand1);
plotnumeric("HiBand2",HiBand2);
plotnumeric("LoBand2",LoBand2);
// 过滤集合竞价
If((BarType==1 or BarType==2) && BarStatus == 2 && date!=date[1] && high==low) return;
If(BarType==0 && BarStatus == 2 && CurrentTime<=0.09 && high==low) return;
// 进场部分
if(MarketPosition==0 && high>=HiBand1)
{
MyPrice = HiBand1;
if (Open>MyPrice) MyPrice = Open;
buy(lots,MyPrice);
}
请求将TB四周法则(本楼第一部分与下一楼第二部分一起为完整策略)改写为金字塔图表逐K线语言程序,谢谢.