______ _______ _____________
Download scriptThis script is designed as a historical data analysis tool for traders who need to understand the behavioral patterns of a specific financial instrument. Instead of providing real-time signals, it performs a "post-mortem" calculation on a specific period of time to establish a baseline of how the market typically behaves.
Core Functionality
The script scans through the historical price history and identifies every price candle that falls within a user-defined date range (set by the start and end dates). It then calculates four distinct types of averages to provide a comprehensive picture of market volatility and price action:
- Average Volatility: This measures the total distance between the highest and lowest prices reached during each period. It tells you the "swing" range, helping you understand how much space the price usually covers in a given timeframe.
- Average Body Size: This focuses on the actual movement of the price from open to close. By calculating the difference between the opening and closing price (regardless of direction), it shows how much "real" progress is typically made during each candle.
- Average Upper Shadow: The script identifies the distance between the top of the candle's body and its highest point. This helps visualize how often the price pushes upward before retreating.
- Average Lower Shadow: Similarly, this measures the distance between the bottom of the candle's body and its lowest point, revealing how much downward pressure or "rejection" typically occurs.
How it works for the user
When executed, the script automatically processes the data and displays a summary report directly on your chart. This report provides you with four key figures:
- The specific Start and End times of the analysis period.
- The Average Volatility in points.
- The Average Body Size in points.
- The Average Upper Shadow and Average Lower Shadow in points.
Practical Use Case
This tool is highly useful for "Normalizing" your expectations. By running this script on a historical period, you can determine the "normal" behavior of an asset. For example, if the average body size is usually 50 points but you see a candle with a 200-point body, you can instantly identify it as an outlier or an异常 move relative to historical norms.
//+------------------------------------------------------------------+
//| AverageRange.mq4 |
//| Êèì Èãîðü Â. aka KimIV |
//| http://www.kimiv.ru |
//| |
//| 14.09.2005 Ñêðèïò äëÿ ðàñ÷¸òà: |
//| ñðåäíåé âîëàòèëüíîñòè èíñòðóìåíòà High-Low |
//| ñðåäíåãî ðàçìåðà òåëà ñâå÷è ABS(Open-Close) |
//| ñðåäíåãî ðàçìåðà òåíè ñâå÷è |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link "http://www.kimiv.ru"
#property show_inputs
extern datetime BeginDateCalc = D'2001.01.01';
extern datetime EndDateCalc = D'2005.09.30';
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
void start() {
int i, b=0, bb=0, eb, h=0, l=0, s=0, t=0;
string comm="";
for (i=Bars; i>0; i--) {
if (Time[i]>=BeginDateCalc && Time[i]<=EndDateCalc) {
if (bb==0) bb=i;
s+=(High[i]-Low[i])/Point;
t+=MathAbs(Open[i]-Close[i])/Point;
if (Open[i]>Close[i]) {
h+=(High[i]-Open[i])/Point;
l+=(Close[i]-Low[i])/Point;
} else {
h+=(High[i]-Close[i])/Point;
l+=(Open[i]-Low[i])/Point;
}
b++;
}
}
comm = "Íà÷àëî: " + TimeToStr(Time[bb], TIME_DATE|TIME_MINUTES) + "\n";
comm = comm + "Êîíåö: " + TimeToStr(Time[bb-b+1], TIME_DATE|TIME_MINUTES) + "\n";
comm = comm + "Ñðåäíÿÿ âîëàòèëüíîñòü: " + s/b + " ï.\n";
comm = comm + "Ñðåäíèé ðàçìåð òåëà: " + t/b + " ï.\n";
comm = comm + "Ñðåäíèé ðàçìåð âåðõíåé òåíè: " + h/b + " ï.\n";
comm = comm + "Ñðåäíèé ðàçìåð íèæíåé òåíè: " + l/b + " ï.";
Comment(comm);
}
//+------------------------------------------------------------------+
Comments