以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请教关于上次开仓  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=59801)

--  作者:punkcat401
--  发布时间:2013/12/11 11:08:07
--  请教关于上次开仓

上一次多头开仓盈利大于50点,则再次buy,怎么描述


--  作者:jinzhe
--  发布时间:2013/12/11 11:12:05
--  

variable:n=0;

if holding>0 and 平多条件   then begin

    sell;

    if c-enterprice>50*mindiff then n:=1;

end

 

if n=1 then begin

 sellshort;

 buy;

end


--  作者:punkcat401
--  发布时间:2013/12/11 11:20:09
--  
以下是引用jinzhe在2013/12/11 11:12:05的发言:

 

    if c-enterprice>50*mindiff then n:=1;

这个全局变量没有信号


--  作者:jinzhe
--  发布时间:2013/12/11 11:24:20
--  
n是多少?调试一下,你那里有没有盈利50点的行情?
--  作者:fly
--  发布时间:2013/12/11 11:27:52
--  

2楼是简略写法,具体开平仓及加仓条件,需要楼主自己填写的,以下为简单示例

 

variable:n=0;

ma5:ma(c,5);

ma20:ma(c,20);

 

if cross(ma5,ma20) and holding=0 then buy(1,1,market);

 

if  cross(ma20,ma5) and holding>0 then begin

    sell(1,1,market);

    if c-enterprice>50*mindiff then n:=1;//如果赢利超过50个点,则赋值为1

end

 

if cross(ma5,ma20) and holding=0  and n=1 then

begin

 buy(1,1,market);

 n:=0;//加仓后赋值为0

end


--  作者:punkcat401
--  发布时间:2013/12/11 11:36:36
--  
以下是引用fly在2013/12/11 11:27:52的发言:

2楼是简略写法,具体开平仓及加仓条件,需要楼主自己填写的,以下为简单示例

 

明白了,原来是N在赋值为1后,没有初始化为0.....