variable:HHbias=0;
variable:LLbias=0;
250乖离率:=((close-250ma)/250ma)*100,noaxis;
250乖离率中间:=between(250乖离率,llbias,hhbias);
hbias:=hhv(250乖离率,30),noaxis;
lbias:=llv(250乖离率,30),noaxis;
hb:=if(hbias>ref(hbias,1),hbias,ref(hbias,1));
lb:=if(lbias<ref(hbias,1),lbias,ref(hbias,1));
if close<250ma and hbias=0 and lbias=0 then begin
HHbias:=hb,noaxis;
if islastbar then begin
debugfile('d:\test1.text','HHbias%.0f',HHbias);
LLbias:=lb,noaxis;
if islastbar then BEGIN
debugfile('d:\test2.text','LLbias%.0f',LLbias);
end
end
end
各位老师,上面“250乖离率中间”的llbias和hhbias,通过变量赋值得到的话是否可以使用呢?谢谢!
可以.
看你的代码发现个小问题 代码是自上而下运行,
所以
250乖离率中间:=between(250乖离率,llbias,hhbias);
这句 中的llbias用的是上一根K线的llbias,因为本根K的llbias要等之后的代码运行后才产生。
不知这是否符合你的原意。
若不是的话,把这句放到最后。
250ma是指250日均线,250乖离率是指价格与250日均线的偏离程度,
比如说现在30日内的最高的乖离率是5,hhbias就等于5,如果现在30日内最高的乖离率是6,则hhbias就等于6;250乖离率中间:=between(250乖离率,llbias,hhbias);这个里面的llbias 和hhbias会随着30日内乖离率不同而变化;因为对变量不是很了解,像上面的语句可以达到前面说的那种效果么?能否帮我修改下,谢谢!