//------------------------------------------------------------------------
// 简称: MovingAverageCrossOver_L
// 名称: 基于均线交叉的通道突破系统多
// 类别: 公式应用
// 类型: 内建应用
// 输出:
//------------------------------------------------------------------------
//----------------------------------------------------------------------//
// 策略说明:
// 本策略是基于均线交叉与通道突破相结合的交易系统
//
// 系统要素:
// 1. 以快速均线与慢速均线的交叉初步判断趋势
// 2. 均线交叉后以最近几根K线的高低点加上一定幅度设定为突破通道
// 3. 均线交叉后一定K线根数内突破通道则趋势有效,否则等待下次趋势
// 入场条件:
// 1. 当价格向上突破通道时做多
// 2. 当价格向下突破通道时做空
// 出场条件:
// 1. 趋势反转突破时平仓
// 2. 基于周期高低点的跟踪止损
// 再入场条件:
// 1. 未发生趋势反转
// 2. 跟踪止损后一定K线根数内突破止损时N根K线的高低点时再进场
//
// 注: 当前策略仅为做多系统, 如需做空, 请参见CL_MovingAverageCrossOver_S
//----------------------------------------------------------------------//
Params
Numeric FastLen(15); // 快速均线周期数
Numeric SlowLen(60); // 慢速均线周期数
Numeric ChLen(12); // 通道突破的周期数
Numeric Blots(1);
Numeric Slots(1);
Numeric BuyYes(1);
Numeric SellYes(1);
Vars
Series<Numeric> FastMA; // 快速均线
Series<Numeric> SlowMA; // 慢速均线
Bool ConCrossOver; // 是否金叉(快速均线上穿慢速均线)
Bool ConCrossUnder; // 是否死叉(快速均线下穿慢速均线)
Numeric HH; // 最近N根BAR的高点
Numeric LL; // 最近N根BAR的低点
Global Integer havebuy;
Events
OnInit()
{
havebuy=7;
}
OnBar(ArrayRef<Integer> indexs)
{
// 计算均线
FastMA = Average(Close, FastLen);
SlowMA = Average(Close, SlowLen);
PlotNumeric(\"FastMA\",FastMA);
PlotNumeric(\"SlowMA\",SlowMA);
// 判断均线是否金叉
ConCrossOver = CrossOver(FastMA[1],SlowMA[1]);
ConCrossUnder = CrossUnder(FastMA[1],SlowMA[1]);
If(Data1.Marketposition!=1 and Data0.Marketposition!=1 and havebuy==7 And BuyYes==1 And ConCrossOver And Vol > 0)
{
Data1.Buy(Blots, Data1.Open );
Data0.Buy(Blots, Data0.Open);
}
if( data1.MarketPosition==1 and data0.MarketPosition==1 and Data1.BarsSinceEntry >1 )
{
havebuy=2;
}
If(Data0.MarketPosition == 1 and ConCrossUnder )
{
data1.Sell(0,data1.Open-0);
data0.Sell(0,data0.Open-0);
havebuy=7;
}
}
//------------------------------------------------------------------------
// 编译版本 GS2014.10.25
// 版权所有 TradeBlazer Software 2003-2025
// 更改声明 TradeBlazer Software保留对TradeBlazer平
// 台每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------
...这位是刘老师
王老师,我又试了一下,新建了一个策略单元,录了个视频,您看看,我发到QQ了。
我加载以后为什么有很多次交易?