[转][程序化交易]自适应均线交易系统tb源码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

[转][程序化交易]自适应均线交易系统tb源码
//------------------------------------------------------------------------
// 简称: MRJS_YM_SingleAMA_00
// 名称: MRJS_YM_SingleAMA_00
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------
Params
//AMA相关
Numeric FastAvgLength(2);
Numeric SlowAvgLength(30);
Numeric EffRatioLength(10);
//系统相关
Numeric ConfirmPeriod(3); //确认均线趋势次数
Numeric StdMultiplier(1); //过滤器百分比
//交易相关
Numeric Slipes(2); //滑点
Vars
//AMA相关
Numeric NetChg(0);
Numeric TotChg(0);
Numeric EffRatio(0);
Numeric SmoothRatio(1);
NumericSeries AMAValue;
Numeric STDLen(0); //标准差长度
Numeric PriceSTD(0);
Numeric STDRatio(1); //进入标准差的倍数
Bool LongIndicator(True);
Bool ShortIndicator(True);
Numeric i;
Begin
if(CurrentBar == 0)
{
AMAValue = Close;
}Else
{
NetChg = Abs( Close - Close[EffRatioLength] );
TotChg = Summation( Abs( Close - Close[1] ), EffRatioLength );
EffRatio = IIF(TotChg > 0, NetChg / TotChg, 0);
SmoothRatio = Power( ( EffRatio * ( 2 / ( FastAvgLength + 1 ) - 2 / ( SlowAvgLength + 1 ) ) + 2 / ( SlowAvgLength + 1 ) ), 2 );
AMAValue = AMAValue[1] + SmoothRatio * ( Close - AMAValue[1] );
}
STDLen=SlowAvgLength;
PriceSTD=StandardDev(Close[1],STDLen);
//当不持多仓的情况下,如果做多条件满足,则做多
If(MarketPosition <>1 && AMAValue[1]-Lowest(AMAValue[1],ConfirmPeriod) > PriceSTD*STDRatio*StdMultiplier/100 )
{
Buy(0,Open+Slipes);
PlotString ("top","jdc",Portfolio_TotalProfit,Red);
}
//当不持空仓的情况下,如果做空条件满足,则做空
If(MarketPosition <>-1 && Highest(AMAValue[1],ConfirmPeriod)-AMAValue[1] > PriceSTD*STDRatio*StdMultiplier/100 )
{
SellShort(0,Open-Slipes);
PlotString ("top","jkc",Portfolio_T otalProfit,Red);
}
PlotNumeric("PL",Portfolio_T otalProfit);
End
//------------------------------------------------------------------------
// 编译版本 GS2010.12.08
// 用户版本 2013/03/14 13:43
// 版权所有 ymingcn
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TrabeBlazer公式修改和重写的权利
//-----------------------------------------------------------------
原文见:自适应均线交易系统tb源码。

相关文档
最新文档