- 精华
- 0
- 在线时间
- 31 小时
- UID
- 113075
- 积分
- 37
- 帖子
- 11
- 阅读权限
- 10
- 注册时间
- 2012-10-24
- 最后登录
- 2012-11-7
- 精华
- 0
- UID
- 113075
- 积分
- 37
- 帖子
- 11
- 主题
- 4
- 阅读权限
- 10
- 注册时间
- 2012-10-24
- 最后登录
- 2012-11-7
|
我的想法是:AMA(20)上捌 且价格向上突破AMA(20)线买入开仓,价格向下碰到AMA(20)卖出平仓;同样AMA(20)下捌 且价格向下突破AMA(20)线卖出开仓,价格向上碰到AMA(20)买入平仓;
我是一个刚学的菜鸟,以下程序请帮忙修正,万分感谢!
Params
NumericSeries Price(1);
Numeric EffRatioLength(20);
Numeric FastAvgLength(2);
Numeric SlowAvgLength(30);
Vars
Numeric NetChg(0);
Numeric TotChg(0);
Numeric EffRatio(0);
Numeric ScaledSFSqr(0);
NumericSeries AMAValue;
Numeric SFDiff;
Begin
if(CurrentBar == 0)
{
AMAValue = Price;
}Else
{
NetChg = Abs( Price - Price[EffRatioLength] );
TotChg = Summation( Abs( Price - Price[1] ), EffRatioLength );
EffRatio = IIF(TotChg > 0, NetChg / TotChg, 0);
SFDiff = 2 / ( FastAvgLength + 1 ) - 2 / ( SlowAvgLength + 1 );
ScaledSFSqr = Sqr( 2 / ( SlowAvgLength + 1 ) + EffRatio * SFDiff );
AMAValue = AMAValue[1] + ScaledSFSqr * ( Price - AMAValue[1] );
}
Return AMAValue;
If(Price >AMAValue && AMAValue[1] > AMAValue[2])
{
Buy(1,Open);
}
If(Price <AMAValue)
{
SellShort(1,Open);
}
If(Price <AMAValue && AMAValue[1] < AMAValue[2])
{
Sell(1,Open);
}
If(Price >AMAValue)
{
BuyToCover(1,Open);
}
PlotNumeric("AMA",AMAValue);
PlotNumeric("PL",Portfolio_TotalProfit);
PlotNumeric("AdpMa",AdaptiveMovAvg(Close,EffRatioLength,FastAvgLength,SlowAvgLength));
End
|
|