A_SendOrder(Enum_Buy,Enum_Entry,flot,Q_AskPrice()); 其中flot(1) 参数设置 但是执行下单就是成交两次,设为flot(5) 就成交10手单子 崩溃了都
//------------------------------------------------------------------------
// 简称: ceshi
// 名称:
// 类别: 公式应用
// 类型: 用户应用
// 输出: Void
//------------------------------------------------------------------------
Params
//此处添加参数
Numeric N(4);
Numeric flot(1);
Numeric t1(2);//交易时间定时器
Vars
//此处添加变量
Global Integer timeid1;
Global Integer timeid2;
GloBal Integer time1;
Global Integer sendCount(0);
Global Integer fillCount(0);
//Global Integer sendCount1(0);
//Global Integer sendCount2(0);
Series<Numeric> sendCount1;
Series<Numeric> sendCount2;
Series<Numeric> cci7;
Series<Numeric> typ;
Numeric unit;
BOOL sc;
BOOL xc;
BOOL sc1;
BOOL xc1;
Bool ordcombOffset;
Numeric i(0);
Integer id;
Integer id5;
Defs
//此处添加公式函数
Numeric calcAvg(Numeric a,Numeric b)
{
return (a+b)/2;
}
Events
//此处实现事件函数
//初始化事件函数,策略运行期间,首先运行且只有一次,应用在订阅数据等操作
OnInit()
{
A_SubscribeTradeByCreateId(Enum_Trade_Source_ALL);
}
//在所有的数据源准备完成后调用,应用在数据源的设置等操作
OnReady()
{
}
//基础数据更新事件函数
OnDic(StringRef dicName,StringRef dicSymbol,DicDataRef dicValue)
{
}
//在新bar的第一次执行之前调用一次,参数为新bar的图层数组
OnBarOpen(ArrayRef<Integer> indexs)
{
}
//Bar更新事件函数,参数indexs表示变化的数据源图层ID数组
OnBar(ArrayRef<Integer> indexs)
{
typ=close;
CCI7=(TYP-Averagefc(TYP,N))/(0.015*AvgDeviation(TYP,N));
sc=cci7>=60 ;//
sc1=cci7<=-10;
xc=cci7<=-60 ;
xc1=cci7>=10;
Commentary(\"cci;\"+Text (CCi7));
Commentary(\"持仓:\"+Text (A_TotalPosition));
Commentary(\"持多=:\"+Text (A_BuyPosition));
Commentary(\"持空=:\"+Text (A_SellPosition));
If(BarStatus == 0)
{
if(A_BuyPosition()>0)
{
sendCount1=1;
}
if(A_BuyPosition()==0)
{
sendCount1=0;
}
if(A_SellPosition() >0)
{
sendCount2=1;
}
if(A_SellPosition()==0)
{
sendCount2=0;
}
}
//----------------------------------------
If(BarStatus == 2 And sendCount1== 0 And A_BuyPosition()==0 And A_SellPosition() == 0 And cci7>60)
{
A_SendOrder(Enum_Buy,Enum_Entry,flot,Q_AskPrice());
sendCount1=1;
}
}
//下一个Bar开始前,重新执行当前bar最后一次,参数为当前bar的图层数组
OnBarClose(ArrayRef<Integer> indexs)
{
}
//Tick更新事件函数,需要SubscribeTick函数订阅后触发,参数evtTick表示更新的tick结构体
OnTick(TickRef evtTick)
{
}
//持仓更新事件函数,参数pos表示更新的持仓结构体
OnPosition(PositionRef pos)
{
}
//策略账户仓更新事件函数,参数pos表示更新的账户仓结构体
OnStrategyPosition(PositionRef pos)
{
}
//委托更新事件函数,参数ord表示更新的委托结构体
OnOrder(OrderRef ord)
{
}
//成交更新事件函数,参数ordFill表示更新的成交结构体
OnFill(FillRef ordFill)
{
}
//定时器更新事件函数,参数id表示定时器的编号,millsecs表示定时间的间隔毫秒值
OnTimer(Integer id,Integer intervalMillsecs)
{
}
//通用事件触发函数,参数evtName为事件名称,参数evtValue为事件内容
OnEvent(StringRef evtName,MapRef<String,String> evtValue)
{
}
//当前策略退出时触发
OnExit()
{
}
//------------------------------------------------------------------------
// 编译版本 2023/08/24 142327
// 版权所有 jansen119
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------
原因找到了,是第一次发单 没成交 返回全局变量控制值没有改变,新的TICK又来了,条件符合 又发了一次单,这时 第一个单成交量,全局变量限制值起作用,不继续发单,但是发出去的两个单都成交了。结果是本来是买一手,结果就变成成交两手了, 哎 这成交机制也是没谁了,,,,,
记录是公式发的单 两次
建议A函数不要跟图表混用
你的问题光看代码是不够的,先看委托记录是怎么报的2倍