請教這個連漲 + Retmsg的寫法是哪裡有誤

  •   75 
  • 最後發表   WEIWANG  2022 十月 26
WEIWANG 發文於   2022/10/25

請教各位先進,

我寫了一個連漲,利用retmsg顯示是幾次的連漲

但她永遠只會顯示三連漲

請問是哪裡寫錯了 感謝

condition1 = TrueAll(close > Close[1] ,3);

condition2 = TrueAll(close > Close[1] ,5);

condition3 = TrueAll(close > Close[1] ,7);

condition4 = TrueAll(close > Close[1] ,9);

if condition1 and condition2 and condition3 and condition4 then Ret = 1; retMsg="九連漲";

if condition1 and condition2 and condition3 then Ret = 1; retMsg="七連漲";

if condition1 and condition2 then Ret = 1; retMsg="五連漲";

if condition1 then Ret = 1; retMsg="三連漲";

 

 

排序方式: 標準 | 最新
WEIWANG 發文於   2022/10/25

Musashi大,你可以幫我看一下嗎

XQ小幫手 發文於   2022/10/26

Hello WEIWANG,

 

您的寫法,最後一定會執行 retMsg="三連漲";,所以顯示的也會是三連漲。

且執行順序因為其他條件符合時 condition1 一定會符合,而您放在最後的那個也一定會執行。

 

應該要:

if condition1 then begin 

    Ret = 1; 

    retMsg="三連漲";ret = 1;

    end;

 

if condition1 and condition2 then begin

    Ret = 1; 

    retMsg="五連漲";

    end;

 

...

 

這樣才會顯示對應的retMsg。

 

WEIWANG 發文於   2022/10/26

原來如此..... 謝謝

發表回覆
Close