Params
//此处添加参数
Numeric Lots(1);
Numeric leavetime(0.145500);
Vars
//此处添加变量
Series<Numeric> ma5;
Series<Numeric> buypoint;
Series<Numeric> sellpoint;
Array<Integer> ids;
Bool condition1;
Bool condition2;
Events
OnBar(ArrayRef<Integer> indexs)
{//此处添加公式函数
ma5 = Average(Close,5);
buypoint = ma5[1] + 5*minmove*PriceScale;
sellpoint = ma5[1] - 5*minmove*PriceScale;
condition1 = Q_AskPrice>=buypoint;
condition2 = Q_BidPrice<=sellpoint;
If(BarStatus == 0)
{ SetGlobalVar(1,0);
SetGlobalVar(2,0);
SetGlobalVar(0,0);
SetGlobalVar(3,0);
}
If(A_BuyPosition == 0 And condition1 And GetGlobalVar(1) <> 1)
{
A_SendOrder( Enum_Buy, Enum_Entry, 1, Q_AskPrice);
SetGlobalVar(1,1);
}
If(A_SellPosition == 0 And condition2 And GetGlobalVar(2) <> 1)
{
A_SendOrder( Enum_Sell, Enum_Entry, 1, Q_BidPrice);
SetGlobalVar(2,1);
}
If(Time>=leavetime And A_BuyPosition<>0 And GetGlobalVar(0)<>1)
{
A_SendOrder(Enum_Sell, Enum_Exit, A_BuyPosition, Q_BidPrice);
SetGlobalVar(0,1);
SetGlobalVar(1,0);
}
If(Time>=leavetime And A_SellPosition<>0 And GetGlobalVar(3)<>1)
{
A_SendOrder(Enum_Buy, Enum_Exit, A_SellPosition, Q_AskPrice);
SetGlobalVar(3,1);
SetGlobalVar(2,0);
}
}
OnBarClose(ArrayRef<Integer> indexs)
{
If(A_BuyPosition <> 0 And GetGlobalVar(0)<>1)
{
A_SendOrder(Enum_Sell, Enum_Exit, A_BuyPosition, Q_BidPrice);
SetGlobalVar(0,1);
SetGlobalVar(1,0);
}
If(A_BuyPosition == 0 And GetGlobalVar(1)<>0)
{
A_DeleteOrder(0,0);
SetGlobalVar(1,0);
}
If(A_SellPosition <> 0 And GetGlobalVar(3)<>1)
{
A_SendOrder(Enum_Buy, Enum_Exit, A_SellPosition, Q_AskPrice);
SetGlobalVar(3,1);
SetGlobalVar(2,0);
}
If(A_SellPosition == 0 And GetGlobalVar(3)<>0)
{
A_DeleteOrder(0,0);
SetGlobalVar(3,0);
}
老师,请问一下。这个是5分钟均线上下突破对开挂单。当根Bar结束平仓。没成交撤单,尾盘时间离场。里边有哪些错误?实盘跑了没开单。
}
老师,我就是想问一下,当一根K线结束全部平仓用什么函数比较好?
这个看不了
a函数的策略只能靠自己写日志诊断
建议先把诊断手段方法熟练了再研究a函数
不会诊断就先不要着急用a函数写,熟练程度跟不上