以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]ref函数出现问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=9475)

--  作者:brighyel
--  发布时间:2011/12/23 13:08:50
--  [求助]ref函数出现问题

图片点击可在新窗口打开查看 图片请点击

 

部分代码如下:开多仓后保存开仓k线前2周期最低点,开多后 逐k线进行保存该值,但出现问题,只能隔一个k线保存到该值(2348),见图片

variable:ll0=open;

ll0:=ref(ll0,1);
if  holding<=0 and (buyopencon1 or  buyopencon2) then
begin
sellshort(holding<0,lots,limitr,open);
buy(holding=0,lots,limitr,open);
binprice:=open;
ll0:=minlprice;
  If  Open-minlprice>=loss then
 ll0:=binprice-loss;
end

 

 

[此贴子已经被作者于2011-12-23 13:12:21编辑过]

--  作者:26327756l
--  发布时间:2011/12/23 13:38:28
--  
问题正在解决中
--  作者:26327756l
--  发布时间:2011/12/23 14:16:22
--  
实在是看不懂 你想干啥
--  作者:fly
--  发布时间:2011/12/23 14:31:17
--  

variable:kclo2=0;//记录开仓前2根K线最低价

 

ma5:ma(c,5);
ma20:ma(c,20);

 

lo2:=ref(llv(low,2),1);//前2根K线最低价


if cross(ma5,ma20) then
begin
sellshort(holding<0,1,limitr,open);

if holding=0 then
 begin
 buy(1,1,limitr,open);
 kclo2:=lo2;//记录开仓前2根K线最低价
 end
end

 

if cross(ma20,ma5) then sell(holding>0,0,market);


--  作者:brighyel
--  发布时间:2011/12/23 14:40:28
--  
不能直接传递吗
--  作者:fly
--  发布时间:2011/12/23 14:44:35
--  

你的代码,不太懂,4楼是照你的文字描述写的.

REF不要用在IF语句中.