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或微信请选择方便的一个联系我们就行,加好友时请简单备注下您的需求,否则无法通过。谢谢您!)
相关文章
-
没有相关内容