SmoothCandle C v1.00_v1

Download script
SmoothCandle C v1.00_v1

The SmoothCandle S is a custom technical analysis tool designed for the MetaTrader 4 platform. Its primary purpose is to filter out "market noise" by smoothing the price action of traditional Japanese candlesticks, allowing traders to see more stabilized trends rather than volatile, erratic price movements.

How the Logic Works

The script operates by calculating a Simple Moving Average (SMA) specifically for each individual component of a candlestick. In standard trading, candles are defined by four key price points:

  • Open: The price when the candle started.
  • High: The highest price reached during the period.
  • Low: The lowest price reached during the period.
  • Close: The final price when the candle ended.

Instead of plotting these raw, jagged values, the SmoothCandle S takes a user-defined number of previous candles (the "SMA" setting) and calculates the average for each of those four points.

Key Features of the Logic

  • Multi-Point Smoothing: Rather than just smoothing the closing price, the script simultaneously smooths the Open, High, Low, and Close prices. This creates a cohesive set of averaged data points that represent the "core" movement of the market over a specific timeframe.
  • Visual Shift: The tool incorporates a built-in visual shift. By aligning the smoothed data with the SMA period, it ensures that the lines appear correctly positioned on your chart relative to the current price action, preventing the visual clutter that often occurs with lagging indicators.
  • Trend Clarification: By averaging the highs and lows alongside the opens and closes, the indicator helps traders identify the prevailing direction of the market. It suppresses minor fluctuations (wicks and small body movements) to highlight the underlying trend.

Summary for Traders

Essentially, this script acts as a "lens" that blurs out the immediate chaos of the market. By using a moving average to redraw the boundaries of the candles, it provides a cleaner visual representation of price history, making it easier to identify significant support, resistance, and trend shifts without being distracted by insignificant price spikes.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
SmoothCandle C v1.00_v1
//+------------------------------------------------------------------+
//|                                         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