- 精华
- 0
- 在线时间
- 73 小时
- UID
- 268549
- 积分
- 23
- 帖子
- 13
- 阅读权限
- 10
- 注册时间
- 2018-8-11
- 最后登录
- 2021-2-23
- 精华
- 0
- UID
- 268549
- 积分
- 23
- 帖子
- 13
- 主题
- 4
- 阅读权限
- 10
- 注册时间
- 2018-8-11
- 最后登录
- 2021-2-23
|
本帖最后由 i7755_1 于 2019-1-10 02:41 编辑
新手,刚刚接触TB,学着写策略,遇到如下问题。
见图片:
开盘到收盘,一直不停地写。
请问出现这样的情况,怎样解决。
//If(!CallAuctionFilter) Return;
If( BarStatus ==0 )
{
SetGlobalVar( 0, 1 ); //记录
SetGlobalVar( 1, 1 ); //记录
SetGlobalVar( 2, 0 ); //记录
SetGlobalVar( 3, 0 ); //记录
SetGlobalVar( 4, 0 ); //记录
SetGlobalVar( 5, 0 ); //记录
SetGlobalVar( 6, 0 ); //记录
SetGlobalVar( 7, 0 ); //记录
}
MA = AverageFC( Close, M );
PlotNumeric( "均线", MA, 0, Yellow );
PlotNumeric( "上线", MA + yuanli*MinMove*PriceScale , 0, Green );
PlotNumeric( "下线", MA - zhisun*MinMove*PriceScale , 0, Red );
If( BarStatus ==2 )
{
If( CurrentTime < opentime/100 )
{
SetGlobalVar( 6, 0 );
Return;
}
If( Q_BidPrice > MA and GetGlobalVar(0) ==1 )
SetGlobalVar( 0, 0 );
If( ( A_BuyPosition >0 or A_BuyPosition ==0 and A_GetLastOpenOrderIndex( Enum_Buy, Enum_Entry ) == InvalidInteger ) and GetGlobalVar(1) ==1 )
{
SetGlobalVar( 1, 0 ); //允许开仓
FileAppend( "C:\\WeiJun_MA_A_" +SymbolName+ ".txt ", "时间 = " + Text( date + CurrentTime ) + " GetGlobalVar(1)归零时 = " + Text( A_GetOpenOrderCount ));
}
If( ( A_BuyPosition ==0 OR A_BuyPosition >0 and A_GetLastOpenOrderIndex( Enum_Sell, Enum_Exit ) == InvalidInteger ) and GetGlobalVar(3) <>0 )
{
SetGlobalVar( 3, 0 ); //允许止盈
FileAppend( "C:\\WeiJun_MA_A_" +SymbolName+ ".txt ", "时间 = " + Text( date + CurrentTime ) + " GetGlobalVar(3)归零时 = " + A_OpenOrderContractNo( A_GetLastOpenOrderIndex( Enum_Sell, Enum_Exit ) ) );
}
If( A_BuyPosition ==0 and GetGlobalVar(1) ==0 and GetGlobalVar(0) ==0 and Q_BidPrice < MA + yuanli*MinMove*PriceScale and CurrentTime <= lastopentime/100 )
{
A_SendOrder( Enum_Buy, Enum_Entry, lots, Q_BidPrice - N2*MinMove*PriceScale );
SetGlobalVar( 2, Q_BidPrice );
SetGlobalVar( 1, 1 );
SetGlobalVar( 4, 0 );
SetGlobalVar( 7, 0 );
FileAppend( "C:\\WeiJun_MA_A_" +SymbolName+ ".txt ", "时间 = " + Text( date + CurrentTime ) + " 开仓 = " + Text( Q_BidPrice ));
}
If( GetGlobalVar(2) == InvalidNumeric OR GetGlobalVar(2) ==0 ) SetGlobalVar( 2, Q_BidPrice );
If( A_BuyPosition ==0 and A_GetLastOpenOrderIndex( Enum_Buy, Enum_Entry ) <> InvalidInteger and Q_BidPrice >= GetGlobalVar(2) + N3*MinMove*PriceScale and GetGlobalVar(1) ==1)
{
A_DeleteOrder( A_OpenOrderContractNo( A_GetLastOpenOrderIndex( Enum_Buy, Enum_Entry ) ) );
SetGlobalVar( 1, 0 );
SetGlobalVar( 2, Q_BidPrice );
FileAppend( "C:\\WeiJun_MA_A_" +SymbolName+ ".txt ", "时间 = " + Text( date + CurrentTime ) + " 撤开仓和尾仓 = " + A_OpenOrderContractNo( A_GetLastOpenOrderIndex( Enum_Buy, Enum_Entry ) ) );
}
If( A_BuyPosition >0 and GetGlobalVar(3) ==0 and GetGlobalVar(4) ==0 and CurrentTime < stoptime/100 )
{
A_SendOrder( Enum_Sell, Enum_Exit, lots, GetGlobalVar(2) + zhiying*MinMove*PriceScale );[/code] |
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
|