|
2楼
楼主 |
发表于 2016-7-1 13:56:51
|
只看该作者
双均线交叉模型
Params
Numeric FastLength(5); //短周期
Numeric SlowLength(20); //长周期
Numeric TradeUint(5); //每次交易手数
Vars
NumericSeries AvgValue1;
NumericSeries AvgValue2;
BoolSeries bCrossOver(false);
BoolSeries bCrossDn(False);
Begin
AvgValue1 = AverageFC(CLOSE,FastLength);
AvgValue2 = AverageFC(CLOSE,SlowLength);
PlotNumeric("MA1",AvgValue1);
PlotNumeric("MA2",AvgValue2);
bCrossOver = CrossOver(AvgValue1,AvgValue2);
bCrossDn = CrossUnder(AvgValue1,AvgValue2);
//均线交叉时开仓
if(bCrossOver[1])
{
if(MarketPosition != 1)
Buy(TradeUint,Open);
}
Else if(bCrossDn[1])
{
if(MarketPosition != -1)
SellShort(TradeUint,Open);
}
End
|
|