设为首页收藏本站

 找回密码
 注册
查看: 2845|回复: 2
打印 上一主题 下一主题

请高手指点加减仓模型赋值部分怎么样编写 [复制链接]

Rank: 5Rank: 5

精华
0
UID
73474
积分
1249
帖子
695
主题
30
阅读权限
60
注册时间
2011-10-22
最后登录
2015-11-6
跳转到指定楼层
1#
发表于 2012-4-10 21:25:54 |只看该作者 |倒序浏览
请高手指点,加减仓模型赋值部分怎么样编写?FirstEntryCon = ...

怎么样才能测试通过啊???

加仓减仓

本例仅以做多为例,做空类似。模板以首次开仓2手后每赢利30跳加仓一次,每次1手,最多加仓3次;开仓后每亏损30跳减仓1手。也可以转换为开仓价格的百分比值,或波动率的百分比等其任何设置的变量进行处理。


Vars

Numeric MinPoint; //一个最小变动单位,也就是一跳

NumericSeries firstPrice; //第一次开仓价格

NumericSeries LastPrice; //最后一次开仓价格

Numeric AddSet(30); //加仓设置

Numeric SubSet(30); //减仓设置

Bool FirstEntryCon; //首次开仓条件



Begin

FirstEntryCon = ...

MinPoint = MinMove*PriceScale;


//多头开仓部分

If(MarketPosition==0)

{

If(FirstEntryCon)

{

firstPrice = Open;

LastPrice = firstPrice;

Buy(2,firstPrice);

}

}else If(MarketPosition==1) //有多仓的情况


{

While(CurrentEntries < 4 && High >= LastPrice + AddSet*MinPoint) //加仓

{

LastPrice = LastPrice + AddSet*MinPoint;

if(Open > LastPrice) LastPrice = Open;

Buy(1,LastPrice);

}

While(CurrentEntries > 0 && Low <= firstPrice - SubSet*MinPoint) //减仓

{

firstPrice = firstPrice - SubSet*MinPoint;

if(Open < firstPrice) firstPrice = Open;

Sell(1,firstPrice);

}

}







//空头开仓部分

If(MarketPosition==0)

{

If(FirstEntryCon)

{

firstPrice = Open;

LastPrice = firstPrice;

Buy(2,firstPrice);

}

}else If(MarketPosition==-1) //有空仓的情况


{

While(CurrentEntries < 4 && High <= LastPrice - AddSet*MinPoint) //加仓

{

LastPrice = LastPrice - AddSet*MinPoint;

if(Open < LastPrice) LastPrice = Open;

Buy(1,LastPrice);

}

While(CurrentEntries > 0 && Low >= firstPrice + SubSet*MinPoint) //减仓

{

firstPrice = firstPrice + SubSet*MinPoint;

if(Open > firstPrice) firstPrice = Open;

Sell(1,firstPrice);

}

}
天崖

Rank: 5Rank: 5

精华
0
UID
32158
积分
731
帖子
176
主题
53
阅读权限
60
注册时间
2011-4-5
最后登录
2023-1-17
2#
发表于 2012-6-11 20:36:27 |只看该作者
遇到差不多的问题 还未解决

使用道具 举报

Rank: 4

精华
0
UID
50057
积分
304
帖子
175
主题
17
阅读权限
50
注册时间
2011-6-27
最后登录
2015-1-4
3#
发表于 2012-6-12 10:24:31 |只看该作者
帮你顶一下 最近也在想资金管理的模块怎么开发

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-5-12 11:21

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部