Author: Copyright � 2004, MetaQuotes Software Corp.
RSI_dots1

This tool is designed to provide traders with a visual representation of market momentum by calculating the Relative Strength Index (RSI). Unlike standard indicators that may simply show a fluctuating line, this specific script focuses on highlighting key price action dynamics through a dedicated visual output.

Core Functionality

The primary purpose of this script is to measure the velocity and magnitude of price movements over a user-defined period. It evaluates how much "push" there is in an upward direction versus a downward direction. By quantifying these opposing forces, it helps identify whether a market trend is gaining strength or beginning to exhaust itself.

How the Logic Works

The logic operates through three main stages:

1. Data Collection and Calculation The script looks back at a specific number of previous price bars (determined by the period setting). It calculates the difference between consecutive closing prices to determine if the move was positive or negative. It then separates these moves into two distinct categories: total gains and total losses.

2. Smoothing the Momentum To ensure the data isn't overly reactive to minor, insignificant "noise" in the market, the script employs a smoothing mechanism. Instead of looking at each price change in isolation, it blends the current momentum with previous calculations. This creates a more fluid and continuous calculation of the strength of the trend, making it easier for users to see the overall direction of the market flow.

3. Visual Output The final result is expressed as a percentage value between 0 and 100:

  • Strength Measurement: The script calculates a ratio of positive momentum relative to negative momentum. This is then converted into a standardized scale.
  • Visual Indicators: Rather than a standard continuous line, this script is configured to display specific "dots" or markers. These markers appear in a separate window on your chart, allowing you to monitor the RSI levels against pre-defined thresholds (such as 75, 65, 35, and 25).

Practical Application

By monitoring these visual points, users can better understand overbought or oversold conditions. When the momentum shifts significantly toward one extreme or the other, the indicator provides a clear cue regarding the current state of market exhaustion or strength, helping to inform more informed trading decisions.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
RSI_dots1
//+------------------------------------------------------------------+
//|    Dots added by Accrete : )  accrete.com            RSIdots.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_color1 Yellow
#property indicator_level1 75
#property indicator_level2 25
#property indicator_level3 65
#property indicator_level4 35
//---- input parameters
extern int RSIPeriod=2;

//---- buffers
double RSIBuffer[];
double PosBuffer[];
double NegBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
   SetIndexBuffer(1,PosBuffer);
   SetIndexBuffer(2,NegBuffer);
//---- indicator line
  SetIndexStyle(0,DRAW_ARROW,EMPTY);
   SetIndexArrow(0,115); 
   SetIndexBuffer(0,RSIBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="RSI("+RSIPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,RSIPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   int    i,counted_bars=IndicatorCounted();
   double rel,negative,positive;
//----
   if(Bars<=RSIPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=RSIPeriod;i++) RSIBuffer[Bars-i]=0.0;
//----
   i=Bars-RSIPeriod-1;
   if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
      double sumn=0.0,sump=0.0;
      if(i==Bars-RSIPeriod-1)
        {
         int k=Bars-2;
         //---- initial accumulation
         while(k>=i)
           {
            rel=Close[k]-Close[k+1];
            if(rel>0) sump+=rel;
            else      sumn-=rel;
            k--;
           }
         positive=sump/RSIPeriod;
         negative=sumn/RSIPeriod;
        }
      else
        {
         //---- smoothed moving average
         rel=Close[i]-Close[i+1];
         if(rel>0) sump=rel;
         else      sumn=-rel;
         positive=(PosBuffer[i+1]*(RSIPeriod-1)+sump)/RSIPeriod;
         negative=(NegBuffer[i+1]*(RSIPeriod-1)+sumn)/RSIPeriod;
        }
      PosBuffer[i]=positive;
      NegBuffer[i]=negative;
      if(negative==0.0) RSIBuffer[i]=0.0;
      else RSIBuffer[i]=100.0-100.0/(1+positive/negative);
      i--;
     }

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

Comments