期貨期權交流趨勢策略-三均線利劍 [MC]
- 咨詢內容:
近來歐美股市的波動非常大啊,伊波拉病毒也蠢蠢欲動.....不知道會不會影響到咱們中國,也因此,策略天地在此介紹一個趨勢型的策略,讓讀者們試試,策略優點主要在動態出場,進場隨意寫的,需要靠用戶優化
策略適用商品:趨勢性較好的商品。下圖測試商品IF,3 min周期。
原理如下:此策略是根據短期及中長期均線確認行情方向,然后當行情突破近期高低點時進行趨勢性開倉。
出場停利用常用的三條均線作為出場條件,根據進場后的行情創新高跟新低的次數控制用哪條均線出場,好處是防止剛剛進場后激活短期均線,容易錯失大的行情。
input:x(30),y(120),m(20),n(15);var:ma1(close),ma2(close);
ma1=Average(close,x);ma2=Average(close,y);
condition1=close>ma1 and ma1>ma2;condition2=close<ma1 and ma1<ma2;condition3=high > highest(high,m)[1];condition4=low <lowest(low,n)[1];//以上定義變量跟參數,對進場條件進行定義
if marketposition=0 and condition1 and condition3 then buy next bar at market;//判斷進場條件
//////////////////////input:f1(10),f2(20),f3(30),stp(11);var:av1(0),av2(0),av3(0),position(0),stH(0),Hct(0),stl(0),lct(0);av1 = average(close, f1);av2 = average(close, f2);av3 = average(close, f3);position = marketposition;//定義常用的三條移動平均線
if position =1 and position[1] =0 then beginstH = high;Hct =0;end;//進場后對第一個bar高點賦值
if position =1 and close > stH then beginstH = high;Hct = Hct[1] +1;end;//后面對創新高時進行累加計算
if position =1 then beginif Hct <3 then sell("begin stop") next bar at entryprice - stp stop;if Hct >=3 and Hct <6 then sell("30stop") next bar at av3 stop;if Hct >=6 and Hct <9 then sell("20stop") next bar at av2 stop;if Hct >=9 then sell ("10stop") next bar at av1 stop;end;//當有持倉時,累加值作為激活某條均線的出場條件,有長期均線激活開始,這樣可以防止進場后快速被洗出來。
////////////////////////if marketposition=0 and condition2 and condition4 then sellshort next bar at market;if position =-1 and position[1] =0 then beginstl = low;lct =0;end;if position =-1 and close < stl then beginstl = low;lct = lct[1] +1;end;if position =-1 then beginif lct <3 then buytocover("begin stop1") next bar at entryprice + stp stop;if lct >=3 and lct <6 then buytocover("30stop1") next bar at av3 stop;if lct >=6 and lct <9 then buytocover("20stop1") next bar at av2 stop;if lct >=9 then buytocover ("10stop1") next bar at av1 stop;end;//原理跟上面的多單進場出場條件判斷一致,方向相反操作
此策略參數未做優化處理,都是常用的數值,可以按照此思路作為之后策略的出場判斷。
展示圖如下:
-
three_sword.pla
2014-10-21 10:00 上傳
點擊文件名下載附件
4.94 KB, 下載次數: 11
售價: 10 金錢 [記錄]
源代碼下載
- MC技術部: 學習了,不錯的思路
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 511411198 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容