- 精华
- 0
- 在线时间
- 78 小时
- UID
- 92443
- 积分
- 74
- 帖子
- 41
- 阅读权限
- 30
- 注册时间
- 2012-1-11
- 最后登录
- 2013-7-10
- 精华
- 0
- UID
- 92443
- 积分
- 74
- 帖子
- 41
- 主题
- 10
- 阅读权限
- 30
- 注册时间
- 2012-1-11
- 最后登录
- 2013-7-10
|
它的代码不是TB得,希望大虾们能转为TB,让大家一起观摩学习。
背景简介:
这个系统的创作人是Philipp Kahler,德国人。由WLD开发者...场趋势上获利。
实际的市场趋势(牛/熊)由ADX、DIMinus和DIPlus确定,并由EMA的方向确认,交易信号由最高价和最低价的SMA产生。
进场部分:
ADX显示趋势有多强,作为一个标准值,如果ADX>30,趋势就是强的。趋势的方向由DIMinus和DIPlus决定。如果DMPlus在DIMinus之上,趋势就是牛的(浅绿色背景),反之,就是熊的(浅红色背景)。ADX、DIMinus和DIPlus的初始长度设置是18(读物中的标准长度是14,而ADX的边界值是20)。
趋势的确认通过观察收盘价的EMA做到。如果实际的EMA比前一天的EMA高,市场就向上走,因此牛趋势被确认。EMA的长度是28个K线。被确认的牛趋势用暗绿色显示,被确认的熊趋势用暗红色确认。
买入信号(做多)在牛趋势被检测并确认时,并且收盘价大于最高价的SMA时产生。SMA的长度是5个K线。
出场部分:
当日最低价穿过它的SMA,或者收盘价低于它的EMA时,做多信号就被关闭。做空信号情况类似但相反。
风险控制:
无采取特别的风险控制措施。
资金管理:
每次交易用总帐户的10%资金建仓。
测试绩效:
根据Kahler的说法,从1998年10月开始,两年内这个系统只交易德国债券合约(多空都交易),帐户回报率达到400%(获利因子profit factor=3.6),总共有30次交易(13个是多,其他是空),其中22个盈利,8个亏损,50%的时间在市。
{ Plot ADX Values }
var Bar, ADXPeriod, ADXPane, Parameter, StopLossSeries: integer;
var BarHighProfit, BarLowProfit, CumProfit, p, Shares: integer;
var StartCapital, ATRValue, ProfitPercent, Profit, Price: float;
var BullTrend, BearTrend, DipLong, DipShort: boolean;
var ATRFactor, ChandelierExit, YoYoExit, SellPrice: float;
var ExitLong, ExitShort: boolean;
var ProfitControlPane, CumProfitPane: integer;
ADXPane := CreatePane( 75, TRUE, FALSE );
PlotSeries( ADXSeries( 18 ), ADXPane, 009, 2 );
PlotSeries( DIPlusSeries( 18 ), ADXPane, 050, 0 );
PlotSeries( DIMinusSeries( 18 ), ADXPane, 900, 0 );
DrawLabel( 'ADX, DI+, DI-', ADXPane );
DrawHorzLine( 0, ADXPane, 444, 1 );
DrawHorzLine( 30, ADXPane, 444, 1 );
{ Plot SMAs and EMAs }
PlotSeries( EMASeries( #Close, 28 ), 0, 044, 2 );
PlotSeries( SMASeries( #High, 5 ), 0, 922, 0 );
PlotSeries( SMASeries( #Low, 5 ), 0, 262, 0 );
for Bar := 30 to BarCount() - 1 do
begin
{ See if we're in a trend mode }
BullTrend := false;
BearTrend := false;
if ADX( Bar, 18 ) > 30 then
begin
if DIPlus( Bar, 18 ) > DIMinus( Bar, 18 ) then
begin
BullTrend := true;
SetBackgroundColor( Bar, 898 );
end
else if DIMinus( Bar, 18 ) > DIPlus( Bar, 18 ) then
begin
SetBackgroundColor( Bar, 988 );
BearTrend := true;
end;
end;
if LastPositionActive() then
begin
{ Test for closing Long Positions }
if PositionLong( LastPosition() ) then
begin
if ( PriceLow( Bar ) < SMA( Bar, #Low, 5 ) ) or ( PriceClose( Bar ) < EMA( Bar, #Close, 28 ) ) then
SellAtMarket( Bar + 1, LastPosition(), '' );
end
else
{ Test for closing Short Positions }
begin
if ( PriceHigh( Bar ) > SMA( Bar, #High, 5 ) ) or ( PriceClose( Bar ) > EMA( Bar, #Close, 28 ) ) then
CoverAtMarket( Bar + 1, LastPosition(), '' );
end;
end
else
begin
{ Confirm any trends with an EMA check }
if BullTrend then
BullTrend := EMA( Bar, #Close, 28 ) > EMA( Bar - 1, #Close, 28 );
if BearTrend then
BearTrend := EMA( Bar, #Close, 28 ) < EMA( Bar - 1, #Close, 28 );
{ Trigger long/short trades with the confirmed trends }
if BullTrend then
begin
SetBackgroundColor( Bar, 787 );
if PriceClose( Bar ) > SMA( Bar, #High, 5 ) then
BuyAtMarket( Bar + 1, '' );
end;
if BearTrend then
begin
SetBackgroundColor( Bar, 877 );
if PriceClose( Bar ) < SMA( Bar, #Low, 5 ) then
ShortAtMarket( Bar + 1, '' );
end;
end;
end; |
|