想請問小幫手,剛剛我的策略突然自動下單,但是下單的指令有誤,這個策略也跑了一個月了都沒有問題,請幫我看一下那裡有問題
主要是圈起來的地方,我初始部位有兩口小台多單,但有觸發到新的進場指令,可是此指令是多單進場的指令,怎麼會是賣出呢(指令行數47)


想請問小幫手,剛剛我的策略突然自動下單,但是下單的指令有誤,這個策略也跑了一個月了都沒有問題,請幫我看一下那裡有問題
主要是圈起來的地方,我初始部位有兩口小台多單,但有觸發到新的進場指令,可是此指令是多單進場的指令,怎麼會是賣出呢(指令行數47)


Hello 豬仔,
and 運算子的優先度高於 or。
所以您的 filled = 0 and (condition7 and condition11) or (condition8 and condition12) or (condition8 and condition11)
會相當於 (filled = 0 and (condition7 and condition11)) or (condition8 and condition12) or (condition8 and condition11)。
可參考 stackoverflow 和 wiki 上的說明。
所以只要 condition8 and condition12 或是 condition8 and condition11 符合的話,setposition(1, market) 也會執行。
小幫手推測您應該是要寫成 filled = 0 and ((condition7 and condition11) or (condition8 and condition12) or (condition8 and condition11)) 才對。
如果您想知道XS中運算子的優先順序的話,可以參考C++運算子的優先順序。
1 評論