- 精华
- 0
- 在线时间
- 20 小时
- UID
- 233115
- 积分
- 11
- 帖子
- 7
- 阅读权限
- 10
- 注册时间
- 2016-4-26
- 最后登录
- 2021-2-8
- 精华
- 0
- UID
- 233115
- 积分
- 11
- 帖子
- 7
- 主题
- 2
- 阅读权限
- 10
- 注册时间
- 2016-4-26
- 最后登录
- 2021-2-8
|
将上述公式中的条件
MACDDValueD>0和MACDDValueD<0删除掉,就只有在死叉或金叉时开仓一次了。
请高手看看如何把这个条件加上,同时保持不重复开仓。
多谢
Params
Numeric FastLength(12);
Numeric SlowLength(26);
Numeric MACDLength(9);
Numeric LEFast(21);
Numeric LESlow(34);
Vars
Series<Numeric> MACDValue;
Series<Numeric> AvgMACD;
Series<Numeric> MACDDiff;
Series<Numeric> EMALEFast;
Series<Numeric> EMALESlow;
Bool ConCrossOver;
Bool ConCrossUnder;
Events
OnBar(ArrayRef<Integer> indexs)
{
EMALEFast = XAverage(Close, LEFast);
EMALESlow = XAverage(Close, LESlow);
PlotNumeric("EMALEFast",EMALEFast);
PlotNumeric("EMALESlow",EMALESlow);
ConCrossOver = CrossOver(EMALEFast,EMALESlow);
ConCrossUnder = CrossUnder(EMALEFast,EMALESlow);
MACDValue = XAverage( Close, FastLength ) - XAverage( Close, SlowLength ) ;
AvgMACD = XAverage(MACDValue, MACDLength);
If(ConCrossOver)
{
BuyToCover(8,CLOSE);
Buy(8,CLOSE);
}
If(ConCrossUnder)
{
SELL(8,CLOSE);
SELLSHORT(8,CLOSE);
}
} |
|