以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]当日亏损交易次数超过3次,则不再开仓如何写?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=4991)

--  作者:j888fff
--  发布时间:2011/1/25 23:01:46
--  [求助]当日亏损交易次数超过3次,则不再开仓如何写?

图表交易 新交易函数

一。当日亏损交易次数超过3次,则不再开仓如何写?

二。当日连续亏损交易次数超过2次,则不再开仓如何写?

 


--  作者:阿火
--  发布时间:2011/1/25 23:38:45
--  

用全局变量variable:kuisun=0;

每次平仓时,再判断一下是盈利,还是亏损,是亏损的话,kuisun就累加

如:

if cond1 and holding>0 then

begin

  sell(1,1,thisclose);

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

end

 

if cond2 and holding=0 and kuisun<3 then

buy(1,1,thisclose);

 

 

记得收盘的时候把kuisun赋值为0.

另外一个问题,方法类似。

[此贴子已经被作者于2011-1-26 13:21:40编辑过]

--  作者:xian_0_9
--  发布时间:2011/1/26 11:14:51
--  

好例子,好例子。


--  作者:j888fff
--  发布时间:2011/1/26 13:35:34
--  
以下是引用leevolvo在2011-1-25 23:38:45的发言:

用全局变量variable:kuisun=0;

每次平仓时,再判断一下是盈利,还是亏损,是亏损的话,kuisun就累加

如:

if cond1 and holding>0 then

begin

  sell(1,1,thisclose);

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

end

 

if cond2 and holding=0 and kuisun<3 then

buy(1,1,thisclose);

 

 

记得收盘的时候把kuisun赋值为0.

另外一个问题,方法类似。

[此贴子已经被作者于2011-1-26 13:21:40编辑过]

是哦,收盘不赋值为0,后面就不再开仓了

 

另问,收盘赋值为0怎么表达?


--  作者:fly
--  发布时间:2011/1/26 14:29:33
--  

商品期货

if time=150000 then kuisun:=0;//收盘的同时,赋值为0


--  作者:j888fff
--  发布时间:2011/1/26 21:07:46
--  
以下是引用leevolvo在2011-1-25 23:38:45的发言:

用全局变量variable:kuisun=0;

每次平仓时,再判断一下是盈利,还是亏损,是亏损的话,kuisun就累加

如:

if cond1 and holding>0 then

begin

  sell(1,1,thisclose);

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

end

 

if cond2 and holding=0 and kuisun<3 then

buy(1,1,thisclose);

 

 

记得收盘的时候把kuisun赋值为0.

另外一个问题,方法类似。

[此贴子已经被作者于2011-1-26 13:21:40编辑过]

测试了下, 貌似平多亏损次数和平空亏损次数是单独累计的,合并累计该怎么写?


--  作者:阿火
--  发布时间:2011/1/27 0:04:06
--  

这里是举例,道理一样

 

if cond1 and holding>0 then

begin

  sell(1,1,thisclose);

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

end

 

if cond3 and holding<0 then

begin

  sellshort(1,1,thisclose);

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

end

 

if cond2 and holding=0 and kuisun<3 then

buy(1,1,thisclose);


--  作者:z7c9
--  发布时间:2011/1/27 9:06:17
--  
以下内容为程序代码:

1 runmode:1;
2
3 variable:profit=0;
4
5 buycond:=1;
6 sellcond:=1;
7
8 if date<>ref(date,1) then
9     profit:=0;
10     
11 if profit<=-3 then exit;
12
13 if holding=0 and buycond then begin
14     buy(1,1,limitr,close);
15 end
16
17 if holding>0 and sellcond then begin
18     sell(1,holding,limitr,close);
19     if exitprice<enterprice then
20         profit:=profit-1;
21 end

--  作者:j888fff
--  发布时间:2011/1/27 23:44:19
--  

z7c9的,是序列模式的。

 

 

请教leevolvo版主

为何我下面这公式,KS的输出值,一直是0?什么地方编写错误了?

(按设计,光标在K线上来回拖动,KS的数值应会变动)5分钟周期

 

aa:=ema(c,5) ;
bb:=ema(c,10) ;
dc:=cross(aa,bb) ;
kc:=cross(bb,aa) ;

variable: kuisun=0;


//平多

if kc and holding>0  then

 begin

  sell( 1 ,0 , LIMITR , close ) ,ORDERQUEUE ;
 
  if c<enterprice then kuisun=kuisun+1 ;
 
 end


//平空

if dc  and holding<0  then

 begin

   sellshort( 1 , 0 , LIMITR , close ) ,ORDERQUEUE ;
   
   if c>enterprice then kuisun=kuisun+1 ;

 end

//开多
if c>o and kuisun<3 then
    begin
    buy(dc and holding=0 , 1  ,  market) ,ORDERQUEUE ; 
    end
else
    begin
    buy(dc and holding=0 , 1 ,  LIMITR, close ) ,ORDERQUEUE ; 
    end

 

//开空
if c<o and kuisun<3 then
     begin
     buyshort(kc and holding=0 , 1  ,  market) ,ORDERQUEUE ; 
     end
else
     begin
     buyshort(kc and holding=0 , 1  ,  LIMITR, close) ,ORDERQUEUE ; 
     end

 

if time=150500 then kuisun:=0;//收盘的同时,赋值为0

ks: kuisun ;

[此贴子已经被作者于2011-1-27 23:55:30编辑过]

--  作者:阿火
--  发布时间:2011/1/28 10:59:23
--  

代码错了啊。kuisun=kuisun+1。这是比较运算了。

正确:

kuisun:=kuisun+1;

 

收盘时间不是150500 ,商品是150000,股指151500