如何串接3個警示 布林上緣買超+寶塔線紅K+成交量突破N倍 用於分K線

  •   509 
  • 最後發表   股市小貓咪  2025 一月 08
股市小貓咪 發文於   2025/01/07

如何串接3個警示?    布林上緣買超+寶塔線紅K+成交量突破N倍三個同時達成觸發警示   用於分K線

以下是我串接的邏輯,感覺抓不到我要的點,我該怎麼修改。 

// 布林通道超買訊號

Input: Length(20), UpperBand(2);

settotalbar(Length + 3);

SetInputName(1, "期數");

SetInputName(2, "通道上緣");

if High >= bollingerband(Close, Length, UpperBand) then Value2 = 1;

// 寶塔線紅K

input: Length1(4);

variable: _Index(0), HV(0), LV(0);

SetInputName(1, "寶塔天數");

HV = Close[1];

LV = Close[1];

for _Index = 2 to Length1 + 1

begin

if HV <= Close[_Index] then HV = Close[_Index];

if LV >= Close[_Index] then LV = Close[_Index];

end;

if Close > HV then Value1 = 1

else if Close < LV then Value1 = -1;

//成交量突破N倍

//input: length(20);  setinputname(1,"均量期數");

input: VolumeXtime(3);  setinputname(2,"量增倍數");

settotalbar(3);

setbarback(Length);

if volume > Average( volume[1],length)* VolumeXtime then Value3 = 1;

if Value1 = 1 and Value2 = 1 and Value3 = 1  then ret=1;

 

排序方式: 標準 | 最新
虎科大許教授 發文於   2025/01/07

問題應該出在你的value1, value2, value3只要在跑歷史K棒時變成1,它就一直是1,這造成在最後一根即時K棒時,儘管這三個變數沒有全部符合條件,仍然會警示。

XQ小幫手 發文於   2025/01/08

股市小貓咪,您好:

同虎科大許教授所說,將 value1, value2, value3 初始化後,應該就能排除您的問題,如下修改後的範例程式碼:

// 布林通道超買訊號
Input: Length(20), UpperBand(2);
SetTotalBar(Length + 3);
SetInputName(1, "期數");
SetInputName(2, "通道上緣");

Value2 = 0; // 初始化
if High >= BollingerBand(Close, Length, UpperBand) then Value2 = 1;

// 寶塔線紅K
Input: Length1(4);
Variable: _Index(0), HV(0), LV(0);
SetInputName(1, "寶塔天數");

HV = Close[1];
LV = Close[1];
for _Index = 2 to Length1 + 1 begin
    if HV <= Close[_Index] then HV = Close[_Index];
    if LV >= Close[_Index] then LV = Close[_Index];
end;

Value1 = 0; // 初始化
if Close > HV then Value1 = 1 else if Close < LV then Value1 = -1;

// 成交量突破N倍
Input: VolumeXtime(3);
SetInputName(2, "量增倍數");
Input: Vol_Length(20, "均量期數");
SetTotalBar(3);
SetBarBack(Vol_Length);

Value3 = 0; // 初始化
if Volume > Average(Volume[1], Vol_Length) * VolumeXtime then Value3 = 1;

// 最終判斷
if Value1 = 1 and Value2 = 1 and Value3 = 1 then ret = 1;

 

小幫手方才在 2025/01/08 下午 15:56:01 用雷達執行頻率1分K跑出來的觸發紀錄,對照商品的技術分析查看應該是無誤的,如副檔圖,您可以試試看,謝謝。

附加文件

發表回覆
Close