condition的語法撰寫問題

  •   1.1K 
  • 最後發表   charlie1234  2024 五月 31
charlie1234 發文於   2022/09/06

小幫手好

想知道condition的寫法,是不是有所限制,如一定要是下面寫法才行

consdition1=......   

而不能寫成

if ....... then condition1=true;  

我用以下的程式碼

If (date>=20200317 and date<=20200405) then condition1=true;

if condition1  then ret=1;

在選股裡面,如果是用and,則進場只會是20200318之後

如果是用NOT,則進場只會是20200317之前

 

如果沒有用condition,寫成下面那樣,就很正常

If (date>=20200317 and date<=20200405) then ret=;

檔案已附上,請小幫手協助瞭解,謝謝

 

 

 

附加文件

排序方式: 標準 | 最新
XQ小幫手 發文於   2022/09/14

Hello charlie1234,

 

condition1 就像是 value1 一樣,是系統內建的變數但只保存布林值。

If (date>=20200317 and date<=20200405) then condition1=true; 這種寫法是可以的,但須注意這樣寫的話在 date>=20200317 以後都會是True,因為不符合的時候您沒有將 condition1 調整回 False,所以一旦條件成立過後,condition1就會一直維持True。

If (date>=20200317 and date<=20200405) then condition1=true else condition1 = False; 這樣的話就會和 condition1 = (date>=20200317 and date<=20200405); 相同。

linhappy 發文於   2024/05/31

請問這個排除大跌時段是如何計算的

發表回覆
Close