外汇MT4编程:
MACD背离指标
(转)网上的资料:
MACD背离指标
//+------------------------------------------------------------------+ //| FX5_Divergence.mq4 | //| FX5 | //| | //+------------------------------------------------------------------+ #property copyright "Copyright ?2007, FX5" //---- #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 LimeGreen #property indicator_color2 FireBrick #property indicator_color3 Green #property indicator_color4 Red //---- input parameters extern string separator1 = "*** OSMA Settings ***"; extern int fastEMA = 12; extern int slowEMA = 26; extern int signal = 9; extern string separator2 = "*** Indicator Settings"; extern double positiveSensitivity = 0.0001; extern double negativeSensitivity = -0.0001; extern double historyBarsCount = 0; extern bool drawDivergenceLines = true; //---- buffers double upOsMA[]; double downOsMA[]; double bullishDivergence[]; double bearishDivergence[]; double OsMA[]; double MACD[]; double Signal[]; static int chartBarsCount; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(7); //---- SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2); SetIndexBuffer(0, upOsMA); SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2); SetIndexBuffer(1, downOsMA); SetIndexStyle(2, DRAW_ARROW); SetIndexBuffer(2, bullishDivergence); SetIndexArrow(2, 233); SetIndexStyle(3, DRAW_ARROW); SetIndexBuffer(3, bearishDivergence); SetIndexArrow(3, 234); SetIndexStyle(4, DRAW_NONE); SetIndexBuffer(4, OsMA); // additional buffers SetIndexBuffer(5, MACD); SetIndexBuffer(6, Signal); //---- SetIndexDrawBegin(0, signal); SetIndexDrawBegin(1, signal); //---- IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 2); |