Ticker Awesome Oscillator
Download scriptThis script is a specialized technical analysis tool designed for the MetaTrader platform. It functions as a customized version of the "Awesome Oscillator," specifically modified to track price movement through a unique "Ticker" logic.
Instead of relying solely on standard price candles, the script builds a historical record of price points to calculate momentum and trends. Here is a breakdown of how the logic operates:
Core Tracking Logic
The tool maintains a memory bank of recent price data (up to 1,000 bars). Every time the market price moves to a new level, the script updates this internal history. It effectively creates a "timeline" of values that it uses as the foundation for all its calculations.
Moving Average Calculations
To determine the trend, the script performs two distinct types of mathematical averaging:
- Fast Movement: It calculates a short-term average based on a small window of data (5 periods). This represents the immediate, "fast" momentum of the market.
- Slow Movement: It calculates a long-term average based on a larger window of data (34 periods). This represents the broader, "slow" trend of the market.
Momentum Visualization
The primary goal of the script is to find the difference between these two averages. By subtracting the slow average from the fast average, the tool identifies the current momentum:
- Positive Momentum: If the fast average is higher than the slow average, it indicates upward momentum.
- Negative Momentum: If the fast average is lower than the slow average, it indicates downward momentum.
Visual Representation
The results are displayed in a separate window at the bottom of your trading chart using a histogram format:
- Green Histograms: These appear when the calculated momentum is moving upward (positive values).
- Red Histograms: These appear when the calculated momentum is moving downward (negative values).
In summary, this tool acts as a trend-tracking barometer. It smooths out market "noise" by comparing short-term price action against long-term trends, allowing traders to see at a glance whether the current momentum is accelerating in a positive or negative direction.
//+------------------------------------------------------------------+
//| |
//| Ticker Awesome Oscillator.mq4 |
//+------------------------------------------------------------------+
#property copyright "mandorr@gmail.com"
//----
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Black
#property indicator_width1 1
#property indicator_style1 0
#property indicator_color2 Green
#property indicator_width2 1
#property indicator_style2 0
#property indicator_color3 Red
#property indicator_width3 1
#property indicator_style3 0
//----
extern int CountBars=1000; // Êîëè÷åñòâî îòîáðàæàåìûõ áàðîâ
//----
int count;
int price;
int price_prev;
double period_fast=5;
double period_slow=34;
double ma_fast; // Fast SMA
double ma_slow; // Slow SMA
double ticker[10]; // Ticker
double array0[10];
double array1[10];
double array2[10];
double buffer0[];
double buffer1[];
double buffer2[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void init()
{
SetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(0,buffer0);
SetIndexLabel(0,"Value");
SetIndexDrawBegin(0,0);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,buffer1);
SetIndexLabel(1,NULL);
SetIndexDrawBegin(1,0);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexBuffer(2,buffer2);
SetIndexLabel(2,NULL);
SetIndexDrawBegin(2,0);
IndicatorDigits(Digits+2);
//----
count=ArrayResize(ticker,CountBars);
count=ArrayResize(array0,CountBars);
count=ArrayResize(array1,CountBars);
count=ArrayResize(array2,CountBars);
count=0;
//----
ArrayInitialize(array0,0);
ArrayInitialize(array1,0);
ArrayInitialize(array2,0);
price_prev=0;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void start()
{
int i;
double sum;
if (price_prev==0)
{
ArrayInitialize(buffer0,0);
ArrayInitialize(buffer1,0);
ArrayInitialize(buffer2,0);
array0[0]=0;
array1[0]=0.01*Point;
array2[0]=-0.01*Point;
buffer0[0]=array0[0];
buffer1[0]=array1[0];
buffer2[0]=array2[0];
price=MathRound(Bid/Point);
price_prev=price;
ticker[0]=price*Point;
IndicatorShortName("Ticker ("+count+") AO");
return;
}
price=MathRound(Bid/Point);
if (price==price_prev) return;
price_prev=price;
for(i=count; i>=0; i--)
{
ticker[i+1]=ticker[i];
array0[i+1]=array0[i];
array1[i+1]=array1[i];
array2[i+1]=array2[i];
}
ticker[0]=price*Point;
if (count<CountBars-1) count++;
IndicatorShortName("Ticker ("+count+") AO");
if (count<period_slow-1)
{
array0[0]=0;
array1[0]=0.01*Point;
array2[0]=-0.01*Point;
for(i=0; i<=count; i++)
{
buffer0[i]=array0[i];
buffer1[i]=array1[i];
buffer2[i]=array2[i];
}
return;
}
sum=0;
for(i=0; i<=period_fast-1; i++) sum+=ticker[i];
ma_fast=sum/period_fast;
sum=0;
for(i=0; i<=period_slow-1; i++) sum+=ticker[i];
ma_slow=sum/period_slow;
array0[0]=ma_fast-ma_slow;
array1[0]=0;
array2[0]=0;
if (array0[0]>=array0[1]) array1[0]=array0[0]; else array2[0]=array0[0];
for(i=0; i<=count; i++)
{
buffer0[i]=array0[i];
buffer1[i]=array1[i];
buffer2[i]=array2[i];
}
}
//+------------------------------------------------------------------+
Comments