F2a_AO
Download scriptThis tool is designed to help traders identify specific momentum shifts and trend reversals by analyzing price movement through a series of smoothed averages. Instead of just looking at raw price action, it uses a secondary calculation to filter out "noise," aiming to provide clearer signals for potential buying and selling opportunities.
How the Logic Works
The script functions by processing data in three distinct layers:
1. The Core Calculation (The Awesome Oscillator) The tool first looks at two different types of moving averages—a "Fast" average and a "Slow" average. By subtracting the Slow average from the Fast average, it calculates a momentum value. This represents the gap between short-term price trends and long-term trends. If this gap is widening, momentum is increasing; if it is narrowing, momentum is slowing down.
2. The Trend Filter To ensure the signals are reliable, the script uses a third "Filter" moving average. It compares the current trend values against previous data points to confirm that the price movement is significant enough to warrant an alert. This prevents the tool from reacting to minor, insignificant price fluctuations.
3. Signal Generation (The Buy and Sell Rules) The script looks for specific mathematical "turning points" to place markers on your chart:
- Buy Signals: The tool identifies a situation where the momentum is currently rising compared to the previous bar, but it also detects that the trend was previously moving in the opposite direction. When these conditions meet, it places a green upward arrow below the candle.
- Sell Signals: Conversely, if the momentum is falling while the trend was previously moving upward, the tool identifies a potential peak. In these cases, it places a red downward arrow above the candle.
User Notifications
Beyond just placing visual arrows on the chart, the script features two integrated notification systems:
- Visual Comments: It can automatically write a text summary directly onto your trading screen, showing you the current action (Buy/Sell) along with the exact price and timeframe.
- Live Alerts: If enabled, the tool will trigger an active sound alert and pop-up message on your platform the moment a new signal is detected, ensuring you don't miss a potential entry point while away from the screen.
//+------------------------------------------------------------------+
//| F2a_AO.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property link "Alert by GOEN"
//+------------+-----------------------------------------------------+
// Bookkeeper: Ïîäïðàâèë íåìíîãî ïî ñâîåìó
// Íåîáõîäèìî íàëè÷èå NavelEMA.mq4
// Presence NavelEMA.mq4 is necessary
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
extern int MA_Filtr=3;
extern int MA_Fast=13;
extern int MA_Slow=144;
extern bool WithAlert=false;
extern bool WithComment=true;
double up_buffer[];
double dn_buffer[];
double ind_buffer[];
datetime lastalert=0, lastcomment=0;
//+------------------------------------------------------------------+
int deinit()
{
Comment("");
}
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
SetIndexStyle(0,DRAW_ARROW);//
SetIndexStyle(1,DRAW_ARROW);//
SetIndexArrow(0,233);
SetIndexArrow(1,234);
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexDrawBegin(0,MA_Slow+2);
SetIndexDrawBegin(1,MA_Slow+2);
if(!SetIndexBuffer(0,up_buffer) &&
!SetIndexBuffer(1,dn_buffer) &&
!SetIndexBuffer(2,ind_buffer))
Print("cannot set indicator buffers!");
return(0);
}
//+------------------------------------------------------------------+
//| Awesome Oscillator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double prev, current;
static datetime lastalert;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=0; i<limit; i++)
ind_buffer[i]=iCustom(NULL,0,"NavelEMA",MA_Fast,0,0,i)-
iCustom(NULL,0,"NavelEMA",MA_Slow,0,0,i);
for(i=limit-1; i>=0; i--)
{
current=iCustom(NULL,0,"NavelEMA",MA_Filtr,0,0,i);
prev=iCustom(NULL,0,"NavelEMA",MA_Filtr,0,0,i+1);
if(ind_buffer[i]>ind_buffer[i+1] && current>=prev &&
ind_buffer[i+1]<=ind_buffer[i+2])
up_buffer[i]=Low[i]-Point*10;
else up_buffer[i]=0.0;
if(ind_buffer[i]<ind_buffer[i+1] && current<=prev &&
ind_buffer[i+1]>=ind_buffer[i+2])
dn_buffer[i]=High[i]+Point*10;
else dn_buffer[i]=0.0;
}
if(WithAlert==true && lastalert!=Time[0])
{
if (up_buffer[0]>Point)
{
Alert("Buy " +Symbol()+"_"+Period()+" "+
" "+DoubleToStr(MarketInfo(Symbol(),MODE_ASK),Digits)+
" "+TimeToStr(TimeCurrent(),TIME_MINUTES));
lastalert=Time[0];
}
if (dn_buffer[0]>Point)
{
Alert("Sell " +Symbol()+"_"+Period()+
" "+DoubleToStr(MarketInfo(Symbol(),MODE_BID),Digits)+
" "+TimeToStr(TimeCurrent(),TIME_MINUTES));
lastalert=Time[0];
}
}
if(WithComment==true && lastcomment!=Time[0])
{
if (up_buffer[0]>Point)
{
lastcomment=Time[0];
Comment("Buy ",Symbol(),"_",Period()," ",
" "+DoubleToStr(Close[0],Digits));
}
if (dn_buffer[0]>Point)
{
lastcomment=Time[0];
Comment("Sell ",Symbol(),"_",Period(),
" "+DoubleToStr(Close[0],Digits));
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments