Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共11 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:[求助]当日亏损交易次数超过3次,则不再开仓如何写?

1楼
j888fff 发表于:2011/1/25 23:01:46

图表交易 新交易函数

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

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

 

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编辑过]
3楼
xian_0_9 发表于:2011/1/26 11:14:51

好例子,好例子。

4楼
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怎么表达?

5楼
fly 发表于:2011/1/26 14:29:33

商品期货

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

6楼
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编辑过]

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

7楼
阿火 发表于: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);

8楼
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
9楼
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编辑过]
10楼
阿火 发表于:2011/1/28 10:59:23

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

正确:

kuisun:=kuisun+1;

 

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

共11 条记录, 每页显示 10 条, 页签: [1] [2]


Powered By Dvbbs Version 8.3.0
Processed in 0.03125 s, 3 queries.