Params
//此处添加参数
Vars
//此处添加变量
global numeric long_num(0);
global numeric short_num(0);
Events
OnBar(ArrayRef<Integer> indexs)
{
//多头
if(h-o>2 and a_buyposition == 0 and long_num==0 and BarStatus==2)
{
A_SendOrder(enum_buy,enum_entry,1,Q_AskPrice+10*minmove*pricescale,0);
long_num=1;
}
if(BarsSinceEntry!=0 and a_buyposition == 1)
{
A_SendOrder(enum_sell,enum_exit,1,q_bidprice-10*minmove*pricescale,0);
long_num=0;
}
//空头
if(o-l>2 and a_sellposition == 0 and short_num==0 and BarStatus==2)
{
A_SendOrder(enum_sell,enum_entry,1,Q_bidPrice-10*minmove*pricescale,0);
short_num=1;
}
if(BarsSinceEntry!=0 and a_sellposition == 1)
{
A_SendOrder(enum_buy,enum_exit,1,q_askprice+10*minmove*pricescale,0);
short_num=0;
}
}
两个问题
第一个 barssinceentry判断的是图表信号 但是a函数报单是没有图表信号的 所以不可能满足
第二 sellposition 是判断的持仓 不是可平仓 这样会引起频繁平仓的废单
请问还有判断可否平仓的函数吗?有的话请告诉我一下,谢谢指教。
什么都没有报
BarsSinceEntry的判断对A函数没有用的,所以永远都是0,就无法满足平仓条件了。
是报可平仓不足么
有关联账户。这个代码开仓正常,就是不能平仓。 之前我是用a_sendorederex,记录下来的委托单索引的值为0,不知道为什么。昨天晚上也和值班老师反应过这个情况了
已测试过,可以正常取到订单号。
另外不能平仓的问题,前面其他老师也回复过,是因为BARSSINCEENTRY对于A函数不起作用的。
谢谢,明白了。可能我的问题都是出在BARSSINCEENTRY上面。那请问入股我想用A函数发单,怎么在开仓的第二根K线平仓呢?该使用什么函数?谢谢各位老师了。
有没有关联账户