Awesome_Signal_Alert
Download scriptThe Awesome Signal script is a technical analysis tool designed to help traders identify market momentum and potential reversal points by analyzing price movements over different timeframes. It processes raw market data to create a visual representation of momentum, making it easier to see the "strength" behind current price trends.
Core Logic and Mechanics
Momentum Calculation At its foundation, the script compares two different moving averages: a fast-moving average (representing short-term price behavior) and a slow-moving average (representing longer-term price behavior). By calculating the difference between these two averages, the tool generates an "Oscillator" value.
- When the fast average is higher than the slow average, it indicates upward momentum.
- When the fast average falls below the slow average, it indicates downward momentum.
Visual Trends and Histograms The script translates these differences into a visual histogram. It tracks whether the current momentum value is increasing or decreasing compared to the previous period:
- Upward Momentum: When the values are rising, the script highlights this movement to indicate strengthening positive pressure.
- Downward Momentum: When the values begin to drop, it highlights the shift toward negative pressure.
Signal Smoothing and Crossover Detection To filter out market "noise" and provide clearer entry/exit points, the script calculates a smoothed "Signal Line." This is an average of the oscillator itself. The tool monitors for "Crossovers," which occur when the primary oscillator line crosses over this smoother signal line. These intersections are often interpreted as early warnings of a change in trend direction.
Alert System
The script features an automated notification system to keep traders informed without needing to watch the charts constantly. It is programmed to trigger alerts based on two specific conditions:
- Signal Line Crossovers: The tool monitors when the oscillator crosses its own signal line. If it crosses downward, it triggers a "Sell" alert; if it crosses upward, it triggers a "Buy" alert.
- Zero Line Crossovers: The script watches for when the oscillator moves from positive to negative territory (crossing below the zero line) or vice versa. Crossing above zero is viewed as a move into bullish momentum, while crossing below zero suggests bearish momentum.
By combining these three layers—raw momentum, trend visualization, and automated alert triggers—the script provides a comprehensive overview of market direction and potential turning points in real-time.
//+------------------------------------------------------------------+
//| Awesome_Signal.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.fxservice.eu/ |
//| contact@fxservice.eu |
//+------------------------------------------------------------------+
#property copyright "Kalenzo contact@fxservice.eu"
#property link "http://www.fxservice.eu/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Black
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_color4 Gold
extern int Fast = 5;
extern int Slow = 34;
extern int Signal=5;
extern int SignalShift=0;
extern bool EnableSignalLineAlert = true;
extern bool EnableZeroLineCrossoverAlert = true;
//---- indicator buffers
double ExtBuffer0[];
double ExtBuffer1[];
double ExtBuffer2[];
double SignalBuffer[];
int a=0,b=0,c=0,d=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID);
SetIndexShift( 3, SignalShift);
IndicatorDigits(Digits+1);
SetIndexDrawBegin(0,34);
SetIndexDrawBegin(1,34);
SetIndexDrawBegin(2,34);
SetIndexDrawBegin(3,34);
//---- 3 indicator buffers mapping
SetIndexBuffer(0,ExtBuffer0);
SetIndexBuffer(1,ExtBuffer1);
SetIndexBuffer(2,ExtBuffer2);
SetIndexBuffer(3,SignalBuffer);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("AO");
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Awesome Oscillator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double prev,current;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd
for(int i=0; i<limit; i++)
ExtBuffer0[i]=iMA(NULL,0,Fast,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,Slow,0,MODE_SMA,PRICE_MEDIAN,i);
//---- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0; i--)
{
current=ExtBuffer0[i];
prev=ExtBuffer0[i+1];
if(current>prev) up=true;
if(current<prev) up=false;
if(!up)
{
ExtBuffer2[i]=current;
ExtBuffer1[i]=0.0;
}
else
{
ExtBuffer1[i]=current;
ExtBuffer2[i]=0.0;
}
}
// ----- Draw signal
for(i=0; i<limit; i++)
SignalBuffer[i]=iMAOnArray(ExtBuffer0,Bars,Signal,0,MODE_SMA,i);
if(EnableSignalLineAlert)
{
if(ExtBuffer0[0]<SignalBuffer[0] && ExtBuffer0[1]>=SignalBuffer[1] && Bars>a)
{
Alert(Symbol()+" Period "+Period()+" AO CROSSED Signal (SELL)");
a = Bars;
}
if(ExtBuffer0[0]>SignalBuffer[0] && ExtBuffer0[1]<=SignalBuffer[1] && Bars>b)
{
Alert(Symbol()+" Period "+Period()+" AO CROSSED Signal (BUY)");
b = Bars;
}
}
if(EnableZeroLineCrossoverAlert)
{
if(ExtBuffer0[0]<0 && ExtBuffer0[1]>=0 && Bars>c)
{
Alert(Symbol()+" Period "+Period()+" AO CROSSED ZERO LINE (SELL)");
c = Bars;
}
if(ExtBuffer0[0]>0 && ExtBuffer0[1]<=0 && Bars>d)
{
Alert(Symbol()+" Period "+Period()+" AO CROSSED ZERO LINE (BUY)");
d = Bars;
}
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments