- 精华
- 0
- 在线时间
- 1479 小时
- UID
- 5696
- 积分
- 1213
- 帖子
- 256
- 阅读权限
- 60
- 注册时间
- 2009-10-18
- 最后登录
- 2023-6-10
- 精华
- 0
- UID
- 5696
- 积分
- 1213
- 帖子
- 256
- 主题
- 111
- 阅读权限
- 60
- 注册时间
- 2009-10-18
- 最后登录
- 2023-6-10
|
Params
Numeric entrylots(1);
Numeric exitlots(1);
Numeric opentime(9.15);
Numeric closetime(14.45);
Numeric morepoint(1);
Numeric alllots(1);
Vars
Numeric minpoint;
Numeric bpoint;
Numeric spoint;
bool bcon;
bool scon;
bool timecon;
Begin
MinPoint = MinMove*PriceScale;
timecon = q_lasttime>=opentime/100 && q_lasttime<=closetime/100 && Q_LastDate==date;
if( BarStatus==0 )
{
SetGlobalVar(10,999999);
setGlobalVar(11,0);
}
if( xxxxxxxx )
{
SetGlobalVar(10,xxxxxxxx);
}
if( yyyyyyyyyy)
{
setGlobalVar(11,yyyyyyyyyyyy);
}
bpoint = GetGlobalVar(10)+morepoint*minpoint;
spoint = GetGlobalVar(11)-morepoint*minpoint;
bcon = Q_AskPrice>=bpoint || (Q_AskPrice==GetGlobalVar(10) && Q_AskVol<entrylots && Q_BidVol>2*Q_AskVol);
scon = Q_BidPrice<=spoint || (Q_BidPrice==GetGlobalVar(11) && Q_BidVol<entrylots && Q_AskVol>2*Q_BidVol);
if( bcon && timecon && A_AccountID!="")
{
A_SendOrder(Enum_Buy,Enum_Exit,exitlots,Q_AskPrice());
A_SendOrder(Enum_Buy,Enum_Entry,entrylots,Q_AskPrice());
SetGlobalVar(10,999999);
}
else if( bcon && A_SellPosition>0 && Q_LastDate==date && q_lasttime>=opentime/100 && A_AccountID!="")
{
A_SendOrder(Enum_Buy,Enum_Exit,exitlots,Q_AskPrice());
SetGlobalVar(10,999999);
}
if( scon && timecon && A_AccountID!="")
{
A_SendOrder(Enum_Sell,Enum_Exit,exitlots,Q_BidPrice());
A_SendOrder(Enum_Sell,Enum_Entry,entrylots,Q_BidPrice());
setGlobalVar(11,0);
}
else if( scon && A_BuyPosition>0 && Q_LastDate==date && q_lasttime>=opentime/100 && A_AccountID!="")
{
A_SendOrder(Enum_Sell,Enum_Exit,exitlots,Q_BidPrice());
setGlobalVar(11,0);
}
if(high>GetGlobalVar(10)) SetGlobalVar(10,999999);
if(low<GetGlobalVar(11)) setGlobalVar(11,0);
if(Q_LastTime>0.1458 && A_BuyPosition>0)
{
A_SendOrder(Enum_Sell,Enum_Exit,allLots,Q_BidPrice);
}
if(data1.Q_LastTime>0.1458 && A_SellPosition>0)
{
A_SendOrder(Enum_Buy,Enum_Exit,allLots,Q_AskPrice);
}
Commentary("bpoint:"+Text(GetGlobalVar(10)));
Commentary("spoint:"+Text(GetGlobalVar(11)));
End
该程序思路:使用全局变量记录开仓点位,一旦符合条件下单,更改全局变量值,使开仓条件不满足,避免重复下单。
但是模拟测试时仍旧会重复发单。。。交易助手不追单也没用。。。 |
|