|
盘立方里面MACD拐点指标,我这里有源码,直接公开给大家,我还加了一些卖空的提示,希望对大家有用
//------------------------------------------------------------------------
// 简称:MACD_bl
// 名称:MACD_bl
// 类别: 交易指令
// 类型: 用户应用
//------------------------------------------------------------------------
Params
//参数定义
GlobalVars
//全局变量定义
Numeric stopPrice(0);
Vars
//局部变量定义
NumericSeries ret;
BoolSeries bCrossOver(False);
BoolSeries bCrossUnder(False);
Begin
//策略执行区
SetFmlUserGroupID("macd_dadf-dadfe-aee343");
Numeric DIFF = EMA(Close,12) - EMA(Close,26);
Numeric DEA = EMA(DIFF,9);
ret = 2*(DIFF-DEA);
bCrossOver = CrossOver(DIFF, DEA);
bCrossUnder = CrossUnder(DIFF, DEA);
Numeric crossOver1 = NthCon(bCrossOver, 1);
Numeric crossOver2 = NthCon(bCrossOver, 2);
Numeric crossOver3 = NthCon(bCrossOver, 3);
Numeric crossOver4 = NthCon(bCrossOver, 4);
Numeric crossUnder1 = NthCon(bCrossUnder, 1);
Numeric crossUnder2 = NthCon(bCrossUnder, 2);
Numeric crossUnder3 = NthCon(bCrossUnder, 3);
Numeric crossUnder4 = NthCon(bCrossUnder, 4);
Numeric retsum1 = 0;
For(int i=crossOver1;i<crossUnder1;i++){
retsum1 = retsum1 + Abs(ret);
}
Numeric retsum2 = 0;
For(int i = crossOver2;i<crossUnder2;i++){
retsum2 = retsum2 + Abs(ret);
}
If(bCrossOver && retsum1<retsum2){
SelectStock;
Alert(SymbolName+"MACD多单开仓");
}
Numeric retsum3 = 0;
For(int i=crossUnder1;i<crossOver1;i++){
retsum3 = retsum3 + Abs(ret);
}
Numeric retsum4 = 0;
For(int i = CrossUnder2;i<crossOver2;i++){
retsum4 = retsum4 + Abs(ret);
}
If(bCrossUnder && retsum3<retsum4){
ColorBar(Yellow,1);
PlotText(c,"卖出",0);
PlotIcon(h,4,0);
Alert(SymbolName+"MACD空单开仓");
}
End
|
|