SmoothCandle C v1.00
Download scriptThe SmoothCandle S is a technical analysis tool designed to filter out market "noise" by smoothing the standard price action of financial charts. While traditional candlesticks can often appear jagged and erratic due to rapid, minor fluctuations in price, this script provides a more stabilized visual representation of where the market is actually moving over a specific period.
How the Logic Works
Price Averaging Instead of looking at the price of just the most recent candle, the script calculates an average for four key data points: the Open, High, Low, and Close prices. It looks back at a predetermined number of past candles (defined by the "SMA" setting) and aggregates their values to determine a single "smoothed" price point for the current moment.
Visual Smoothing By averaging these values, the tool creates a more fluid transition between data points. This helps traders identify the primary trend by removing insignificant price spikes that might otherwise trigger premature reactions or confusion.
Delayed Projection (Shifting) To ensure the visual lines align correctly with the smoothed data, the script applies a specific "shift" to the lines on your chart. This shift ensures that the smoothed trends correspond accurately to the timeframe you are analyzing, providing a clear, continuous path of price movement.
Key Benefits for Traders
- Trend Clarity: By rounding off the sharp edges of standard candles, it becomes easier to see the underlying direction of the market.
- Reduced Noise: It helps in identifying significant movements while ignoring minor fluctuations that don't contribute to the overall trend.
- Customizable Sensitivity: The logic allows you to adjust the "SMA" parameter, giving you control over how much historical data is used—allowing you to choose between a highly responsive line or a much slower, more stable average.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| SmoothCandle S v1.00.mq4 |
//| Copyright © 2005, Varus Henschke |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Varus Henschke"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 DimGray
#property indicator_color3 DimGray
#property indicator_color4 Blue
//---- indicator parameters
extern int SMA=5;
//---- indicator buffers
double nOpen[];
double nHigh[];
double nLow[];
double nClose[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator line
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
//---- line shifts when drawing
SetIndexShift(0,SMA);
SetIndexShift(1,SMA);
SetIndexShift(2,SMA);
SetIndexShift(3,SMA);
//---- indicator buffers mapping
if(!SetIndexBuffer(0,nOpen) && !SetIndexBuffer(1,nHigh) && !SetIndexBuffer(2,nLow) && !SetIndexBuffer(3,nClose))
Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
//IndicatorShortName("SmoothCandle S SMA ( " +SMA+ " )");
//SetIndexLabel(0,"Open");
//SetIndexLabel(1,"High");
//SetIndexLabel(2,"Low");
//SetIndexLabel(3,"Close");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Moving Averages of Candlestick |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars-SMA-1;
for(int i=SMA; i<limit; i++){ // Does not work if i=0 so included SetIndexShift above. That does my head in.
nOpen[i] = 0;
nHigh[i] = 0;
nLow[i] = 0;
nClose[i] = 0;
for(int j=i-SMA; j<i; j++){
nOpen[i] = nOpen[i] + (Open[j] / SMA);
nHigh[i] = nHigh[i] + (High[j] / SMA);
nLow[i] = nLow[i] + (Low[j] / SMA);
nClose[i] = nClose[i] + (Close[j] / SMA);
}
}
//---- done
return(0);
}
Comments