pro
Download scriptThe Percentage Price Oscillator (PPO) is a momentum-based technical analysis tool designed to help traders understand the strength and speed of price movements. Unlike standard indicators that show absolute price values, this script focuses on the relative percentage change between two different moving averages, making it easier to gauge market trends regardless of the asset's specific price point.
Core Logic and Calculations
The script operates by comparing two primary moving averages: a "Fast" average (which reacts quickly to recent price changes) and a "Slow" average (which tracks long-term trends).
- The PPO Value: The tool calculates the difference between these two averages and then divides that difference by the value of the slow average. By converting this into a percentage, the indicator provides a clearer picture of how much momentum is shifting in favor of either buyers or sellers.
- The Signal Line: To smooth out the fluctuations and make the data easier to read, the script creates a second line called the "Signal Line." This is essentially a moving average of the PPO values themselves, acting as a benchmark to identify significant shifts in trend direction.
Visual Indicators and Alerts
The script provides several visual cues to help users identify potential trading opportunities:
- Trend Lines: The main PPO line shows the current momentum, while the Signal Line acts as a guide for identifying when that momentum is accelerating or decelerating.
- Crossover Markers: The logic automatically monitors the relationship between the PPO and the Signal Line.
- When the PPO line crosses above the Signal Line, it suggests upward momentum.
- When the PPO line crosses below the Signal Line, it suggests downward momentum.
- Automated Alerts: To ensure traders don't miss these shifts, the script is programmed to trigger specific visual arrows on the chart and play audio alerts at the exact moment a crossover occurs.
Practical Application
By filtering out "market noise" through these calculations, the PPO helps identify the underlying strength of a trend. It tells you not just where the price is going, but how fast it is moving there, allowing for more informed decision-making during volatile market conditions.
//+------------------------------------------------------------------+
//| PPO.mq4 |
//| Copyright © 2007 Tom Balfe |
//| |
//| Percentage Price Oscillator |
//| This is a momentum indicator. |
//| Signal line is EMA of PPO. |
//| |
//| Follows formula: (FastEMA-SlowEMA)/SlowEMA |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007 Tom Balfe"
#property link "redcarsarasota@yahoo.com"
//----
#property indicator_separate_window
#property indicator_buffers 4
//----
#property indicator_color1 SkyBlue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_width1 2
#property indicator_width2 1
#property indicator_style2 2
//---- user changeable stuff
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalEMA=9;
extern bool sound= true;
//---- two buffers
double PPOBuffer[];
double SignalBuffer[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
static int prevtime = 0 ;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(1,SignalEMA);
IndicatorDigits(Digits+1);
SetIndexBuffer(0,PPOBuffer);
SetIndexBuffer(1,SignalBuffer);
SetIndexStyle(2,DRAW_ARROW,Red);
SetIndexArrow(2,236);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_ARROW,Blue);
SetIndexArrow(3,238);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexEmptyValue(3,0.0);
//----
IndicatorShortName("PPO ("+FastEMA+","+SlowEMA+","+SignalEMA+")");
SetIndexLabel(0,"PPO");
SetIndexLabel(1,"Signal");
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- (FastEMA-SlowEMA)/SlowEMA
//---- PPO counted in the 1st buffer
for(int i=0; i<limit; i++)
{
PPOBuffer[i]=(iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i))/
iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
}
for(i=0; i<limit; i++)
{
SignalBuffer[i]=iMAOnArray(PPOBuffer,Bars,SignalEMA,0,MODE_EMA,i);
if (Time[0]!=prevtime)
{
if ((PPOBuffer[i+2]>SignalBuffer[i+2])&&(PPOBuffer[i+1]<SignalBuffer[i+1]))
{
ExtMapBuffer4[i]=SignalBuffer[i];
if (sound == true){ PlaySound("alert.wav"); }
}
if ((PPOBuffer[i+2]<SignalBuffer[i+2])&&(PPOBuffer[i+1]>SignalBuffer[i+1]))
{
ExtMapBuffer3[i]=SignalBuffer[i];
if (sound == true){ PlaySound("alert2.wav"); }
}
prevtime=Time[0];
}
}
return(0);
}
//+--------------------------------------------------------------
Comments