OS Gaussian SR Rate

Download script
Author: mladen
OS Gaussian SR Rate

This tool is designed to provide traders with a visual representation of price positioning relative to recent market highs and lows. By analyzing historical price action, it calculates a specific "rate" that helps identify where the current price sits within a defined window of time.

How the Logic Works

1. Data Smoothing The script begins by looking at the highest and lowest prices over a specific period (the high and low points of each candle). To prevent the data from being too "noisy" or jumpy, it applies a Gaussian smoothing technique. This creates a cleaner, more fluid line that represents the general trend of the highs and lows rather than every tiny price fluctuation.

2. Establishing the Range The tool looks back at a predetermined number of bars (the "SRPeriod") to identify the boundaries of the market. It finds the lowest smoothed low and the highest smoothed high within that timeframe. These two points act as the "floor" and "ceiling" for the current price action.

3. Calculating the Position (The Rate) Once the floor and ceiling are established, the script calculates where the weighted average price currently sits between those two boundaries.

  • If the price is near the bottom of the range, the value will be closer to 0.
  • If the price is near the top of the range, the value will be closer to 1.
  • If the price is exactly in the middle, the value will be around 0.5.

Summary for the User

Essentially, this script translates complex price movements into a single percentage-like value (a rate) displayed in a separate window. It allows you to see at a glance whether the market is currently "oversold" relative to its recent highs/lows, "overbought," or hovering comfortably in the middle. It strips away the visual clutter of the main chart to show you the relative strength and position of the current price action.

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

#property indicator_separate_window
#property indicator_buffers    1
#property indicator_color1     Red
#property indicator_minimum    0
#property indicator_maximum    1
#property indicator_level1     0.5
#property indicator_levelcolor DarkSlateGray

//
//
//
//
//

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

//
//
//
//
//

double SmoothHigh[];
double SmoothLow[];
double Rate[];


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

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

//
//
//
//
//

int init()
{
   BuffersInit();
   IndicatorBuffers(3);
      SetIndexBuffer(0, Rate);
      SetIndexBuffer(1, SmoothHigh);
      SetIndexBuffer(2, SmoothLow);
         SmoothType  = MathMax(MathMin(SmoothType,7),0);
      IndicatorShortName("One side Gaussian SR rate("+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);
      
         double Min = SmoothLow [ArrayMinimum(SmoothLow ,SRPeriod,i)];
         double Max = SmoothHigh[ArrayMaximum(SmoothHigh,SRPeriod,i)];
         if (Min == Max) 
               Rate[i] = 0;
         else  Rate[i] = (Smooth(SmoothType,PRICE_WEIGHTED,i)-Min)/(Max - Min);
   }
   return(0);
}

Comments