[求助]變量用法
作者:金字塔 來源:cxh99.com 發布時間:2015年07月30日
- 咨詢內容:
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日內乖離率不同而變化;因為對變量不是很了解,像上面的語句可以達到前面說的那種效果么?能否幫我修改下,謝謝!