码迷,mamicode.com
首页 > 系统相关 > 详细

BIG_MACD

时间:2015-06-11 16:58:09      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:

一.介绍

  1. 原理:
    MACD是基于BIAS乘离率的变形应用。它是利用两条不同速度的指数平滑移动平均线来计算的(其中一条变动速度快–短期的移动平均线,另一条较慢—长期的移动平均线),两者之间的差异状况(DIF)作为研判行情的基础,然后再求DIF的9日平滑移动平均线,即为DEA线。而MACD实际就是运用快速与慢速移动平均线聚合与分离的征兆,来研判买进与卖出的时机。
  2. 相关字母与标号:

    • EMA:指数平滑移动平均线
    • N:周期
    • DIF:乘离率
    • DEA:离差平均值
  3. 计算方法:

    • DIF:EMA(C,short) - EMA(C, long);
    • DEA: EMA(DIF, M)
    • MACD: 2*(DIF-DEA)
  4. 基本应用原则:

    • DIF与DEA均为正值时,为多头行情
    • DIF与DEA均为负值时,为空头行情
    • DIF向上突破DEA时,可买入
    • DIF向下突破DEA时,可卖出

四.代码:

DIFF:EMA(DCLOSE,12)-EMA(DCLOSE,26);
DEA:EMA(DIFF,9),COLORFFFF00;
MACD:(DIFF-DEA)*2;
STICKLINE(MACD>=0 AND MACD>=REF(MACD,1),0,MACD,1,0),colorred;
STICKLINE(MACD>=0 AND MACD<=REF(MACD,1),0,MACD,1,0),colorgreen;
STICKLINE(MACD<=0 AND MACD>=REF(MACD,1),0,MACD,1,0),COLORFF00FF;
STICKLINE(MACD<=0 AND MACD<=REF(MACD,1),0,MACD,1,0),COLOR00FFFF;
多转空:=((((LLV(MACD,4)>0) AND (MACD<REF(MACD,1))) AND (REF(MACD,1)>REF(MACD,2))) AND (REF(MACD,2)>REF(MACD,3)));
空转多:=((((HHV(MACD,4)<0) AND (MACD>REF(MACD,1))) AND (REF(MACD,1)<REF(MACD,2))) AND (REF(MACD,2)<REF(MACD,3)));
DRAWICON(多转空,MACD,2);
DRAWICON(空转多,MACD,1);
低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;
DRAWICON(低位金叉,DEA,1);
DRAWTEXT(低位金叉,DEA,‘低位金叉‘),COLORFF00FF;
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
DRAWICON(二次金叉,DEA*1.06,1);
STICKLINE(二次金叉,0,0.2,2,0),COLORFF00FF;
DRAWTEXT(二次金叉,DEA*1.06,‘二次金叉‘),colorred;
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:=REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA);
DRAWTEXT(底背离,-0.2-MACD,‘底背离‘),colorwhite;
DRAWICON(底背离,-0.2-MACD,1);
A2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(DIFF,A2+1)>DIFF AND CROSS(DEA,DIFF);
DRAWICON(顶背离,0.2+MACD,2);
DRAWTEXT(顶背离,0.2+MACD,‘顶背离‘),colorwhite;

BIG_MACD

标签:

原文地址:http://blog.csdn.net/neu_chenguangq/article/details/46458381

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!