简单的四周策略,改成收盘价模型,不回溯一根K的话是正常的,回溯一根K就没有信号,请问老师什么原因?
Param
Numeric length(5);
Vars
Series<Numeric> upband;
Series<Numeric> dnband;
Series<Bool> bool_up;
Series<Bool> bool_dn;
Events
OnInit()
{
Range[0:DataCount-1]
{
AddDataFlag(Enum_Data_RolloverBackWard()); //设置后复权
AddDataFlag(Enum_Data_RolloverRealPrice()); //设置映射真实价格
AddDataFlag(Enum_Data_AutoSwapPosition()); //设置自动换仓
AddDataFlag(Enum_Data_IgnoreSwapSignalCalc()); //设置忽略换仓信号计算
}
}
OnBar(ArrayRef<Integer> indexs)
{
upband = Highest(high[1],length);
dnband = Lowest(Low[1],length);
PlotNumeric(\"upband\",upband);
PlotNumeric(\"dnband\",dnband);
bool_up = CrossOver(Close[1],upband) ;
bool_dn = CrossUnder(Close[1],dnband);
If(MarketPosition<>1 and bool_up )
{
Buy(1,O);
}
If(MarketPosition<>-1 and bool_dn )
{
SellShort(1,O);
}
}
你可以在图上自己找一找
你用的是上一根bar的收盘价要比当前bar的上轨要高
图上找得到这种案例吗?