Rss & SiteMap

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

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

标题:求助 运用全局变量 实现 大盈利或连续亏损两次后停止交易一段时间

1楼
厚德载物生 发表于:2015/4/27 11:09:05
求助  运用全局变量 实现  大盈利或连续亏损两次后停止交易一段时间  

搜索过论坛里各位高手的代码 ,但是关于 “大盈利或连续亏损两次后停止交易一段时间”  一直没有一个类似于阿火秘籍系统整理过的功能模块代码,
恳请在论坛的各位版主高手 给个 通用版本 帮助新手 克服这个障碍,十分感谢。
2楼
jinzhe 发表于:2015/4/27 11:15:32

variable:n=0,m=0;

if 平仓条件 and holding判断 then begin

     平仓语句;

     if 大盈利  then begin

         n:=1;

         m:=0;

     end

     if numprofit(1)>0 then m:=0;

     if numprofit(1)<0 then m:=m+1;

end

 

开仓条件加入:barslast(n=1 and ref(n=0,1))>一段时间 or barslast(m=2 and ref(m=1,1))>一段时间

     

3楼
厚德载物生 发表于:2015/4/27 11:26:56
我自己 顶一个 ,


//交易控制变量
variable:DYL=0;
variable:大盈利=0;



if 大盈利:=abs(enterprice-EXITPRICE)>=40 and  DYL=0 THEN  BEGIN
   DYL:=1;
   盈利休止:=DYL=1 AND EXITBARS<=40;
   end
   

   
if 大盈利:=abs(enterprice-EXITPRICE)<40 and  DYL=1 THEN  BEGIN
   DYL:=0;
   end

另外 这是我自己按照对函数的理解 写出的一个盈利停盘 条件

在开仓条件 and not(盈利休止)//在大盈利后 平仓历时40个周期内不交易

但是 这个代码 有问题
4楼
jinzhe 发表于:2015/4/27 11:29:42
按照我上面的格式改,把“一段时间”改成40
5楼
厚德载物生 发表于:2015/4/27 11:45:24
连续 亏损两次 以上 停盘一段时间 应该如何写功能模块 嵌入到 策略当中 ,真心求助啊 这个也是大部分金字塔新手 守住盈利 控制亏损的 迫切需求啊  请版主与各位高手重视 
6楼
jinzhe 发表于:2015/4/27 13:10:53

抬头,看上面

7楼
厚德载物生 发表于:2015/4/27 13:36:18
JINZHE大版主功力深厚 好牛 十分感谢  立刻回答了我的问题 ,刚才 我试一下代码,单独用连续2次亏损的代码模块没问题 ,可是大盈利停盘这块加进去不行,是不是 我的大盈利的写法问题   
写法1 // 大盈利:=abs(enterprice-EXITPRICE)>=40 ;
     if 大盈利  then begin

         n:=1;

         m:=0;

写法2// 大盈利:=abs(enterprice-EXITPRICE);
          if 大盈利>=40  then begin

         n:=1;

         m:=0;

写法3// 
           if numprofit(1)>12000 then n:=0;
望版主赐教
8楼
jinzhe 发表于:2015/4/27 13:40:16

这个要嵌套在平仓语句里面

if 平仓条件 and 持仓判断 then begin

     平仓语句;

     if numprofit(1)>12000 then begin

         m:=0;

         n:=0;

     end

end

 

9楼
厚德载物生 发表于:2015/4/27 13:56:42
已经根据版主的意思修改了代码 但是 不管n=1还是n=0 我都试过了
 if numprofit(1)>12000 then begin
         m:=0;
         n:=1;
     end
这段一加进来 代码就不管用,连 连续亏损停盘也不起作用了; 



if a4 and tpcc=1  then BEGIN
  平多4:SELL(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\590191352.txt', '平多4 %.0f',holding );
     if numprofit(1)>12000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
   
end


if a5 and tpcc=1  then BEGIN
  平多5:SELL(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\590191352.txt', '平多5 %.0f',holding );
     if numprofit(1)>12000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
end

if a6 and tpcc=1  then BEGIN
  平多6:SELL(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\590191352.txt', '平多6 %.0f',holding );
  if numprofit(1)>12000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
end

if a3  and tpcc=1    then BEGIN
   止损平多3:SELL(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\590191352.txt', '止损平多3 %.0f',holding );
     if numprofit(1)>12000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
end


if b4 and tpcc=2  then BEGIN
  平空4:SELLSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\590191352.txt', '平空4 %.0f',holding );
     if numprofit(1)>12000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
end

if b5 and tpcc=2  then BEGIN
  平空5:SELLSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\590191352.txt', '平空5 %.0f',holding );
     if numprofit(1)>12000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
end

if b6 and tpcc=2  then BEGIN
  平空6:SELLSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\590191352.txt', '平空6 %.0f',holding );
     if numprofit(1)>12000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
end

if b3 and tpcc=2  then BEGIN
  止损平空3:SELLSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\590191352.txt', '平空3 %.0f',holding );
     if numprofit(1)>12000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
end

10楼
jinzhe 发表于:2015/4/27 14:01:49

if 平仓条件 and 持仓判断

你少写了持仓判断

 

平多的持仓判断是:holding>0

平空是:holding<0

共52 条记录, 每页显示 10 条, 页签: [1] [2][3][4][5][6]


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