以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  日内只开1次仓如何表达  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=12272)

--  作者:phui999
--  发布时间:2012/6/7 11:00:49
--  日内只开1次仓如何表达
日内只开1次仓如何表达?
--  作者:rushtaotao
--  发布时间:2012/6/7 11:03:52
--  
variable:a:=0;
if date<>ref(date,1) and a=0 then
begin
   buy(c>o,1,market);
   a:=1;
end

--  作者:phui999
--  发布时间:2012/6/7 11:10:52
--  
感谢
--  作者:phui999
--  发布时间:2012/6/7 11:23:38
--  

VARIABLE:nums=0;

 

if long and nums=0 then
    begin
       buy(holding=0,1,market);
       nums:=1;
       end

是不是这样写啊,好像我开不了仓。

 

另,平仓是否要定义nums啊?


--  作者:rushtaotao
--  发布时间:2012/6/7 11:35:53
--  

编译没通过吧?

 


--  作者:phui999
--  发布时间:2012/6/7 11:38:34
--  
通过,就是无法开仓
--  作者:王锋
--  发布时间:2012/6/7 11:47:38
--  
客服给写的逻辑有问题,请重写!
--  作者:rushtaotao
--  发布时间:2012/6/7 13:00:38
--  
正在处理
--  作者:rushtaotao
--  发布时间:2012/6/7 13:10:12
--  

稍等

 

[此贴子已经被作者于2012-6-7 13:16:37编辑过]

--  作者:just
--  发布时间:2012/6/7 13:16:45
--  

variable:nums=0;
short:=cross(ma(c,10),ma(c,5));
long:=cross(ma(c,5),ma(c,10));
tt:= time>092000 and time<151000;
n:=barslast(date<>ref(date,1))+1;

if n then begin
if long and tt and nums=0 then
    begin
       buy(holding=0,1,market);
       nums:=1;
 end
if short and tt and nums=1 then
   begin
    sell(holding>0,0,market);
     end
    
 if time>=151000 then nums:=0;//收盘前赋值变回去   
end