以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  求教:extgbdata定义的全局变量,不是满足条件才赋值?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=9011)

--  作者:fly
--  发布时间:2011/11/17 14:44:05
--  求教:extgbdata定义的全局变量,不是满足条件才赋值?

//用的是1分钟K线,走完一根K线

 

runmode:1;
price:=\'price\';// 全局变量,控制开仓次数

 

if tholding=0 and DYNAINFO(207)>112300 then
begin
tbuy(1,1,mkt);
extgbdataset(\'price\',close);//记录开仓价格
end

 

tsell(tholding>0 and tenterbars>5,1,mkt);

 

if islastbar then
begin 
DEBUGFILE2(\'d:\\debug.txt\',\'xinhao:%.2f\',ttype(1),1);//+\',当前持仓量:\'+numtostr(abs(tholding),0)
DEBUGFILE2(\'d:\\debug.txt\',\'jiage:%.2f\',extgbdata(\'price\'),1);
end

 

全局变量price的值在每根K线上,都有变化,且变化为该周期的开盘价

从全局变量表里,和DEBUG文件里看到的都是这样.

我明明限定了,在开仓的时候,才改变其值,应该一直都是开仓价的


--  作者:fly
--  发布时间:2011/11/17 15:19:15
--  

在该句中加入了红色部分,貌似正常了,明天继续跟踪一下.

 

if tholding=0 and DYNAINFO(207)>112300 and islastbar then
begin
tbuy(1,1,mkt);
extgbdataset(\'price\',close);//记录开仓价格
end