MA Crossover Shift Dots by Dr House

Download script
Author: Copyright � 2009, Dr.House7
MA Crossover Shift Dots by Dr House

This script is a specialized trading tool designed to identify momentum shifts in the financial markets by analyzing the relationship between two Moving Averages (MA). Instead of simply looking at price action, it interprets "crossovers"—the moments when a faster-moving average crosses over a slower-moving one—to signal potential changes in market direction.

Core Logic and Mechanics

1. The Moving Average Comparison The script continuously monitors two different Moving Averages (defined by the user as "Faster" and "Slower"). By comparing these two averages, the tool detects the underlying trend of the asset. When the faster average moves above the slower one, it suggests upward momentum; conversely, when it moves below, it indicates downward pressure.

2. Dynamic Visual Positioning One of the unique features of this logic is how it handles visual signals on your chart. Rather than placing markers at a static price point, the script calculates the "Range" of the market—specifically looking at the average volatility (the distance between the high and low prices) over a 10-bar period. It then uses this range to automatically offset the visual arrows:

  • Buy Signals: Placed slightly below the recent low price.
  • Sell Signals: Placed slightly above the recent high price. This ensures that the signals remain clearly visible and do not clutter the actual price candles, regardless of how volatile the market is at any given moment.

3. Trend Detection and Alerts The script scans historical data to populate the chart with these visual markers, allowing traders to see where trend shifts occurred in the past. Additionally, it features a real-time monitoring system. If the user enables the audio alerts, the script will monitor the very latest price action. When it detects a significant crossover between the two averages on the most recent completed candle, it triggers an audible notification.

4. Smart Alert Filtering To prevent "alert fatigue," the logic includes a check to ensure that notifications are only sent once per candle. If the trend remains in a crossover state as new price data comes in, the script remembers that it has already notified you for that specific time period, ensuring you aren't bombarded with repeated sounds for the same move.

Summary for the Trader

Essentially, this tool filters out market "noise" by focusing on smoothed averages. It identifies when the immediate momentum (Faster MA) is pulling away from the longer-term trend (Slower MA) and provides a visual and audible cue to help you spot these transitions while automatically adjusting its visual layout to suit the current market volatility.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
12 Views
0 Downloads
0 Favorites
MA Crossover Shift Dots by Dr House
//+------------------------------------------------------------------+
//|   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);
}

Comments