大家好,有板友詢問:
SetPlotLabel沒作用, 該如何show出 "天期"?
該版友的指標程式碼如下:
input: Length(4);
variable: _Index(0), HV(0), LV(0);
settotalbar(200);
HV = Close[1];
LV = Close[1];
for _Index = 2 to Length + 1
begin
if HV <= Close[_Index] then HV = Close[_Index];
if LV >= Close[_Index] then LV = Close[_Index];
end;
if Close <= LV then plot1(LV, "Green")
if Close >= hv then plot2(hV, "red");
SetPlotLabel(1, Text("天期(", NumToStr(Length, 0), ")"));
//SetPlotLabel沒作用, 該如何show出 "天期" ,謝謝
其實呢,
在 if Close <= LV 會Show出天期,
但是,
在此條件外不會Show出天期,原因是if條件沒達成,故不會繪製序列的名稱。
如果,理解上述所述,但還是想要繪製序列的名稱,
那就要修改此程式碼 if Close <= LV then plot1(LV, "Green")
為 if Close <= LV then plot1(LV, "Green") else plot1(0,"Green");
修改此行程式碼的意思就是,若 if Close <= LV 條件不成立,則 plot1 數值為0,
這樣在條件不成立的狀況下,仍可以繪製出數值為0的plot1,
所以就可以繪製 SetPlotLabel(1, Text("天期(", NumToStr(Length, 0), ")"));
如圖

修改後的完整程式碼範例如下:
input: Length(4);
variable: _Index(0), HV(0), LV(0);
settotalbar(200);
HV = Close[1];
LV = Close[1];
for _Index = 2 to Length + 1
begin
if HV <= Close[_Index] then HV = Close[_Index];
if LV >= Close[_Index] then LV = Close[_Index];
end;
if Close <= LV then plot1(LV, "Green")
else plot1(0,"Green");
if Close >= hv then plot2(hV, "red");
SetPlotLabel(1, Text("天期(", NumToStr(Length, 0), ")"));
//SetPlotLabel沒作用, 該如何show出 "天期" ,謝謝
以上,提供參考,謝謝。
1 評論