以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  策略编写求助区  (http://weistock.com/bbs/list.asp?boardid=11)
----  [求助]  (http://weistock.com/bbs/dispbbs.asp?boardid=11&id=8050)

--  作者:pepsi
--  发布时间:2011/9/16 14:27:00
--  [求助]

若遇到某一平仓单亏损额度或者亏损点数大于一定的值的时候,下一个开仓信号则不开仓价,下第二个开仓信号再继续开仓,如何实现?


--  作者:fly
--  发布时间:2011/9/16 14:41:25
--  

用VARIABLE定义的全局变量标识,是否某一平仓单亏损额度或者亏损点数大于一定的值.决定是否开仓.

 

与此方法类似,请自行改写.如果对全局变量不了解,请在论坛搜帖查看.

示例:

当日亏损交易次数超过3次,则不再开仓

variable:lossnum=0;// 全局变量,平仓时判断一下是盈利/亏损,若亏损lossnum就加1


 

ma5:ma(close,5);

ma15:ma(close,15);


 

if CROSS(ma5,ma15) and holding<0 and time>091500 and time<145000 then

begin

sellshort(1,1,market),orderqueue;

if c>enterprice then lossnum:=lossnum+1;

end


 

if CROSS(ma5,ma15) and holding<0 and lossnum<3 and time>091500 and time<145000 then

begin

buy(1,1,market),orderqueue;

end


 

if CROSS(ma15,ma5) and holding>0 and time>091500 and time<145000 then

begin

sell(1,1,market),orderqueue;

if c<enterprice then lossnum:=lossnum+1;

end


 

if CROSS(ma15,ma5) and holding=0 and lossnum<3 and time>091500 and time<145000 then

begin

buyshort(1,1,market),orderqueue;

end


 

//收盘前5分钟平仓

if time > 145500 then

       begin

       sell(holding > 0, 0, thisclose);

       sellshort(holding < 0, 0, thisclose);

       end


 

if time=150000 then begin

   lossnum:=0;//收盘时要重新赋值为0

end


--  作者:pepsi
--  发布时间:2011/9/16 22:37:16
--  

variable:lossnum=0;// 全局变量,平仓时判断一下是盈利/亏损,若亏损lossnum就加1

 

全局变量从开盘到收盘,如果不重新赋值的话,就永久保留吗?还会保留到第二天?


--  作者:pepsi
--  发布时间:2011/9/19 10:28:22
--  
?
--  作者:jinzhe
--  发布时间:2011/9/19 10:59:33
--  

工具---数据---全局变量 点那个清空


--  作者:fly
--  发布时间:2011/9/19 13:58:22
--  

variable定义的全局变量,是局部全局变量.不会显示在全局变量表中.

 

如果不重新赋值的话,第2天就不会再开仓了.