//+------------------------------------------------------------------+ //| Custom MACD.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red //---- indicator parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalEMA=9; //---- indicator buffers double TriggerUP[]; double TriggerDN[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_ARROW,EMPTY,3,Blue); SetIndexArrow(0,SYMBOL_ARROWUP); SetIndexStyle(1,DRAW_ARROW,EMPTY,3,Red); SetIndexArrow(1,SYMBOL_ARROWDOWN); SetIndexBuffer(0,TriggerUP); SetIndexBuffer(1,TriggerDN); return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int i,MACDTrigger,SARTrigger,counted_bars=IndicatorCounted(); double MACDHistCur,MACDHistPrev,Signal,MACD; double alpha = 2.0 / (SignalEMA + 1.0); double alpha_1 = 1.0 - alpha; //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; i=Bars-counted_bars; while(i>0) { MACD=iMACD(NULL,0,FastEMA,SlowEMA,SignalEMA,PRICE_CLOSE,MODE_MAIN,i); Signal=iMACD(NULL,0,FastEMA,SlowEMA,SignalEMA,PRICE_CLOSE,MODE_SIGNAL,i); MACDHistPrev=MACDHistCur; MACDHistCur=MACD-Signal; if((MACDHistCur*MACDHistPrev)<0.0) MACDTrigger=((MACDHistCur<0.0)+1); SARTrigger=((iSAR(NULL,0,0.02,0.2,i)>Close[i])+1); if(MACDTrigger==SARTrigger) { if(MACDTrigger==1) TriggerUP[i]=(High[i]-Low[i])/2+Low[i]+Point*10; if(MACDTrigger==2) TriggerDN[i]=(Low[i]-Low[i])/2+Low[i]-Point*10; MACDTrigger=0; SARTrigger=0; } i--; } return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_ARROW
Indicators Used:
MACD Histogram
Parabolic Stop and Reverse system
Custom Indicators Used:
Order Management characteristics:
Other Features: