以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  求助 这个模型怎么写  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=12933)

--  作者:gfqh
--  发布时间:2012/7/15 15:20:29
--  求助 这个模型怎么写
给定一个价格P,价格每涨200就开空一手,即P+200时开空一手,P+400时再开空一手,如此继续;如果价格从最高位回调200就全部平仓
--  作者:jinzhe
--  发布时间:2012/7/16 9:02:33
--  

variable:hh=0,a=0;

p:=20000;

if h>hh then hh:=h;

if c>p+200 and a=0 then begin

buyshort(1,1,market);

a:=1;

end

 

if c>p+400 and a=1 then begin

buyshort(1,1,market);

a:=2;

end

 

......以此类推

if c<h-200 then sellshort(holding<0,0,market);


--  作者:gfqh
--  发布时间:2012/7/16 10:22:47
--  

那这个程序要写多长啊,能不能一次性写完的呀


--  作者:jinzhe
--  发布时间:2012/7/16 10:41:45
--  

一次性写完不太现实,有个变量不能套入循环中


--  作者:gfqh
--  发布时间:2012/7/16 10:45:10
--  

input:N(1,1,200,1); 
p:=8000;
M:=BARSLAST(DATE<>REF(DATE,1) )+1;
for i=1 to datacount  do
A1:=C>200*i+p ;//价格每上涨100
B1:=hhv(h,M)-C>200;//价格从最高位回调
 
if A1 THEN BEGIN
  buyshort(AK,1,market);
  end
 
if B1 then begin
 sellshort( holding<0 and AK,0,market);
 end

 

 

  这样行不,用for循环