Aberration交易系統源碼整理: [開拓者 TB]
-
咨詢內容:
Aberration交易系統源碼整理:青蜂俠 微信adu3341 ;QQ 994206922 ;
交易開拓者 代碼
Params
? ? ? ? Numeric Length(90);
? ? ? ? Numeric StdDevUp(2.0);??//標準差參數
? ? ? ? Numeric StdDevDn(-2.0); //標準差參數
? ? ? ? Numeric Lots(1);
Vars
? ? ? ? Series<Numeric> UpperBand;
? ? ? ? Series<Numeric> LowerBand;
? ? ? ? Series<Numeric> AveMa;
? ? ? ? Numeric StdValue;
Events
? ? onBar(ArrayRef<Integer> indexs)
? ? {? ?
? ?? ???//布林指標計算
? ? ? ? ? ? AveMa=Average(Close[1],Length);
? ? ? ? ? ? StdValue = StandardDev(Close[1],Length);
? ? ? ? ? ?
? ? ? ? ? ? UpperBand=Avema+StdDevUp*StdValue;? ?//標準差參數
? ? ? ? ? ? LowerBand=Avema-StdDevUp*StdValue;? ?//標準差參數
? ? ? ? ? ?
? ? ? ? ? ? PlotNumeric("UpperBand",UpperBand);
? ? ? ? ? ? PlotNumeric("LowerBand",LowerBand);
? ? ? ? ? ? PlotNumeric("AveMa",AveMa);
? ? ? ? ? ? //
? ? ? ? ? ? If(MarketPosition!=1 &&CrossOver(Close[1],UpperBand[1]))
? ? ? ? ? ? {
? ?? ?? ?? ? Buy(Lots,Open);
? ? ? ? ? ? }
? ???
? ? ? ? ? ? If(MarketPosition!=-1 &&CrossUnder(Close[1],LowerBand[1]))
? ? ? ? ? ? {
? ?? ?? ?? ? SellShort(Lots,Open);
? ? ? ? ? ? }
? ???
? ? ? ? ? ? If(MarketPosition==1 && Close[1]<AveMa[1])
? ? ? ? ? ? {
? ?? ?? ?? ? Sell(Lots,Open);
? ? ? ? ? ? }
? ???
? ? ? ? ? ? If(MarketPosition==-1 && Close[1]>AveMa[1])
? ? ? ? ? ? {
? ???
? ?? ?? ?? ?BuyToCover(Lots,Open);
? ? ? ? ? ? }
? ???
}
===========================================================
TBQuant
Params
? ? ? ? //此處添加參數
? ? ? ? Numeric lots(0);
? ? ? ? Numeric Length(80);
Vars
? ? ? ? //此處添加變量
? ? ? ? Series<Numeric> UpperBand;
? ? ? ? Series<Numeric> LowerBand;
? ? ? ? Series<Numeric> AveMa;
? ? ? ? Numeric StdValue;
? ? ? ? bool buycon;
? ? ? ? bool sellcon;
Defs
? ? ? ? //此處添加公式函數
Events
? ? ? ? //此處實現事件函數
? ? ? ? //初始化事件函數,策略運行期間,首先運行且只有一次
? ? ? ? OnInit()
? ? ? ? {? ? ? ?
? ? ? ? }
? ? ? ? //Bar更新事件函數,參數indexs表示變化的數據源圖層ID數組
? ? ? ? OnBar(ArrayRef<Integer> indexs)
? ? ? ? {
? ? ? ? //布林指標計算
? ? ? ? ? ? ? ? AveMa=Average(close[1],Length);
? ? ? ? ? ? ? ? StdValue=StandardDev(close[1],Length);
? ? ? ? ? ? ? ? UpperBand=AveMa+2*StdValue;
? ? ? ? ? ? ? ? LowerBand=AveMa-2*StdValue;
? ? ? ? ? ? ? ? PlotNumeric("UpperBand",UpperBand);
? ? ? ? ? ? ? ? PlotNumeric("LowerBand",LowerBand);
? ? ? ? ? ? ? ? PlotNumeric("AveMa",AveMa);
? ? ? ? //開倉條件計算
? ? ? ? ? ? ? ? buycon=CrossOver(close[1],UpperBand[1]);
? ? ? ? ? ? ? ? sellcon=CrossUnder(close[1],LowerBand[1]);
? ? ? ? //突破中軌平倉
? ? ? ? ? ? ? ? If(MarketPosition==1 && close[1]<AveMa[1])sell(0,Open);
? ? ? ? ? ? ? ? If(MarketPosition==-1 && close[1]>AveMa[1])BuyToCover(0,Open);
? ? ? ? //突破上下軌道開倉
? ? ? ? ? ? ? ? If(MarketPosition!=1 && buycon)buy(lots,Open);
? ? ? ? ? ? ? ? If(MarketPosition!=-1 && sellcon)SellShort(lots,Open);? ? ? ? ? ? ? ?
? ? ? ? }
===========================================================
在Tradestation下
Input: Length(35), StdDevUp(2.0), StdDevDn(-2.0);
Vars: UpBand(0), DnBand(0), Ave(0);
UpBand=BollingerBand(Close, Length, StdDevUp);
DnBand=BollingerBand(Close, Length, StdDevDn);
Ave=Average(Close, Length);
{--------Enter Long--------}
if (MarketPosition=0) and (Close > UpBand) then
Buy("BE") tomorrow at market;
{--------Enter Short--------}
if (MarketPosition=0) and (Close < DnBand) then
Sell("SE") tomorrow at market;
{--------Exit Long--------}
if (MarketPosition=1) and (Close < Ave) then
ExitLong("LX") today at Close;
{--------Exit Short--------}
if (MarketPosition=-1) and (Close > Ave) then
ExitShort("SX") today at Close;
==========================================================
MC(MultiCharts)平臺上的源碼:
inputs: Len(35),Dev(2),type(0);
variables: ma(0),std(0),up(0),down(0);
ma = AverageFC(Close,Len);
std = StandardDev(Close, Len,1); //StandardDev( Close, Period, 1 ) ;
up = ma + Dev * std;
down = ma - Dev * std;
if(type=0) then
begin
? ? if(marketposition=0 and close>up) then
? ? begin
? ?? ???buy("b") next bar at market;
? ? end;
? ? if(marketposition=0 and close<down) then
? ? begin
? ?? ???sellshort("s") next bar at market;
? ? end;
? ? if(marketposition>0 and close<ma) then sell("sp") next bar at market;
? ? if(marketposition<0 and close>ma) then buytocover("bp") next bar at market;
end
else
begin
? ? if(marketposition=0) then
? ? begin
? ?? ???buy("b2") next bar at up stop;
? ?? ???sellshort("s2") next bar at down stop;
? ? end;? ?
? ? if(marketposition>0) then sell("sp2") next bar at ma stop;
? ? if(marketposition<0) then buytocover("bp2") next bar at ma stop;
end;
=========================================================
有思路,想編寫各種指標公式,交易模型,選股公式,還原公式的朋友
可聯系技術人員 QQ: 262069696 或微信號:cxh99cxh99 進行 有償收費 編寫!
(注:由于人數限制,QQ或微信請選擇方便的一個聯系我們就行,加好友時請簡單備注下您的需求,否則無法通過。謝謝您!)
相關文章
-
沒有相關內容