分享

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

 家心何如 2017-10-05

 //------------------------------------------------------------------------
// 简称: 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_TotalProfit,Red); 
}

PlotNumeric("PL",Portfolio_TotalProfit);


End
//------------------------------------------------------------------------
// 编译版本 GS2010.12.08
// 用户版本 2013/03/14 13:43
// 版权所有 ymingcn
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TrabeBlazer公式修改和重写的权利
//-----------------------------------------------------------------

 

原文见:自适应均线交易系统tb源码
http:///thread-163-1-1.html

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多