Params
Numeric Length(120);
Vars
NumericSeries Highest_value;
NumericSeries Lowest_value;
//---------跟踪止盈参数
Numeric ATRLength(10); //用于计算ATR和新高价的Bar数
Numeric Acceleration(0.8); //抛物线的加速系数
Numeric FirstBarMultp(3); //用于计算在进场Bar设置止损价的系数
NumericSeries stopline; // 止损线计算
NumericSeries StopATR;
Begin
If(!CallAuctionFilter()) Return;
StopATR = ATR_i(0,14);
Highest_value = Highest(High,Length)+StopATR*0.2;
Lowest_value = Lowest(Low,Length)-StopATR*0.2;
Commentary(\"StopATR:\"+text(StopATR));
PlotNumeric(\"MA1\",Highest_value);
PlotNumeric(\"MA2\",Lowest_value);
// 集合竞价和小节休息过滤
If(!CallAuctionFilter()) Return;
If(MarketPosition ==0 && CrossOver(High , Highest_value[1]) )
{
Buy(1,Max(o,Highest_value[1]));
}
If(MarketPosition ==0 && CrossUnder(Low , Lowest_value[1]) )
{
SellShort(1,Min(o,Lowest_value[1]));
}
Commentary(\"PL\"+Text(PositionProfit));
//--------采用ATR跟踪止损止盈
stopline = dj_StopTier_Range(ATRLength,Acceleration,FirstBarMultp,10);
PlotNumeric(\"stopline\",stopline);
If(MarketPosition == 1 and BarsSinceEntry > 0)
{
//-平多
If(Low <= stopline[1] )
{
Sell(0,min(Open,stopline[1]));
}
}
If(MarketPosition == -1 and BarsSinceEntry > 0)
{
//-平空
If(High >= stopline[1] )
{
BuyToCover(0,Max(Open,stopline[1]));
}
}
End
旗舰版代码放到tbquant需要在工具栏找代码升级点一下做转换