AwesomeMod_EA
Download scriptThis custom indicator is designed to provide traders with a specialized visual tool for analyzing market momentum and identifying price trends on the MetaTrader platform. It functions by calculating and smoothing complex price relationships into a single, easy-to-read histogram.
Core Logic Overview
The tool operates through a multi-layered calculation process that filters out "market noise" to reveal the underlying strength of a price movement. It accomplishes this in three distinct stages:
1. Baseline Price Analysis The script begins by monitoring two different types of moving averages. These are essentially "averages of averages" that track the price over two different timeframes (defined by short-term and long-term settings). By comparing these two averages, the tool determines how much the current price is deviating from its historical norm.
2. Percentage Variance Calculation Instead of simply looking at raw price points, the logic calculates the percentage difference between the short-term and long-term averages. This step is crucial because it normalizes the data; it allows the indicator to remain consistent regardless of whether the asset being traded has a high or low unit value. It effectively measures the "velocity" of the price change.
3. Momentum Smoothing To prevent the indicator from reacting too wildly to every minor price flicker, the script applies a final smoothing pass over the percentage data. This final calculation—referred to in the logic as a "Mean AO"—produces the actual histogram you see on your chart.
How It Functions for the User
- Trend Visualization: The resulting histogram provides a clear picture of whether the market is accelerating, decelerating, or moving sideways.
- Safety Checks: The script includes built-in "sanity checks." If there isn't enough historical data available on the chart to make an accurate calculation, or if the user inputs settings that are mathematically incompatible, the tool will display a helpful notification rather than providing incorrect information.
- Dynamic Adjustment: Because it uses "Smoothed Moving Averages" (SMMA), the indicator focuses on preserving the trend's integrity, making it particularly useful for identifying sustained momentum shifts rather than temporary price spikes.
//+------------------------------------------------------------------+
//| AwesomeMod_EA.mq4 |
//| Manel Sanchon |
//| |
//+------------------------------------------------------------------+
#property copyright "Manel Sanchon"
#property link ""
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
// External parameters
extern int short_mean = 5;
extern int long_mean = 34;
extern int meanAO = 7;
//---- indicator buffers
double AO[];
double ExtBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_NONE);
IndicatorDigits(Digits+1);
SetIndexDrawBegin(0,34);
SetIndexDrawBegin(1,34);
//---- 3 indicator buffers mapping
SetIndexBuffer(0,AO);
SetIndexBuffer(1,ExtBuffer);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("AwesomeMod_EA("+short_mean+","+long_mean+";"+meanAO+")");
SetIndexLabel(0,"AO");
return(0);
}
//+------------------------------------------------------------------+
//| Awesome Oscillator |
//+------------------------------------------------------------------+
int start()
{
double ShortMA, LongMA;
double MAExtBufferCurrent,MAExtBufferPrev;
int Count;
if(Bars<=long_mean)
{
Comment("Not enough bars to make computations");
return(0);
}
if(meanAO>long_mean)
{
Comment("Mean AO has to be smaller than Long mean");
return(0);
}
int counted_bars = IndicatorCounted();
int CalculateBars = Bars-counted_bars-(long_mean+1);
if(counted_bars>long_mean)
{
CalculateBars=Bars-counted_bars-1;
}
//--- handles for MAs
for(Count = CalculateBars; Count >=0 ; Count--)
{
ShortMA = iMA(NULL,0,short_mean,0,MODE_SMMA,PRICE_MEDIAN,Count);
LongMA = iMA(NULL,0,long_mean,0,MODE_SMMA,PRICE_MEDIAN,Count);
ExtBuffer[Count] = (ShortMA/LongMA-1)*100;
}
//---- dispatch values between 2 buffers
bool up=true;
for(Count = CalculateBars; Count >= 0; Count--)
{
AO[Count] = iMAOnArray(ExtBuffer,0,meanAO,0,MODE_SMMA,Count);
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments