matlab 突破交易策略,Matlab量化交易策略之 横盘突破策略(附源码)
策略名稱:橫盤突破策略策略說明:
日內交易策略,收盤平倉;
橫盤突破在過去30根K線的高低點圍繞中軸上下0.5%的范圍內波動時;
上軌=過去30根K線的最高價;
下軌=過去30根K線的最低價;
當價格突破上軌,買入開倉;
當價格跌穿下軌,賣出開倉。
多頭出場條件:止損0.5%,盈利大于0.5%,啟動跟蹤止盈,回調20%多頭出場
空頭出場條件:止損0.5%,盈利大于0.5%,啟動跟蹤止盈,回調20%空頭出場
回測曲線:
QQ圖片20170217114330.png (86.04 KB, 下載次數: 4)
2017-2-17 11:48 上傳
策略代碼:
function??calmbreak(stoploss,stopprofit,trailinggap,Freq,shareNum)
%??橫盤突破
%??日內交易策略,收盤平倉;
%??橫盤突破在過去30根K線的高低點圍繞中軸上下0.5%??的范圍內波動時;
%??上軌=過去30根K線的最高價;
%??下軌=過去30根K線的最低價;
%??當價格突破上軌,買入開倉;
%??當價格跌穿下軌,賣出開倉。
%??stoploss止損閾值
%??stopprofit止盈閾值
%??trailinggap跟蹤止盈參數
%??Freq??數據頻率
%??shareNum??買賣手數
%---------------------策略初始化與是否日內平倉---------------%
traderDailyCloseTime(145000);??%??每天15:10分平倉
targetList??=??traderGetTargetList();
HandleList??=??traderGetHandleList();
marketposition=traderGetAccountPosition(HandleList(1),targetList(1).Market,targetList(1).Code);
lags=35;
[barnum,bartime]??=??traderGetCurrentBar(targetList(1).Market,targetList(1).Code);
if(barnum??<=lags)
return;
end
%---------------------策略提取數據---------------%
[time,open,high,low,close,volume,turnover,openinterest]??=??traderGetKData(targetList(1).Market,targetList(1).Code,'min',Freq,??0-lags,??0,false,'FWard');
if??length(close)<31
return;
end
%---------------------策略計算與基本邏輯---------------%
highTar??=??max(high(end-30:end-1));%??過去30根K線的最高價
lowTar??=??min(low(end-30:end-1));%??過去30根K線的最低價
if??marketposition??==??0??&&??close(end)??>??highTar
orderID1=traderBuy(HandleList(1),targetList(1).Market,targetList(1).Code,shareNum,0,'market','buy');
traderStopLossByOrder(HandleList(1),orderID1,stoploss,'Percent','market','stoplossS');
traderStopTrailingByOrder(HandleList(1),orderID1,stopprofit,'Percent',trailinggap,'Percent','market','trailingS');
end
if??marketposition??==??0??&&??close(end)??
orderID2=traderSellShort(HandleList(1),targetList(1).Market,targetList(1).Code,shareNum,0,'market','sell');
traderStopLossByOrder(HandleList(1),orderID2,stoploss,'Percent','market','stoplossB');
traderStopTrailingByOrder(HandleList(1),orderID2,stopprofit,'Percent',trailinggap,'Percent','market','trailingB');
end
end
更多免費策略源碼下載,請登錄 atrader社區-策略服務進行下載,ww w.atrader.com.cn
橫盤突破策略源碼下載:w ww.atrader.com.cn/stra.php?mod=model&pid=74
總結
以上是生活随笔為你收集整理的matlab 突破交易策略,Matlab量化交易策略之 横盘突破策略(附源码)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用scrapy写爬虫(一)快速上手
- 下一篇: 计算机全国一级b考试试题,全国版计算机等