以文本方式查看主题

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

--  作者:cxyr99
--  发布时间:2012/3/14 22:50:53
--  止损问题请教阿火

请教阿火   下列代码   我想用两个条件得出不同的退出价exitprice   但是都使用同一变量名在随后的sell语句中退出 。测试时第一部分可以止损,

但第二部分使用均线止损满足条件没有平仓信号显示无法平仓    我查看说明好像是跟序列运行模式有关  导致用close赋给变量无效

应该怎么解决。或者是我这样写本身结构就不对

 

 

 exitprice{初始化}

 

  if  条件1    then

        {  exitprice:= stoplossprice  } 

 

  if  条件2    then

 

       { if  cross(ma(close,60),close) then


           exitprice: = close;  }

      

   

sell(1,exitprice)


--  作者:阿火
--  发布时间:2012/3/14 22:53:46
--  

看不懂。语法错误 if then 的结构也是错的

金字塔不像开拓者那样使用 { }


--  作者:cxyr99
--  发布时间:2012/3/14 23:02:12
--  

 不好意思,不是为了写成开拓者那样 ,是像搞清楚 第2部分用均线平仓是没信号的,我觉得是满足条件时得不得exitprice,和说明书里序列运行模式有关,但不知道怎么改写才对

 

 if  cond1    then   begin

 

               ·········语句··········

 

              exitprice:= stoplossprice ;

 end 

        

  if  cond2    then  begin

       

              if  cross(ma(close,60),close) then


              exitprice:= close ;

 end 

 

      

   

sell(1,exitprice)

[此贴子已经被作者于2012-3-14 23:06:51编辑过]

--  作者:阿火
--  发布时间:2012/3/15 6:55:02
--  

cond3:=cross(ma(close,60),close) ;//放if结构外面

if  cond2    then  begin

       

              if  cond3  then


              exitprice:= close ;

 end 


--  作者:cxyr99
--  发布时间:2012/3/15 10:36:13
--  
阿火真火图片点击可在新窗口打开查看, 十分感谢