CandleBodyPrcnt
Download scriptThis tool is designed to provide traders with a clear statistical overview of price action by calculating the average "substance" of candlesticks for a specific currency pair. Rather than looking at simple price movements, it focuses on how much of each candle's total range is occupied by the actual body (the difference between the opening and closing prices).
How the Logic Works
The script performs a comprehensive historical analysis of the current chart to determine the following:
- Individual Candle Analysis: The tool examines every single candle currently available in the history of the selected asset. For each candle, it measures the total distance from the highest point (High) to the lowest point (Low).
- Body Percentage Calculation: It then identifies the size of the "body"—the space between where the price opened and where it finally closed. By comparing this body size to the total range of the candle, the script calculates what percentage of that candle's movement was a direct move versus how much was "wasted" in wicks or tails.
- Averaging the Data: Once every historical candle has been analyzed, the script calculates the mean (average) body percentage across the entire data set.
- Final Output: The result is displayed directly on your chart as a simple percentage.
What This Means for the User
This calculation helps you understand the "personality" of a currency pair. For example:
- A high average percentage suggests that price movements are generally decisive, with the market moving steadily in one direction with relatively small wicks.
- A low average percentage indicates a market prone to high volatility and frequent "fake-outs," where the price covers a large range but often reverts back, leaving behind long shadows or wicks.
By providing this snapshot, the tool allows you to quickly gauge whether a pair tends to trend strongly or fluctuate erratically before you begin your analysis.
//+------------------------------------------------------------------+
//| CandleBodyPrcnt.mq4 |
//| Copyright © 2008, Ronald Verwer / Forex MetaSoft |
//| http://www.forexmetasoft.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Ronald Verwer / Forex MetaSoft"
#property link "http://www.forexmetasoft.com"
int i;
double prcnt,OverAllPercent;
//+------------------------------------------------------------------+
//| script initialization function |
//+------------------------------------------------------------------+
int init()
{
Comment("");
}
//+------------------------------------------------------------------+
//| script execution function |
//+------------------------------------------------------------------+
int start()
{
for(i=Bars;i>=0;i--)
{
if(High[i]-Low[i]>0)
prcnt+=((MathAbs(Open[i]-Close[i]))/(High[i]-Low[i]))*100;
}
OverAllPercent=prcnt/(Bars+1);
Comment("\nAverage Candle Body of the "+Symbol()+" currency pair is "+DoubleToStr(OverAllPercent,2)+"%");
//return(0);
}
//+------------------------------------------------------------------+
Comments