- 精华
- 0
- 在线时间
- 108 小时
- UID
- 250562
- 积分
- 105
- 帖子
- 76
- 阅读权限
- 30
- 注册时间
- 2017-4-26
- 最后登录
- 2021-10-15
- 精华
- 0
- UID
- 250562
- 积分
- 105
- 帖子
- 76
- 主题
- 27
- 阅读权限
- 30
- 注册时间
- 2017-4-26
- 最后登录
- 2021-10-15
|
发表于 2019-12-3 15:02:52
|显示全部楼层
Params
Numeric length1(1);
Numeric length2(5);
Numeric length3(8);
Numeric length4(10);
Numeric Sprice(1);
Numeric stoppoint(0.5);
Vars
bool condition1;
bool condition2;
Numeric Price1;
Numeric Price2;
Numeric price3;
Numeric price4;
Series<Numeric> longstop(0);
Series<Numeric> shortstop(0);
Global Numeric TT1;
Global Numeric TT2;
Events
OnBar(ArrayRef<Integer> indexs)
{
condition1 = Close[length3]<Close[length2] And Close[length2]<Close[length1];
condition2 = Close[length3]>Close[length2] and Close[length2]>Close[length1];
if (condition2 and A_SellPosition==A_BuyPosition and A_SellPosition>0 and A_GetOpenOrderCount()==0)
{
A_SendOrder(Enum_Sell,Enum_Exit,5,Q_BidPrice);
SetGlobalVar(0,0);
}
if (condition1 and A_BuyPosition==A_SellPosition And A_BuyPosition>0 And A_GetOpenOrderCount()==0)
{
A_SendOrder(Enum_Buy,Enum_Exit,5,Q_AskPrice);
SetGlobalVar(1,0);
}
longstop = A_OrderFilledPrice(0)-1.5;
if (A_BuyPosition>A_SellPosition And A_GetOpenOrderCount()==0)//空头平仓锁仓
{
A_SendOrder(Enum_Sell,Enum_Exit,5,A_OrderFilledPrice(0)+2);
TT1 = T();
SetGlobalVar(1,GetGlobalVar(1)+1);
}
shortstop = A_OrderFilledPrice(0)+1.5;
if (A_SellPosition>A_BuyPosition And A_GetOpenOrderCount()==0)//多头平仓锁仓
{
A_SendOrder(Enum_Buy,Enum_Exit,5,A_OrderFilledPrice(0)-2);
TT2 = T();
SetGlobalVar(0,GetGlobalVar(0)+1);
}
if (barstatus==2 and High>= shortstop and high>MA1 and A_GetOpenOrderCount()>0 and T()>=TT2+0.0001 And A_SellPosition>A_BuyPosition And A_SellPosition>0 And GetGlobalVar(0)<3)//
{
A_DeleteOrder(A_OpenOrderContractNo(0));
A_SendOrder(Enum_Buy,Enum_Exit,5,Q_AskPrice);
SetGlobalVar(0,GetGlobalVar(0)+1);
}
else if(barstatus==2 and Low <=longstop and Low<MA1 and A_GetOpenOrderCount()>0 and T()>=TT1+0.0001 And A_BuyPosition>A_SellPosition and A_BuyPosition>0 And GetGlobalVar(1)<3)
{
A_DeleteOrder(A_OpenOrderContractNo(0));
A_SendOrder(Enum_Sell,Enum_Exit,5,Q_BidPrice);
SetGlobalVar(1,GetGlobalVar(1)+1);
}
} |
|