丟委託單,除了市價單(Market,單子需要見價就成交),另外就是掛單(單子掛在指定的價位等候行情來到),掛單分為Limit單跟Stop單兩大類。許多人在寫PowerLanguage策略時常常搞不清楚Limit與Stop的差別,弄混了就會發現整個交易訊號"錯很大"!

另外再舉一個例子,要寫一個"最低獲利保障出場機制",以多單為例,就是多單進場價7700,當獲利來到80點,也就是7780,開始啟動最低獲利保障出場機制,假設最低獲利保障為40點,也就是只要回檔到7740就強制停利出場。語法如下:
......
......
......
if marketposition=1 and close>entryprice+80 then gg1=1;
if gg1=1 then sell next bar at entryprice+40 stop;
......
......
if marketposition=1 and close>entryprice+80 then gg1=1;
if gg1=1 then sell next bar at entryprice+40 stop;
......
......
這個出場機制我們另有章節詳細解說,僅就"sell next bar at entryprice+40 stop;"作說明,這邊如何判斷要用Stop呢?首先要成立這個出場條件一定是價格來到entryprice+80之後,而我們要掛單的位置在entryprice+40,也就是在現價之下,根據口訣"欲賣出之價位在現價之下用Stop(停損單)",所以要用Stop單。
歡迎加入LINE@
(點擊上方圖示)