设为首页收藏本站

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

如何编写加仓命令! [复制链接]

Rank: 4

精华
0
UID
188
积分
597
帖子
91
主题
27
阅读权限
50
注册时间
2007-8-24
最后登录
2019-4-5
跳转到指定楼层
1#
发表于 2007-9-14 01:24:43 |只看该作者 |倒序浏览
如果 condtion 条件继续成立 怎么编写加仓命令呢 ?

Numeric extryLots; // 加仓数量
、、、、、、、
//加仓
if (BarStatus == 2 and MarketPosition == -1 )       
   {extryLots=A_FreeMargin /(Q_AskPrice*ContractUnit*MarginRatio);
   extryLots  = IntPart(extryLots );
   if(condtion and Time<0.144500 )                       
     SellShort( extryLots  ,Close,True);
   }
Else If(BarStatus <> 2 and MarketPosition == -1 )       
  {extryLots=CurrentCapital/(Close*ContractUnit*MarginRatio);
    extryLots  = IntPart(extryLots ); // 取整
        if(condtion and Time<0.144500 )                       
      SellShort( extryLots  ,Close,True);
   
    }
在 condtion  第一次成立后 ,开仓,  在部分仓位止赢后, 还剩下部分仓位 !这个时候 condtion  条件又成立了!
在这样的情况如何加仓!
我写的是加空的 代码 好象不行!

[ 本帖最后由 dengwenle 于 2007-9-14 01:26 编辑 ]

Rank: 10Rank: 10Rank: 10

精华
20
UID
4
积分
22709
帖子
4802
主题
64
阅读权限
255
注册时间
2007-7-20
最后登录
2024-1-15
2#
发表于 2007-9-14 09:27:52 |只看该作者
看起来代码没有问题,您用FileAppend函数调试一下,确认是否执行到加仓的代码
代码如下:

  1. if (BarStatus == 2 and MarketPosition == -1)
  2. {
  3.         extryLots=A_FreeMargin /(Q_AskPrice*ContractUnit*MarginRatio);
  4.         extryLots  = IntPart(extryLots );
  5.         if(condtion and Time<0.144500 )
  6.         {
  7.                FileAppend("C:\\Formula.log","Date_lastbar="+Text(Date)+",Time_lastbar="+Text(100*Time)+",extryLots="+Text(extryLots));
  8.                SellShort( extryLots  ,Close,True);
  9.         }
  10. }Else If(BarStatus <> 2 and MarketPosition == -1 )
  11. {
  12.         extryLots=CurrentCapital/(Close*ContractUnit*MarginRatio);
  13.         extryLots  = IntPart(extryLots ); // 取整
  14.         if(condtion and Time<0.144500 )                       
  15.         {
  16.                FileAppend("C:\\Formula.log","Date="+Text(Date)+",Time="+Text(100*Time)+",extryLots="+Text(extryLots));
  17.                SellShort( extryLots  ,Close,True);
  18.         }
  19. }
复制代码

[ 本帖最后由 nopain 于 2007-9-14 12:07 编辑 ]

使用道具 举报

Rank: 4

精华
0
UID
188
积分
597
帖子
91
主题
27
阅读权限
50
注册时间
2007-8-24
最后登录
2019-4-5
3#
发表于 2007-9-14 11:40:07 |只看该作者
测试的结果 如下
Formula文件的内容::

Time=0.09,extryLots=215
Time=0.11,extryLots=217
Time=0.14,extryLots=217
Time=0.14,extryLots=218
Time=0.14,extryLots=222
Time=0.13,extryLots=222

使用道具 举报

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

bottom

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

GMT+8, 2024-5-1 08:27

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部