期货软件TB系统源代码解读系列64-均线和形态的高低点突破
策略说明:本策略是基于均线和K线形态的高低点突破系统
系统要素:
1. 根据价格与快速均线和慢速均线的关系来判断大的趋势,价格在上为多头趋势,在下为空头趋势
2. 根据2根K线收盘位置构成的形态来判断小趋势,第一根收盘靠近低点第二根收盘靠近高点为上涨趋势,否则为下跌趋势
3. 最近2根K线的高低点形成的通道
入场条件:
1. 大趋势为多头趋势,且K线形态也为多头趋势时,突破通道高点做多
2. 大趋势为空头趋势,且K线形态也为空头趋势时,突破通道低点做空
出场条件:
1. 开多以开仓BAR的最近N根BAR的低点作为止损价
开空以开仓BAR的最近N根BAR的高点作为止损价
2. 盈利超过止损额的一定倍数止盈
这程序化系统大周期的的结果很差,5min的测试相对好点,下面是做多代码及解读如下:
**** Hidden Message ***** [attach]25926[/attach] 做空代码及结果如下:[code]Params
Numeric FastLength(8);
Numeric SlowLength(40);
Numeric RiskLength(2);
Numeric ProfitFactor(2);
Vars
NumericSeries MA_Fast;
NumericSeries MA_Slow;
Numeric Range;
BoolSeries Condition1;
BoolSeries Condition2;
NumericSeries HH;
NumericSeries LL;
NumericSeries ShortRisk;
Begin
If(!CallAuctionFilter()) Return;
MA_Fast = Average(Close,FastLength);
MA_Slow = Average(Close,SlowLength);
PlotNumeric("Ma_Fast",MA_Fast);
PlotNumeric("Ma_Slow",MA_Slow);
Range = High - Low;
Condition1 = Close >= High - 0.25 * Range;
Condition2 = Close <= Low + 0.25 * Range;
LL = Lowest(Low,2);
HH = Highest(High,RiskLength);
If(MarketPosition == 0 And Condition1[2] And Condition2[1] And Close[1] < MA_Fast[1] And Close[1] < MA_Slow[1] And Vol > 0)
{
If(Low <= LL[1] - MinMove * PriceScale)
{
SellShort(0, Min(Open,LL[1] - MinMove * PriceScale));
ShortRisk = HH[1] + MinMove * PriceScale;
}
}
If(MarketPosition == -1 And BarsSinceEntry > 0 And Vol > 0)
{
If(Low <= EntryPrice - ProfitFactor * (ShortRisk - EntryPrice))
{
BuyToCover(0, Min(Open,EntryPrice - ProfitFactor * (ShortRisk - EntryPrice)));
}
Else If(High >= ShortRisk)
{
BuyToCover(0, Max(Open,ShortRisk));
}
}
End
[/code] [attach]25927[/attach] 看看
页:
[1]