,但使用後發現是依據寶塔線高/低點這個設定去判斷翻紅,而不是依據K線圖高/低點(附檔),想請問各位先進該如何修改 ? 感謝

,但使用後發現是依據寶塔線高/低點這個設定去判斷翻紅,而不是依據K線圖高/低點(附檔),想請問各位先進該如何修改 ? 感謝

系統提供的寶塔線指標,預設的情況是依據K線圖高低點繪製。你可以參考該指標進行修改。
input: _len(3, "天數"), _reversal(1, "趨勢反轉判斷", inputkind:=Dict(["依據K線圖高/低點",1],["依據寶塔線高低/點",2]));
var: _name("");
SetBackBar(_len);
if _reversal = 1 then begin
value1 = highest(high[1], _len);
value2 = lowest(low[1], _len);
end
else if _reversal = 2 then begin
value1 = highest(value3[1], _len);
value2 = lowest(value4[1], _len);
end;
value3 = maxlist(close, close[1]);
value4 = minlist(close, close[1]);
if close cross over value1 then begin
condition1 = True;
condition2 = False;
end
else if close cross under value2 then begin
condition1 = False;
condition2 = True;
end;
if currentbar > _len then begin
if not condition1[1] and condition1 then
_name = "翻紅"
else if condition1 then
_name = "續紅"
else if not condition2[1] and condition2 then
_name = "翻黑"
else if condition2 then
_name = "續黑";
if condition1 then
plotk(1, value4, value3, value4, value3)
else if condition2 then
plotk(1, value3, value3, value4, value4);
end;
setplotLabel(1, text(_name));
謝謝教授,小弟知道您分享的指標寫法,但小弟希望是將之前網友分享的程式(下列)改成"依據K線圖高/低點"這個設定去判斷翻紅而非"依據寶塔線高/低點",小弟試著修改幾次選出的結果還是有問題,懇請賜教如何將下列程式修改成"依據K線圖高/低點"這個設定去判斷翻紅,謝謝
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[1] < LV[1] and Close > HV then ret=1;
input: Length(4);
variable: HV(0), LV(0);
HV = highest(h[1], Length);
LV = lowest(L[1], Length);
if close cross over HV then
begin
condition1 = True;
condition2 = False;
end
else
if close cross under LV then
begin
condition1 = False;
condition2 = True;
end;
if condition1[1]=false and condition1 then ret=1;
謝謝教授分享,小弟改用教授的寫法跑出來的結果似乎也有落差,小弟用moneydj選股專家(見下圖)篩選出來今天寶塔線翻紅的家數是184檔,教授的寫法跑出來的結果(見下圖)只有68檔(紅色框框是昨天就翻紅並非今天),所以不知該怎麼改寫才能跟moneydj選股專家跑出一樣的結果 ?


應該是參數的關係。把Length參數改成3,就可得到186檔。
謝謝教授,小弟將參數改成3後確實跑出186檔(2027/07/22收盤資料),但仔細比對moneydj選股專家與教授分享的程式檔篩選出來的結果發現,兩邊各有幾檔並未符合"由綠翻紅第一根"的條件,例如moneydj的1529,6244.......等,教授程式的4950,3646.....等,以上供教授參考,或許等"XS小編"看到此篇能告訴我們問題所在 ?
問題應該出在準備的資料不足。用預設的10筆資料,這10筆裡面沒有出現向下跌破與向上突破時,Condtion1及Condition2都是False。這裡有邏輯錯誤問題。若加SetTotalBar(300);則7/22的選股4950及3646都不會被選出來。
教授您好,謝謝提醒,篩選天數確實需增加,不能只用預設的10筆。另外,因為moneydj選股專家是以"還原股價"作為篩選標準所以與程式篩選出來的(未還原股價)會有差異,以上,謝謝您
8 評論