因为是以时间为开仓信号(开仓信号有5个),平仓想以每次开仓价格上涨1%止损,下跌4%止盈(5个开仓信号单独计算出场),结果一直算的都是持仓均价,请问如何修正?
代码如下
Params
Numeric TIME1(0.092000);
Numeric TIME2(0.100000);
Numeric TIME3(0.110000);
Numeric TIME4(0.140000);
Numeric TIME5(0.145800);
Vars
Numeric B1;
Numeric B2;
Numeric B3;
Numeric B4;
Numeric B5;
Events
OnBar(ArrayRef<Integer> indexs)
{
{
If(Time==TIME1)
SellShort(0,CLOSE);
B1=LastEntryPrice;
Commentary("B1= "+Text(B1));
If(C>(B1*1.01) Or C<(B1*0.94) )
BuyToCover(0,CLOSE);
}
{
If(Time==TIME2)
SellShort(0,CLOSE);
B2=LastEntryPrice;
Commentary("B2= "+Text(B2));
If(C>(B2*1.01) Or C<(B2*0.94) )
BuyToCover(0,CLOSE);
}
{
If(Time==TIME3)
SellShort(0,CLOSE);
B3=LastEntryPrice;
Commentary("B3= "+Text(B3));
If(C>(B3*1.01) Or C<(B3*0.94) )
BuyToCover(0,CLOSE);
}
{
If(Time==TIME4)
SellShort(0,CLOSE);
B4=LastEntryPrice;
Commentary("B4= "+Text(B4));
If(C>(B4*1.01) Or C<(B4*0.94) )
BuyToCover(0,CLOSE);
}
{
If(Time==TIME5)
SellShort(0,CLOSE);
B5=LastEntryPrice;
Commentary("B5= "+Text(B5));
If(C>(B5*1.01) Or C<(B5*0.94) )
BuyToCover(0,CLOSE);
}
}
坦白说,问题很多,真有点不知从何说起。建议先把帮助中心的课程或视频教程学习一下再来提问。