PAX
Download scriptThis technical indicator is designed to provide traders with a sophisticated visualization of market momentum by blending unique price calculations with trend-smoothing techniques. Instead of looking at standard price action alone, it processes data through several layers to identify overbought/oversold conditions and major trend shifts.
Core Logic and Mechanics
1. Modified Price Foundation (Heikin Ashi Style) The indicator does not rely solely on the standard "Close" prices. It calculates a smoothed average of the price action by examining the relationship between consecutive candles. This creates a cleaner, less "noisy" data set, making it easier to identify the underlying direction of the market without being distracted by minor, insignificant fluctuations.
2. Dynamic Momentum Calculation The core calculation functions similarly to a momentum oscillator. It tracks the difference between the current smoothed price and the previous one:
- Positive Momentum: When prices are rising, the indicator accumulates "positive" weight.
- Negative Momentum: When prices are falling, it accumulates "negative" weight. By balancing these two forces against each other, the script generates a dynamic percentage value that reflects the current strength of the market movement.
3. Multi-Layered Smoothing (EMA) To further refine the data and ensure the signals are reliable, the indicator applies an Exponential Moving Average (EMA) to the calculated momentum. This smoothing helps filter out "fake" spikes, ensuring that the resulting line represents a sustained trend rather than a momentary price jump.
Visual Signals and Trading Zones
The indicator populates a separate window on your chart with several distinct visual elements to help you interpret market psychology:
- The Main Trend Lines: These act as boundary markers. When the momentum moves into specific extreme zones (defined by high or low thresholds), the indicator highlights the dominant trend.
- Trigger Levels: The script establishes specific "Buy" and "Sell" trigger zones. By observing these levels, traders can identify areas where the market may be reaching exhaustion or where a reversal might be imminent.
- Dynamic Histograms: These visual bars provide immediate feedback on whether the momentum is currently leaning toward the "positive" or "negative" side, allowing for a quick glance at the current sentiment of the price action.
Summary for the Trader
In simple terms, this tool takes messy market data and "cleans" it using a specialized averaging method. It then measures how fast that cleaned data is moving in one direction versus the other. Finally, it plots these movements as smooth lines and histograms, providing you with clear visual cues on whether the market is overextended (overbought/oversold) or if a significant trend shift is taking place.
/*--------------------------------------------------------------+
This indicator shows moving average of Heiken Ashi prices |
And a smoothed moving average... |
//--------------------------------------------------------------+
To access data from the indicator:
Main signal:
double PAX_now = iCustom(Symbol(),NULL, "PAX",PAX,Ma_PAX,0,0);
Smoothed signal:
double SPAX_now = iCustom(Symbol(),NULL, "PAX",PAX,Ma_PAX,5,0);
*/
#property copyright "Copyright © 2004, geoffb65."
#property link ""
#property indicator_separate_window
#property indicator_minimum -10
#property indicator_maximum 100
#property indicator_buffers 6
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Magenta
#property indicator_color5 DodgerBlue
#property indicator_color6 Red
//---- input parameters
extern int PAX = 9;
extern int Ma_PAX = 14;
extern int BuyTrigger = 20;
extern int SellTrigger = 80;
extern color BuyTriggerColor = DodgerBlue;
extern color SellTriggerColor = Magenta;
extern int MainTrendLong = 50;
extern int MainTrendShort = 50;
extern color MainTrendLongColor = Red;
extern color MainTrendShortColor = Green;
//---- buffers
double PAXBuffer[];
double PosBuffer[];
double NegBuffer[];
double bdn[],bup[];
double sdn[],sup[];
double marspax[];
string short_name;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
short_name = StringConcatenate("PAX(",PAX,")");
IndicatorBuffers(8);
SetIndexBuffer(0,PAXBuffer);
SetIndexBuffer(2,bup);
SetIndexBuffer(1,bdn);
SetIndexBuffer(3,sdn);
SetIndexBuffer(4,sup);
SetIndexBuffer(5,marspax);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(6,PosBuffer);
SetIndexBuffer(7,NegBuffer);
IndicatorShortName(short_name);
SetIndexDrawBegin(0,PAX);
SetIndexDrawBegin(1,PAX);
SetIndexDrawBegin(2,PAX);
SetIndexDrawBegin(3,PAX);
SetIndexDrawBegin(4,PAX);
SetIndexDrawBegin(5,PAX);
SetIndexDrawBegin(6,PAX);
SetIndexDrawBegin(7,PAX);
//----
drawLine(BuyTrigger,"BuyTrigger", BuyTriggerColor);
drawLine(SellTrigger,"SellTrigger", SellTriggerColor );
drawLine(MainTrendLong,"MainTrendLong", MainTrendLongColor );
drawLine(MainTrendShort,"MainTrendShort",MainTrendShortColor );
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double rel,negative,positive;
//----
if(Bars<=PAX) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=PAX;i++) PAXBuffer[Bars-i]=0.0;
//----
i=Bars-PAX-1;
int ma = i;
if(counted_bars>=PAX) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-PAX-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
int h=k+1;
double cma = (Open[k]+High[k]+Low[k]+Close[k])/4;
double pma = (Open[h]+High[h]+Low[h]+Close[h])/4;
rel=cma-pma;
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/PAX;
negative=sumn/PAX;
}
else
{
//---- smoothed moving average
int j=i+1;
double ccma = (Open[i]+High[i]+Low[i]+Close[i])/4;
double ppma = (Open[j]+High[j]+Low[j]+Close[j])/4;
rel=ccma-ppma;
if(rel>0) sump=rel;
else sumn=-rel;
positive=(PosBuffer[i+1]*(PAX-1)+sump)/PAX;
negative=(NegBuffer[i+1]*(PAX-1)+sumn)/PAX;
}
PosBuffer[i]=positive;
NegBuffer[i]=negative;
if(negative==0.0) PAXBuffer[i]=0.0;
else
{
PAXBuffer[i]=100.0-100.0/(1+positive/negative);
bdn[i] = 0;
bup[i] = 0;
sdn[i] = 0;
sup[i] = 0;
if(PAXBuffer[i]>MainTrendLong)
bup[i] = -10;
if(PAXBuffer[i]<MainTrendShort)
bdn[i] = -10;
if(PAXBuffer[i]<20 && PAXBuffer[i]>PAXBuffer[i+1])
sup[i] = -10;
if(PAXBuffer[i]>80 && PAXBuffer[i]<PAXBuffer[i+1])
sdn[i] = -10;
}
i--;
}
while(ma>=0)
{
marspax[ma] = iMAOnArray(PAXBuffer,0,Ma_PAX,0,MODE_EMA,ma);
ma--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
void drawLine(double lvl,string name, color Col )
{
ObjectDelete(name);
ObjectCreate(name, OBJ_HLINE, WindowFind(short_name), Time[0], lvl,Time[0],lvl);
ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
ObjectSet(name, OBJPROP_COLOR, Col);
ObjectSet(name,OBJPROP_WIDTH,1);
}
Comments