以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请教老师,如何设定提取不到变量的时候用第一根K线作为初始变量?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=71938)

--  作者:zhoutuoying
--  发布时间:2014/11/13 11:00:20
--  请教老师,如何设定提取不到变量的时候用第一根K线作为初始变量?
请教老师,如何设定提取不到变量的时候用第一根K线收盘价作为初始变量?

因为开多条件是根据上一次开多的点位判定是否是有效的信号

--  作者:jinzhe
--  发布时间:2014/11/13 11:01:38
--  

你这样讲让人能难懂

这样吧,你把写好的代码贴出来,然后要实现什么目的说一下


--  作者:zhoutuoying
--  发布时间:2014/11/13 11:11:25
--  
if high>NH then
begin
//平空开多
sellshort(holding<0 and high>NH,0);
buy(holding<=0 and high>SCKD,1);
end


其中SHKD是上一次开多那根K线的收盘价,,,,,现在出的问题是加载到K线没有信号,问题可能出在SHKD这个变量上

想要达到的目的就是   这次的开多价格必须比前一次开多的价格高!

--  作者:jinzhe
--  发布时间:2014/11/13 11:16:20
--  
全部贴出来,让我来判断下你到底是什么问题,按照你的判断思路来找问题,不一定能有效准确的找到
--  作者:zhoutuoying
--  发布时间:2014/11/13 11:24:33
--  
NH:=REF(HHV(HIGH,N),1);
ML:=REF(LLV(LOW,M),1);

当前持仓:HOLDING,COLORGRAY,LINETHICK0;
当前资产:ASSET,NOAXIS,COLORGRAY;

SCKD:=REF(CLOSE,TYPEBAR(1,1));
SCKK:=REF(CLOSE,TYPEBAR(1,3));
//==============================
if high>NH then
begin
//平空开多
sellshort(holding<0 and high>NH,0);
buy(holding<=0 and high>SCKD,1);
end
if low<ML then
begin
//平多开空
sell(holding>0 and low<ML,0);
buyshort(holding>=0 and LOW<SCKK,1);
end

--  作者:jinzhe
--  发布时间:2014/11/13 11:38:04
--  

nh:=ref(hhv(high,n),1);
ml:=ref(llv(low,m),1);
variable:bj=0,sckd=0,sckk=0;


当前持仓:holding,colorgray,linethick0;
当前资产:asset,noaxis,colorgray;

 

if bj=0 and holding=0 and h>nh then begin
 buy(holding=0,1);
 bj:=1;
 sckd:=close;
end

if bj=0 and holding=0 and l<ml then begin
 buyshort(holding=0,1);
 bj:=1;
 sckk:=close;
end

//==============================
if high>nh and bj=1  then
begin
//平空开多
 sellshort(holding<0 and high>nh,0);
 if holding=0 then begin
  buy(holding=0 and high>sckd,1);
  sckd:=close;
 end
end

if low<ml and bj=1 and holding>0 then
begin
//平多开空
 sell(holding>0 and low<ml,0);
 if holding=0 then begin
  buyshort(holding=0 and low<sckk,1);
  sckk:=close;
 end
end


--  作者:jinzhe
--  发布时间:2014/11/13 11:38:41
--  

用全局变量来判断是否是第一次的开仓然后赋值变量

再用全局变量来给SCKK和SCKD记录开仓时的数值


--  作者:zhoutuoying
--  发布时间:2014/11/13 12:18:48
--  
好的,谢谢老师!