简单的布林带上下回归,信号前一个bar也发单了,而且信号出现的时候信号也闪烁了,会不会是上下轨道随着tick价格变动导致的?有什么办法避免吗?
代码如下:
Events
OnReady()
{
SetBackBarMaxCount(1+Length);
}
OnBar(ArrayRef<Integer> indexs)
{
Range[0:DataSourceSize() - 1] //布林带画线
{
MidLine = AverageFC(Close,Length);
Band = StandardDev(Close,Length,2);
UpLine = MidLine + Offset * Band;
DownLine = MidLine - Offset * Band;
PlotNumeric("UpLine",UpLine);
PlotNumeric("DownLine",DownLine);
PlotNumeric("MidLine",MidLine);
}
If(MarketPosition == 0) //若无持仓判断条件进行开仓
{
If(low <= DownLine) Buy(Lots,DownLine); //低于下线开多
If(High >= UpLine) SellShort(Lots,UpLine); //高于上线开空