OS Gaussian Support Resistance

Download script
Author: mladen
OS Gaussian Support Resistance

This script is designed to provide traders with a visual representation of key market boundaries—specifically "Support" and "Resistance" levels—using a sophisticated mathematical approach known as Gaussian smoothing. Instead of reacting erratically to every minor price tick, the tool filters out market noise to highlight more significant trends.

How the Logic Works

1. Data Smoothing The first step the script takes is to look at the highest and lowest prices reached during specific intervals. To prevent these lines from jumping around too much (which can happen with standard moving averages), it applies a Gaussian calculation. This "smooths" the data, creating a fluid curve that reflects the underlying momentum of the market rather than just the raw, jagged price action.

2. Identifying Boundaries (Support and Resistance) Once the data is smoothed, the script looks back over a specific number of historical candles (defined by the "Period" setting).

  • Resistance: The script searches this historical window to find the highest smoothed point reached. This identifies the ceiling where the price has struggled to break through in the past.
  • Support: Simultaneously, it identifies the lowest smoothed point in that same window. This represents the "floor," or the level where buyers have historically stepped in to prevent the price from falling further.

3. Calculating the Equilibrium In addition to identifying the ceiling and the floor, the script automatically calculates an "Average" line. It does this by finding the exact midpoint between the Support and Resistance levels. This provides a visual cue of the market's "fair value" or equilibrium zone.

Summary for the Trader

By combining these three elements, the tool provides a clear snapshot of the current trading environment:

  • The Red Line (Resistance): Shows where the price might face selling pressure.
  • The Green Line (Support): Shows where the price might find buying interest.
  • The Dotted Line (Average): Shows the balanced middle ground between those two extremes.

Ultimately, this logic helps traders identify "zones of interest" where the market is likely to slow down, reverse, or consolidate, based on a statistically smoothed view of recent price history.

14 Views
0 Downloads
0 Favorites
OS Gaussian Support Resistance
//+------------------------------------------------------------------+
//|                             One Side Gaussian Support Resistance |
//|                                                           mladen |
//|                                                                  |
//| original idea and first implementation by : Tinytjan             |
//| (http://codebase.mql4.com/ru/2735)                               |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfxgmail.com"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 DimGray
#property indicator_style3 STYLE_DOT

//
//
//
//
//

extern int SRPeriod   = 40;
extern int SmoothType = 3;

//
//
//
//
//

double Resistance[];
double Support[];
double Average[];
double SmoothHigh[];
double SmoothLow[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

#import "OneSideGaussianLibrary.ex4"
   void   BuffersInit();
   double Smooth(int version,int price,int i);
#import

//
//
//
//
//

int init()
{
   BuffersInit();
   IndicatorBuffers(5);
      SetIndexBuffer(0, Resistance); SetIndexLabel(0,"OS Gaussian resistance");
      SetIndexBuffer(1, Support);    SetIndexLabel(1,"OS Gaussian support");
      SetIndexBuffer(2, Average);    SetIndexLabel(2,"OS Gaussian average");
      SetIndexBuffer(3, SmoothHigh);
      SetIndexBuffer(4, SmoothLow);
         SmoothType  = MathMax(MathMin(SmoothType,7),0);
      IndicatorShortName("One side Gaussian ("+SRPeriod+","+SmoothType+")");
   return(0);
}

//
//
//
//
//

int start()
{
   int counted_bars = IndicatorCounted();
   int i,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;
   
   //
   //
   //
   //
   //
   
   for(i = limit; i >= 0; i--)
   {
      SmoothLow[i]  = Smooth(SmoothType,PRICE_LOW, i);
      SmoothHigh[i] = Smooth(SmoothType,PRICE_HIGH,i);
      Support[i]    = SmoothLow [ArrayMinimum(SmoothLow,SRPeriod,i)];
      Resistance[i] = SmoothHigh[ArrayMaximum(SmoothHigh,SRPeriod,i)];
      Average[i]    = (Support[i] + Resistance[i])/2;
   }
   return(0);
}

Comments