//------------------------------------------------------------------------

// 简称: 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) > PriceSTDSTDRatioStdMultiplier/100 )

{

Buy(0,Open+Slipes);

PlotString ("top","jdc",Portfolio_TotalProfit,Red);

}

//当不持空仓的情况下,如果做空条件满足,则做空

If(MarketPosition -1 && Highest(AMAValue[1],ConfirmPeriod)-AMAValue[1] > PriceSTDSTDRatioStdMultiplier/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公式修改和重写的权利

//------------------------------------------------------------------------
交易技术, 交易策略, 源码

点赞(0)

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部