我的程序中,有以下这些代码。使用A函数下单,模拟运行过程中,总有很多撤单,麻烦帮我看看,是不是价格设置有问题。
OnBarOpen(ArrayRef<Integer> indexs)
{
Integer idx;
Range[idx=0: DataSourceSize() - 1]
{
if (ArrayFind(indexs,idx))
{
...
myprice=open;
lots=1;
MyNMove=10; //偏移
if (满足条件)
{
//如果有空头持仓,先平空
Position pos;
Bool ret = A_GetPosition(MainSymbol(), pos, "", 0);
if (ret)
{
if (pos.shortCurrentVolume>0)
{
Numeric myTradePrice;
if (Abs(myprice - Q_AskPrice) <= MyNMove*MinMove*PriceScale)
{
myTradePrice=Q_AskPrice;
}
Else
{
myTradePrice=myprice + MyNMove*MinMove*PriceScale;
}
Array<Integer> orders;
A_BuyToCover(MainSymbol(),pos.shortCurrentVolume,myTradePrice, orders, "", "");
}
}
//开多单
Numeric myTradePrice;
//如果开盘价和对手价差值在一定范围内,则使用对手价;否则在开盘价基础上处理一定偏移
if (Abs(myprice - Q_AskPrice) <= MyNMove*MinMove*PriceScale)
{
myTradePrice=Q_AskPrice;
}
Else
{
myTradePrice=myprice + MyNMove*MinMove*PriceScale;
}
Array<Integer> orders;
A_Buy(MainSymbol(), Lots, myTradePrice, orders, "", "");
}
...
}
}
有以下疑问:
1)咨询过客服,不采用图表系统,使用A函数下单,委托价格需要自己处理偏移。(界面中设置的委托偏移对A函数不起作用)?是这样的吗?
2)为利于成交,使用A函数下单,我该如何设置价格。有参考的例子吗?
谢谢!
1、A函数下单,其中有一个参数就是委托价格,公式需要自己设置的。
2、可以在盘口价(挂单价或对手价)基础上加上偏移。但即便如此还要考虑不成交的撤单,以及撤单重发问题,这就是A函数比图表复杂的地方,很多东西都要自己考虑。