//+------------------------------------------------------------------+ //| MA Crossover Shift Signal by Dr House.mq4 | //| Copyright © 2009, Dr.House7 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, Dr.House7" #property link "http://www.sungold.it" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red extern int FasterMA = 5; extern int SlowerMA = 5; extern double ArrowShift= 1.0; extern int ma_method =1; extern int ma_price =0; extern bool SoundON=false; double alertTag; double control=2147483647; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW, EMPTY,1); SetIndexArrow(0, 159); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1, DRAW_ARROW, EMPTY,1); SetIndexArrow(1, 159); SetIndexBuffer(1,ExtMapBuffer2); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, counter; double fasterMAnow, slowerMAnow; double Range, AvgRange; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i = 0; i <= limit; i++) { counter=i; Range=0; AvgRange=0; for (counter=i ;counter<=i+9;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10; fasterMAnow = iMA(NULL, 0, FasterMA, 0, ma_method, ma_price, i); slowerMAnow = iMA(NULL, 0, SlowerMA, 0, ma_method, ma_price, i+1); if ((fasterMAnow > slowerMAnow)) { ExtMapBuffer1[i]=Low[i]-ArrowShift*Range*0.5; } else if ((fasterMAnow < slowerMAnow)) { ExtMapBuffer2[i]=High[i]+ArrowShift*Range*0.5; } if (SoundON==true && i==1 && ExtMapBuffer1[i] > ExtMapBuffer2[i] && alertTag!=Time[0]){ Alert("MA Shift Cross Trend going Down on ",Symbol()," ",Period()); alertTag = Time[0]; } if (SoundON==true && i==1 && ExtMapBuffer1[i] < ExtMapBuffer2[i] && alertTag!=Time[0]){ Alert("MA Shift Cross Trend going Up on ",Symbol()," ",Period()); alertTag = Time[0]; } } return(0); }
Sample
Analysis
Market Information Used:
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains open time of each bar
Indicator Curves created:
Implements a curve of type DRAW_ARROW
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features:
It issuies visual alerts to the screen