不懂為何這個程式碼會出錯請大家教教我var:Exitprice(N)while marketposition=0 and Exitprice(1)+20 thenbuy this bar;if marketposition=0 and Exitprice(1)-20 thensellshort this bar;end;
bestronger33 wrote:不懂為何這個程式碼...(恕刪) 我也不懂,不確定這是什麼語言, 一般的語法:請檢查看看marketposition=0 還是 marketposition==0.Exitpeice(1)+20. 還是 (Exitprice(1)+20)<=0. 還是 (Exitprice(1)+20)>=0Exitprice(1)-20 也是一樣通常 marketposition=0. 結果是NUMBER 類別, 值是0marketposition == 0, 才是 BOOLEAN 類別, 結果是 TRUE/FALSEExitprice(1)+20 結果也是數字, 加了 >=0 比較才會轉成Boolean參考看看,不熟,隨便猜
var:Exitprice(N)while marketposition=0 and Exitprice(1)+20 thenbuy this bar on close;if marketposition=0 and Exitprice(1)-20 thensellshort this bar on close;end;-------------------------------------------------------------------------------加上on close 就不會出現反覆的問題了一般程式交易都是用 next bar或是用限價突破 buy stop 或是 sellshort stop-----------------大約是這樣 multichart 不是粉會用 但程式邏輯一般如此
HTS 的語法var:Exitprice(N)IfMarketPosition = 0AND Exitprice(1)+20ThenBuy This Bar Market;End IfIfMarketPosition = 0AND Exitprice(1)-20ThenSell This Bar Market;End If使用 THIS BAR 要非常非常小心記得要勾選
bestronger33 wrote:喔對不起忘了說我這...(恕刪) 我不太懂MC等等的程式語言,不過這問題應該可以去某論壇的程式交易討論區問,那裡有實際在操作程式交易的人蠻多的。論壇網址已私訊給樓主了。