PDF_v2
Download scriptThis technical indicator is designed to provide traders with a visual representation of price momentum and distribution based on historical volatility. Rather than showing standard price movements, it analyzes how frequently specific levels within a moving range are reached over a defined period.
Core Logic Overview
The tool operates by examining a fixed window of past price bars (customizable by the user). It specifically looks at the Stochastic Oscillator—a common momentum tool—to determine where the price is currently positioned relative to its recent high and low points.
Instead of simply plotting this value as a single line, the script performs a frequency analysis:
- Frequency Mapping: The indicator takes the values generated over the last 20 bars (by default) and counts how many times the price "hits" or stays at specific numerical levels.
- Distribution Distribution: It organizes these occurrences into a distribution table. For example, it tracks how often the price reaches the extreme high end versus the middle or the lower end of its recent range.
- Visual Output: The final result is displayed as a profile in a separate window. This allows you to see "density" areas—essentially highlighting which price zones have been most active recently.
Practical Application
For a non-technical user, think of this as a "Heat Map" of recent price activity.
By looking at the resulting curve, you can identify where the market is spending the most time. If the indicator shows a high concentration at a certain level, it suggests a zone of significant interest or resistance. It transforms raw price data into a visual summary of behavior, helping traders see the "weight" of the market's movement rather than just the direction.
//+------------------------------------------------------------------+
//| PDF.mq4 |
//| Copyright © 2006, Luis Guilherme Damiani |
//| http://www.damianifx.com.br |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Luis Guilherme Damiani"
#property link "http://www.damianifx.com.br"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 MediumSeaGreen
//----
double pdf[];
//---- input parameters
extern int ch_size=20;
//extern int limit_value=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,pdf);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
//---- indicators
int counter[100];
int totBars=Bars;
int value=0;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
ArrayInitialize(counter,0);
for(int i =Bars-1-ch_size;i>=0;i--)
{
value=MathCeil(iStochastic(NULL,0,ch_size, 2,1,MODE_SMA,0,MODE_MAIN,i));
counter[100-value]=counter[100-value]+1;
//if(counter[100-value]>limit_value && limit_value!=0)counter[100-value]=limit_value;
}
pdf[0]=0;
for(i=100;i>0;i--)
{
pdf[i]=counter[i];
// Print(pdf[i]);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments