- 精华
- 0
- 在线时间
- 353 小时
- UID
- 21133
- 积分
- 852
- 帖子
- 112
- 阅读权限
- 60
- 注册时间
- 2010-12-8
- 最后登录
- 2016-3-23
- 精华
- 0
- UID
- 21133
- 积分
- 852
- 帖子
- 112
- 主题
- 25
- 阅读权限
- 60
- 注册时间
- 2010-12-8
- 最后登录
- 2016-3-23
|
// 简称: TESTS
// 名称:
// 类别: 公式应用
// 类型: 用户应用
//------------------------------------------------------------------------
Params
Numeric Stop(10);
Vars
Begin
If(time==0.09&&MarketPosition==0)
{Buy(1,Close);SetGlobalVar(21,CLOSE);SetGlobalVar(22,CurrentBar);SetGlobalVar(20,1);}
If(Time==0.1330&&MarketPosition==0)
{SellShort(1,Close);SetGlobalVar(25,close);SetGlobalVar(26,CurrentBar);SetGlobalVar(20,-1);}
I_StopLoss(Stop);
End
下面是用户函数
// 简称: I_StopLoss
// 名称: 止陨平仓
// 类别: 用户函数
// 类型: 用户函数
// 输出: 布尔型
//------------------------------------------------------------------------
Params
Numeric Stop(20);
Vars
Numeric STT;
Numeric Dots(1);
Numeric Min_price;
Numeric Min_value;
Numeric Offset;
String DKX_("DKX_");
String Strkey_Stop;
Bool Stop_feedback;
Begin
Strkey_Stop=Symbol+"Stop";
Min_price=MinMove*PriceScale*BigPointValue;
Min_value=MinMove*PriceScale*ContractUnit*BigPointValue;
Offset=MinMove*PriceScale*BigPointValue*Dots;
If(MarketPosition==-1 && GetGlobalVar(26)!=CurrentBar)
{STT=GetGlobalVar(25)+Min_price*Abs(Stop);Commentary("STOP="+TEXT(STT));
If(High>=STT)
{BuyToCover(CurrentContracts,STT+Offset);Stop_feedback=True;SetGlobalVar(27,STT+Offset);SetGlobalVar(28,currentbar);SetGlobalVar(20,0);Commentary("空头止陨平仓");SetTBProfileString(DKX_+"Breakout",Strkey_Stop,InvalidString);}
Else
SetTBProfileString(DKX_+"Breakout",Strkey_Stop,Text(STT+Offset));
}
If(MarketPosition==1 && GetGlobalVar(22)!=CurrentBar)
{STT=GetGlobalVar(21)-Min_price*Abs(Stop);
If(Low<=STT)
{Sell(CurrentContracts,STT-Offset);Stop_feedback=True;SetGlobalVar(23,STT-Offset);SetGlobalVar(24,currentbar);SetGlobalVar(20,0);Commentary("多头止陨平仓");SetTBProfileString(DKX_+"Breakout",Strkey_Stop,InvalidString); }
Else
SetTBProfileString(DKX_+"Breakout",Strkey_Stop,Text(STT-Offset));
}
Return Stop_feedback;
End |
|