以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  控制语句下赋值为何无法改变变量?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=78695)

--  作者:gongxiangban
--  发布时间:2015/5/18 11:14:28
--  控制语句下赋值为何无法改变变量?
控制语句下赋值为何无法改变变量?

我好几个IF下赋值变量step

第一层是 step :=1;

接着是 step:=2.

等等。

为什么输出出来变量只有一个值?



--  作者:gongxiangban
--  发布时间:2015/5/18 11:15:37
--  
if time=opentime(0) then begin
   step:=0;
end

   
if ( close - enterprice<30*MINDIFF and step <= 1) then 
begin 
stopBuyLine:= enterprice - max(50*MINDIFF*atr,50*MINDIFF),nodraw;
step: = 1,nodraw;
end;
else 
 if  (close - enterprice>=30*MINDIFF and close - enterprice<昨收*0.01
 and ( step=1 or step=2 ) ) then 
begin 
    stopBuyLine:= enterprice + 10*MINDIFF;
    step: = 2,nodraw;
end;
else 
if (close - enterprice>=昨收*0.01 and close - enterprice<昨收*0.02 
 and ( step=2 or step=3 ) ) then 
begin 
stopBuyLine:=  enterprice + (close - enterprice)*0.5 ,nodraw;
step:=3,nodraw;
end;
else 
if (close - enterprice > 昨收*0.02  and ( step=3 or step=4 )) then 
begin 
stopBuyLine:=  enterprice + (close - enterprice)*0.65 ,nodraw;
step:=4,nodraw;
end;
end;

--  作者:gongxiangban
--  发布时间:2015/5/18 11:16:05
--  
最后输出出来step永远都是4.
--  作者:jinzhe
--  发布时间:2015/5/18 11:29:56
--  
请问step的初始定义是如何定义的?
--  作者:gongxiangban
--  发布时间:2015/5/18 11:31:50
--  
初始语句是这段代码
if time=opentime(0) then begin
   step:=0;
end

--  作者:gongxiangban
--  发布时间:2015/5/18 11:32:07
--  
运行在5分钟图标上,股指300
--  作者:gongxiangban
--  发布时间:2015/5/18 11:32:24
--  

1、多单移动止损:当价格往成本上方移动30跳(6个点),将止损移至成本上方10跳。当价格往上移动1%,移动止损移至保护利润的50%,当价格往上移动2%以上,移动止损移至保护利润的65%


--  作者:gongxiangban
--  发布时间:2015/5/18 11:57:10
--  
求版主大人明鉴。
--  作者:jinzhe
--  发布时间:2015/5/18 13:17:07
--  
 variable:step=0;
if ( close - enterprice<30*MINDIFF and step <= 1) then 
begin 
stopBuyLine:= enterprice - max(50*MINDIFF*atr,50*MINDIFF),nodraw;
step: = 1,nodraw;
end;
else 
 if  (close - enterprice>=30*MINDIFF and close - enterprice<昨收*0.01
 and ( step=1 or step=2 ) ) then 
begin 
    stopBuyLine:= enterprice + 10*MINDIFF;
    step: = 2,nodraw;
end;
else 
if (close - enterprice>=昨收*0.01 and close - enterprice<昨收*0.02 
 and ( step=2 or step=3 ) ) then 
begin 
stopBuyLine:=  enterprice + (close - enterprice)*0.5 ,nodraw;
step:=3,nodraw;
end;
else 
if (close - enterprice > 昨收*0.02  and ( step=3 or step=4 )) then 
begin 
stopBuyLine:=  enterprice + (close - enterprice)*0.65 ,nodraw;
step:=4,nodraw;
end;
end;

--  作者:gongxiangban
--  发布时间:2015/5/18 13:43:25
--  
谢谢,感觉可能是其他原因。