ret = condition1 and condition2 and condition3 篩選結果卻 正確與錯誤參雜

  •   96 
  • 最後發表   wns  2023 十二月 29
wns 發文於   2023/12/29

Hello 
我用了一個指標當作選股參考寫腳本
code 如下 : 

input: FastLength(12), SlowLength(26), MACDLength(9), OscDecrease(5);

variable: price(0);

 

SetInputName(1, "DIF短天數");

SetInputName(2, "DIF長天數");

SetInputName(3, "MACD天數");

 

price = WeightedClose();

 

Value1 = XAverage(price, FastLength) - XAverage(price, SlowLength);

Value2 = XAverage(Value1, MACDLength) ;

Value3 = Value1 - Value2 ;

 

condition1 = CrossOver(Value1,Value2);

condition2 = Value3[1] < 0 and Value3 > 0;

 

condition3 = TrueAll(Value3>Value3[1], OscDecrease);

ret = condition1 and condition2 and condition3;

這樣子篩選出來的結果卻是
有 condition1 = 0 and condition2 = 0 and condition3 = 1 的結果 (如附圖)

我期望的結果是 condition1 = 1 and condition2 = 1 and condition3 = 1

想請問這段code是哪邊寫得有問題呢 謝謝


附加文件

排序方式: 標準 | 最新
wns 發文於   2023/12/29

圖好像附的不是很清楚

附加文件

XS小編 發文於   2023/12/29

Hello wns,

 

小幫手認為是您的資料讀取筆數不足讓運算出來的數值和指標看到的不同所導致。

因為指數移動平均是種會運用到前期運算值的指標,所以資料讀取筆數不足會讓計算出來的數值有誤。

建議您可以將筆數設長避免此種狀況 (150筆以上應該就足夠),搭配使用 outputfield 來確認運算數值。

發表回覆
Close