1217  

 

完整策略的架構 需要幾個條件  1.決定交易商品  2.交易的型態(當沖或留倉)  3.進場交易的模式(順勢或是逆勢)  4.加入濾網條件  5.平倉出場的條件(停損或停利),以下是簡單的範例說明

[IntrabarOrderGeneration=true]{當根K棒內交易模式 True or False}

input: {用來設定可外部調整的參數}

var:upline(high),downline(low); {自訂變數}

{定義每天支撐壓力上下的軌道}

if date<>date[1] then begin

upline=highD(0);

downline=lowD(0);

end;

{用condition設定進場交易的時間以及開盤的漲跌幅當作濾網 }

condition1=openD(0)>=closeD(1)*m;

condition2=openD(0)<=closeD(1)*n;

condition3=time>=0900 and time<=1300 and marketposition=0 and close>upline;

condition4=time>=0900 and time<=1300 and marketposition=0 and close<downline;

{符合條件時進場作多或做空}

if condition1 and condition3 then buy next bar at market;

if condition2 and condition4 then sellshort next bar at market;

{多單的停損}

if marketposition=1 and close cross under downline then sell next bar at market;

{空單的停損}

if marketposition=-1 and close crosses over upline then buytocover next bar at market;

{當沖策略需要寫收盤前最後出場的時間}

if time>1330 and marketposition=-1 then buytocover next bar at market;

if time>1330 and marketposition=1 then sell next bar at market;

寫好策略之後按F3編譯,確定編譯成功 就可以套用到multicharts的主圖跑跑看回測的績效了。這是一個簡單的順勢突破策略

1014  

小心得: 先有交易的想法,用文字條列式敘述,再逐一轉換成powerlanguage語法;語法編譯成功不代表邏輯上一定沒有問題,需要放到技術分析圖上面比對買賣訊號;有出現買賣訊號不表示一定可以真實交易,要檢視策略本身的可行性最好觀察一段時間

根據過去回測的數據做策略調整,每個人的標準不同,對績效的要求與風險的控管程度也不同,投資人可根據過去的績效表現評估未來的交易方式

 

 以上心得分享 歡迎留言討論。 或是追蹤我的 FB粉絲頁   https://www.facebook.com/upup12341234

 

arrow
arrow

    元大期貨楊宗儒 發表在 痞客邦 留言(0) 人氣()