以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  请教关于成交量的模型应该怎样写?  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=2653)

--  作者:qkl586
--  发布时间:2010/8/29 0:58:22
--  请教关于成交量的模型应该怎样写?
请教这个公式的编写: 

//平多开空:上周期收阳线并且成交量大于1000手且是5周期均线的2倍时,本周期开盘价平多开空,止损为持仓价之上N;

//平空开多:三个周期前收阴线并且成交量大于1000手且是5周期成交量平均值的2倍时,本周期收盘价平空进多,止损为持仓价之下N;


--  作者:fly
--  发布时间:2010/8/30 9:30:44
--  

按楼主的意思写的,貌似没啥信号,也没啥意义

如果楼主是模拟的,只有上海期货交易所的合约,模拟的支持STOP及STOPR,所以,最好测试该市场的合约。

 

c1:=ref(c,1);
o1:=ref(o,1);
v1:=ref(v,1);
ma5c:=ma(c,5);

 

c3:=ref(c,3);
o3:=ref(o,3);
ma5v:=ma(v,5);

 

//本周期收盘价平空进多
if c3>o3 and v1>1000 and v1=2*ma5v then
 begin
    sellshort(holding<0,0,thisclose);
    buy(holding=0,1,thisclose);
 end

 

if holding>0 then p1:=enterprice;
//止损为持仓价之下N点;
if holding>0 then sell(1,0,stopr,p1-N);


//本周期开盘价平多开空,止损为持仓价之上N点;
if c1>o1 and v1>1000 and v1=2*ma5c then
 begin
    sell(holding>0,0,limitr,o);
    buyshort(holding=0,1,limitr,o);
 end
 
if holding<0 then p2:=enterprice;
//止损为持仓价之上N点;
if holding<0 then sellshort(1,0,stopr,p2+N);

[此贴子已经被作者于2010-8-30 9:54:35编辑过]

--  作者:董小球
--  发布时间:2010/8/30 9:32:38
--  

//要想分别获得连个方向上的持仓均价,必须使用后台交易进行操作
input:n(5);
平多开空:=ref(close,1)>ref(open,1) and vol>1000 and (close=ma(close,5)*2 or close>ma(close,5));
平空开多:=ref(close,3)<ref(open,1) and vol>1000 and (close=ma(close,5)*2 or close>ma(close,5));
tsell(平多开空,0,lmt,DYNAINFO( 20));
tbuyshort(平多开空,0,lmt,DYNAINFO( 20));
  if DYNAINFO( 20)-TAVGENTERPRICEEX2(\'\' ,\'\' , 1)>n then begin
  tsellshort(平多开空,0,limit,DYNAINFO( 20));
  end

tsellshort(平空开多,0,lmt,DYNAINFO( 21));
tbuy(平空开多,0,lmt,DYNAINFO( 21));
  if TAVGENTERPRICEEX2(\'\' ,\'\' , 1)-DYNAINFO( 21)>n then begin
  tsell(平空开多,0,lmt,DYNAINFO( 21));
  end

 

//大概就是这样了,再对照各个函数的解释,看看是否符合你的意思~


--  作者:qkl586
--  发布时间:2010/8/30 10:19:57
--  
多谢二位!
--  作者:qkl586
--  发布时间:2010/8/30 13:51:04
--  

二楼的高手,我测试了您写的模型,有几点我觉得有悖于我的初衷,但是我改的系统没有通过。我把有问题的语句告诉您,麻烦您再修改一下,谢谢!

c1:=ref(c,1);
o1:=ref(o,1);
v1:=ref(v,1);
ma5c:=ma(c,5);//不需要5天
均价,而是5天的成交量,应该把下面ma5V=ma(V5)提上来。

......................; //需要增加引用1天前的5周期均量的条件,我写成ma5v1:=ref(ma5v,1),应用到开平仓条件里时,系统提示ma5v1是未定义的变量。

 

 

c3:=ref(c,3);
o3:=ref(o,3);

V3:=ref(V,3);//需要增加的,三周期前的成交量。
ma5v:=ma(v,5);

......................; //需要增加引用3前的5周期均量的条件,我写成ma5v3=ref(ma5v,3),应用到开平仓条件里时,系统提示ma5v3是未定义的变量。

 

//本周期收盘价平空进多
if c3>o3 and v1>1000 and v1=2*ma5v then 

//拟修改为 if c3<o3 and v3>1000 and v3大于3周期前ma5v的两倍。例:if c3<o3 and v3>1000 and v3>2*ma5v3

 begin
    sellshort(holding<0,0,thisclose);
    buy(holding=0,1,thisclose);
 end

 

if holding>0 then p1:=enterprice;
//止损为持仓价之下N点;
if holding>0 then sell(1,0,stopr,p1-N);


//本周期开盘价平多开空,止损为持仓价之上N点;
if c1>o1 and v1>1000 and v1=2*ma5c then

//拟修改为 if c1>o1 and v1>1000 and v1大于上周期ma5v的两倍.例:c1>o1 and v1>1000 and v1>2*ma5v1
 begin
    sell(holding>0,0,limitr,o);
    buyshort(holding=0,1,limitr,o);
 end
 
if holding<0 then p2:=enterprice;
//止损为持仓价之上N点;
if holding<0 then sellshort(1,0,stopr,p2+N);


--  作者:董小球
--  发布时间:2010/8/30 16:33:39
--  
你这不是理解很到位么 哈哈 自己稍微修改下就好了嘛
--  作者:fly
--  发布时间:2010/8/30 17:18:33
--  

......................; //需要增加引用3前的5周期均量的条件,我写成ma5v3=ref(ma5v,3),应用到开平仓条件里时,系统提示ma5v3是未定义的变量。

 

少了符号“:”,改成这样就好了

ma5v3:=ref(ma5v,3);

 

公式都已经成功了99%了,只是测试没有通过,犯的还是最低级的错误,看起来,楼主的基本功和纠错能力需要加强。


--  作者:qkl586
--  发布时间:2010/8/30 22:58:48
--  

晕!!图片点击可在新窗口打开查看