你好小幫手,想要請問在交易腳本中寫入這樣的condition
if GetSymbolInfo("買賣現沖") and getField("成交量")[1] > 1000 then condition1 = true;
if condition1 and q_priceChangeRatio > 3 then setposition(1);
為什麼回測和自動交易的成交標的會出現處置股及前一天成交量低於1000的股票?
謝謝
你好小幫手,想要請問在交易腳本中寫入這樣的condition
if GetSymbolInfo("買賣現沖") and getField("成交量")[1] > 1000 then condition1 = true;
if condition1 and q_priceChangeRatio > 3 then setposition(1);
為什麼回測和自動交易的成交標的會出現處置股及前一天成交量低於1000的股票?
謝謝
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;
小幫手建議您使用第一種寫起來比較方便。
1 評論