- 精华
- 0
- 在线时间
- 18 小时
- UID
- 286292
- 积分
- 40
- 帖子
- 16
- 阅读权限
- 10
- 注册时间
- 2019-11-30
- 最后登录
- 2019-12-26
- 精华
- 0
- UID
- 286292
- 积分
- 40
- 帖子
- 16
- 主题
- 8
- 阅读权限
- 10
- 注册时间
- 2019-11-30
- 最后登录
- 2019-12-26
|
请问管理员,我策略这样写,为什么在同一根K线上会出现同一价位连续开平仓呢?
//------------------------------------------------------------------------
// 简称: dtjy
// 名称: 多头交易
// 类别: 公式应用
// 类型: 用户应用
//------------------------------------------------------------------------
Params
Numeric ATRLength(26);
Numeric ss(1);
Vars
Numeric MinPoint;
Numeric MyEntryPrice;
NumericSeries ATR;
Numeric N;
Numeric zydw;
Numeric zsdw;
Begin
If(!CallAuctionFilter()) Return;
ATR = XAverage(TrueRange,ATRLength);
N = ATR[1];
MinPoint = MinMove * PriceScale;
MyEntryPrice = AvgEntryPrice;
zydw = IntPart(MyEntryPrice + (N * MinPoint)*2);
zsdw = IntPart(MyEntryPrice - (N * MinPoint)*1);
//-----------------------------------开仓-------------------------------------
If(BarStatus==2 && Time==0.210000 && CurrentTime <= 0.210000 && MarketPosition==0) return;
{
FileAppend("d:\\marketpostion.log"," currentbar: "+text(currentbar)+ "|| 执行buy命令前的marketposition值: " +Text(marketposition));
Buy(ss,open);
FileAppend("d:\\marketpostion.log"," currentbar: "+text(currentbar)+ "|| 执行buy命令后的marketposition值: " +Text(marketposition));
}
//--------------------------------------止盈------------------------------------
if (MarketPosition==1&&High>=zydw)
{
If(open > zydw) zydw = open; // 如果该Bar开盘价有跳空触发,则用开盘价代替
Sell(0,zydw);
buy(ss,zydw);
}
//----------------------------止损--------------------------------------
if (MarketPosition==1&&low<=zsdw)// 止损条件表达式
{
If(open < zsdw) zsdw = open; // 如果该Bar开盘价有跳空触发,则用开盘价代替
Sell(0,zsdw);
SellShort(ss,zsdw);
}
//-------------------------------------收盘平仓----------------------------------------
If((Date[-1]!=InvalidInteger && Date!=Date[-1])||(Date[-1]==InvalidInteger && Date < CurrentDate))
{
Sell(0,Close);
BuyToCover(0,Close);
}Else If(Date==CurrentDate && Time==0.1455 && CurrentTime>=0.1459)
{
Sell(0,Close);
BuyToCover(0,Close);
}
End |
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
|