Stochastic Dots

Download script
Author: mladen
Stochastic Dots

This script is designed as a specialized visual tool for the MetaTrader platform to help traders identify specific price action trends using a modified Stochastic Oscillator. Rather than just showing standard moving lines, this indicator focuses on highlighting "overextended" market conditions through a system of dots and colored signals.

Core Functionality

The logic operates by calculating two primary data streams: a Fast line and a Slow line. These represent the momentum of the currency or asset being traded. While the standard Stochastic Oscillator provides a continuous flow of data, this specific script filters that data to focus on extremes.

How the Logic Works:

  • Momentum Calculation: The tool looks at historical price points (which can be adjusted by the user between "High/Low" prices or "Close" prices) and applies different types of moving averages to smooth out the data. This determines where the current price sits relative to its recent range.
  • Threshold Monitoring: The script continuously checks whether the momentum has reached specific "Overbought" (too high) or "Oversold" (too low) levels. These are the boundaries where a trend might be reaching its limit.
  • Visual Signaling: Instead of just drawing a line across the screen, the logic creates distinct visual markers:
    • Upper Signals: When the momentum exceeds the "Overbought" level, the script places marks to highlight this high-pressure zone.
    • Lower Signals: When the momentum drops below the "Oversold" level, the script places marks to highlight the low-pressure zone.
  • Smart Filtering: The logic includes a "stickiness" feature for the dots. It ensures that signals are displayed in a way that is visually coherent on the chart, checking preceding values to ensure that the markers appear appropriately as the price moves into and out of these extreme zones.

Summary for the User

In plain terms, this tool acts as a visual "alert system" on your chart. Rather than making you watch a constant moving line, it filters out the "noise" of normal market movement and only highlights specific areas where the asset is potentially overextended. It translates complex momentum math into clear, colored dots that show you exactly where the market is pushing against its limits.

Indicators Used
Stochastic oscillator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
12 Views
0 Downloads
0 Favorites
Stochastic Dots
//+------------------------------------------------------------------+
//|                                             Color Stochastic.mq4 |
//|                                                           mladen |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      ""

#property indicator_separate_window
#property indicator_buffers   4
#property indicator_minimum   0
#property indicator_maximum 100
#property indicator_color1 Blue
#property indicator_color2 Pink
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_width3 2
#property indicator_width4 2
 


//---- input parameters
//
//    nice setings for trend = 35,10,1
//
//

extern string note1 = "Stochastic settings";
extern int       KPeriod     =  14;
extern int       DPeriod     =  3;
extern int       Slowing     =  3;
extern string note4 = "0=sma, 1=ema, 2=smma, 3=lwma";
extern int       MAMethod    =   0;
extern string note5 = "0=high/low, 1=close/close";
extern int       PriceField  =   1;
extern string note6 = "overbought level";
extern int       overBought  =  80;
extern string note7 = "oversold level";
extern int       overSold    =  20;
extern string note8 = "nice setings for trend = 35,10,1";


//---- buffers
//
//
//
//
//

double KFull[];
double DFull[];
double Upper[];
double Lower[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
{
      SetIndexStyle(1,DRAW_ARROW); 
      SetIndexStyle(2,DRAW_ARROW); 
      SetIndexStyle(3,DRAW_ARROW); 
      SetIndexBuffer(0,KFull);
      SetIndexBuffer(1,DFull);
      SetIndexBuffer(2,Upper);
      SetIndexBuffer(3,Lower);
      SetIndexLabel(1,"Fast");
      SetIndexLabel(2,NULL);
      SetIndexLabel(3,NULL);
         
         //
         //
         //
         //
         //
         
         DPeriod = MathMax(DPeriod,1);
         if (DPeriod==1) {
               SetIndexStyle(0,DRAW_NONE);
               SetIndexLabel(0,NULL);
            }
         else {
               SetIndexStyle(0,DRAW_ARROW); 
               SetIndexLabel(0,"Slow");
            }               
         
         //
         //
         //
         //
         //
         
   string shortName = "Stochastic Dots ("+KPeriod+","+Slowing+","+DPeriod+","+maDescription(MAMethod)+","+priceDescription(PriceField);
         if (overBought < overSold) overBought = overSold;
         if (overBought < 100)      shortName  = shortName+","+overBought;
         if (overSold   >   0)      shortName  = shortName+","+overSold;
   IndicatorShortName(shortName+")");
   return(0);
}

//
//
//
//
//

int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
{
   int    counted_bars=IndicatorCounted();
   int    limit;
   int    i;
   
   
   
   
   if(counted_bars<0) return(-1);
   limit=Bars-counted_bars;
      
   //
   //
   //
   //
   //
   
   for(i=limit; i>=0; i--)
      {
            KFull[i] = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_MAIN,i);
            DFull[i] = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_SIGNAL,i);

            //
            //
            //
            //
            //
                                
            if (KFull[i] > overBought) { Upper[i] = KFull[i]; Upper[i+1] = KFull[i+1]; }
            else                       { Upper[i] = EMPTY_VALUE;
                                         if (Upper[i+2] == EMPTY_VALUE)
                                             Upper[i+1]  = EMPTY_VALUE; }                            
            if (KFull[i] < overSold)   { Lower[i] = KFull[i]; Lower[i+1] = KFull[i+1]; }                   
            else                       { Lower[i] = EMPTY_VALUE;
                                         if (Lower[i+2] == EMPTY_VALUE)
                                             Lower[i+1]  = EMPTY_VALUE; }                            
      }

   //
   //
   //
   //
   //
 
   return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

string priceDescription(int mode)
{
   string answer;
   switch(mode)
   {
      case 0:  answer = "Low/High"    ; break; 
      case 1:  answer = "Close/Close" ; break;
      default: answer = "Invalid price field requested";
                                    Alert(answer);
   }
   return(answer);
}
string maDescription(int mode)
{
   string answer;
   switch(mode)
   {
      case MODE_SMA:  answer = "SMA"  ; break; 
      case MODE_EMA:  answer = "EMA"  ; break;
      case MODE_SMMA: answer = "SMMA" ; break;
      case MODE_LWMA: answer = "LWMA" ; break;
      default:        answer = "Invalid MA mode requested";
                                    Alert(answer);
   }
   return(answer);
}

Comments