MA_Crossover_Signal_With_wav_v1

Download script
Author: Copyright � 2005, Jason Robinson (jnrtrading)
MA_Crossover_Signal_With_wav_v1

This tool is designed to help traders identify specific momentum shifts in the market by tracking the interaction between two different Moving Averages (MA). Instead of requiring you to constantly watch for subtle changes in line behavior, this script automates the detection of "crossovers"—the moments when a faster-moving average passes through a slower-moving one.

Core Functionality

The script monitors two distinct averages simultaneously: a Faster MA and a Slower MA. By comparing these two lines, the tool seeks to pinpoint the exact moment the market sentiment shifts from one direction to another.

  • The Faster MA reacts quickly to recent price changes.
  • The Slower MA represents the broader, long-term trend.

When the faster line crosses above the slower line, it typically suggests upward momentum (a "Buy" signal). Conversely, when the faster line drops below the slower line, it suggests downward momentum (a "Sell" signal).

Key Features

  • Visual Signals: Rather than just relying on the lines themselves—which can sometimes be difficult to see clearly on a zoomed-out chart or amidst busy price bars—the script places clear visual markers (arrows) directly at the crossover points. This makes it easy to identify historical entries and exits at a glance.
  • Dynamic Positioning: To ensure the markers are always visible and don't overlap with the actual price candles, the script calculates the "average range" of recent price movement. It then places the buy signals slightly below the candle and the sell signals slightly above the candle.
  • Real-Time Alerts: The tool doesn't just provide visual cues; it actively monitors the market for you. When a crossover occurs in real-time, the script will trigger an audible sound alert and a pop-up notification on your screen. To prevent constant noise, it is programmed to only alert you once per candle at the moment of the crossover.
  • Customizable Settings: Users can choose different types of Moving Averages (such as Simple, Exponential, Smooth, or Linear Weighted) and adjust the periods for both the fast and slow settings to suit different trading styles—whether you are looking for quick scalps or long-term trends.

Summary for Traders

Essentially, this script acts as an automated "scout." It scans the relationship between two price averages and alerts you the moment they intersect, highlighting potential trend reversals with visual markers and instant notifications so you don't have to squint at the chart to catch the move.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It plays sound alertsIt issuies visual alerts to the screen
11 Views
0 Downloads
0 Favorites
MA_Crossover_Signal_With_wav_v1
//+------------------------------------------------------------------+
//|                                         EMA-Crossover_Signal.mq4 |
//|         Copyright © 2005, Jason Robinson (jnrtrading)            |
//|                   http://www.jnrtading.co.uk                     |
//+------------------------------------------------------------------+

/*
  +------------------------------------------------------------------+
  | Allows you to enter two ema periods and it will then show you at |
  | Which point they crossed over. It is more usful on the shorter   |
  | periods that get obscured by the bars / candlesticks and when    |
  | the zoom level is out. Also allows you then to remove the emas   |
  | from the chart. (emas are initially set at 5 and 6)              |
  +------------------------------------------------------------------+
*/   
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)"
#property link      "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red

double CrossUp[];
double CrossDown[];
extern int FasterMode = 1; //0=sma, 1=ema, 2=smma, 3=lwma
extern int FasterMA =   13;
extern int SlowerMode = 1; //0=sma, 1=ema, 2=smma, 3=lwma
extern int SlowerMA =   25;
 double alertTag;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, 
fasterMAafter, slowerMAafter;
   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, FasterMode, PRICE_CLOSE, 
i);
      fasterMAprevious = iMA(NULL, 0, FasterMA, 0, FasterMode, 
PRICE_CLOSE, i+1);
      fasterMAafter = iMA(NULL, 0, FasterMA, 0, FasterMode, 
PRICE_CLOSE, i-1);

      slowerMAnow = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, 
i);
      slowerMAprevious = iMA(NULL, 0, SlowerMA, 0, SlowerMode, 
PRICE_CLOSE, i+1);
      slowerMAafter = iMA(NULL, 0, SlowerMA, 0, SlowerMode, 
PRICE_CLOSE, i-1);
      
      if ( (fasterMAnow > slowerMAnow) && (fasterMAprevious < 
slowerMAprevious) && (fasterMAafter > slowerMAafter)) {
         CrossUp[i] = Low[i] - Range*0.5;
         if ( alertTag!=Time[0])
         {
          PlaySound("news.wav");// buy wav
          Alert(Symbol(),"  M",Period()," MA cross BUY");
         }
          alertTag = Time[0];
      }
      else if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > 
slowerMAprevious) && (fasterMAafter < slowerMAafter)) {
         CrossDown[i] = High[i] + Range*0.5;
         if ( alertTag!=Time[0])
         {
          PlaySound("news.wav"); //sell wav
           Alert(Symbol(),"  M",Period()," MA cross SELL");
         }
          alertTag = Time[0];
      }
   }
   return(0);
}


       

Comments