交易腳本中昨量和買賣現沖限制

  •   149 
  • 最後發表   StockS  2023 三月 27
StockS 發文於   2023/03/24

你好小幫手,想要請問在交易腳本中寫入這樣的condition

if GetSymbolInfo("買賣現沖") and getField("成交量")[1] > 1000 then condition1 =  true;

if condition1 and q_priceChangeRatio > 3 then setposition(1);

為什麼回測和自動交易的成交標的會出現處置股及前一天成交量低於1000的股票?

謝謝

XQ小幫手 發文於   2023/03/27

 Hello StockS,

 

if GetSymbolInfo("買賣現沖") and getField("成交量")[1] > 1000 then condition1 =  true;

這種寫法會讓條件符合後 condition1 就會一直維持在 True,因為裡面沒有包含條件不符合的話 condition1 為何。

 

應該修改為

condition1 = GetSymbolInfo("買賣現沖") and getField("成交量")[1] > 1000;

或是

if GetSymbolInfo("買賣現沖") and getField("成交量")[1] > 1000 then condition1 =  true else condition1 = false;

 

小幫手建議您使用第一種寫起來比較方便。

 

發表回覆
Close