Aroon_Up_Down

Download script
Aroon_Up_Down

This custom indicator is designed to help traders visualize market trends by measuring the strength and "freshness" of price movements. It works by calculating how recently the market has reached its highest and lowest points over a specific timeframe (which you can customize, but defaults to 14 periods).

How it Works

The logic operates by looking backward at a set number of bars on your chart to identify two key milestones: the highest peak reached and the lowest valley touched. Instead of just seeing where these peaks are, the script calculates exactly how many bars ago those points occurred.

  • The "Up" Measurement: The tool identifies when the highest price in the recent window occurred. If that high point happened very recently (at the current bar), it suggests a strong bullish momentum.
  • The "Down" Measurement: Similarly, the tool identifies when the lowest price in the recent window occurred. If that low point happened very recently, it indicates strong bearish momentum.

How to Interpret the Results

The script translates these time differences into two separate lines plotted on your screen:

  1. Trend Strength: By calculating the distance between the current bar and the high/low points, the indicator creates a percentage-based score. When a line moves toward the top of its scale (100), it signifies that the market is making new highs or lows aggressively.
  2. Momentum Shifts: By watching both lines simultaneously, you can see the "tug-of-war" between buyers and sellers. If the "Up" line is high while the "Down" line is low, it suggests a dominant upward trend. When they begin to converge or cross, it may indicate that the current trend is losing steam or that a reversal is beginning.

In essence, this tool removes the guesswork of "how long has it been since we saw a new high?" and provides a constant, visual pulse of market momentum based on time and price history.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Aroon_Up_Down
//+------------------------------------------------------------------+
//|                                         Custom Aroon Up & Dn.mq4 |
//|                                                        rafcamara |
//|                                                                  |
//+------------------------------------------------------------------+
#property  copyright "rafcamara"
#property  link      "rafcamara@yahoo.com"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  DodgerBlue
#property  indicator_color2  Red

//---- indicator parameters
extern int AroonPeriod=14;


//---- indicator buffers
double     AroonUpBuffer[];
double     AroonDnBuffer[];
double        HighBarBuffer[];
double        LowBarBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //---- 2 additional buffers are used for counting.
   IndicatorBuffers(4);
   SetIndexBuffer(0, AroonUpBuffer);
   SetIndexBuffer(1, AroonDnBuffer);
   SetIndexBuffer(2, HighBarBuffer);
   SetIndexBuffer(3, LowBarBuffer);

   //---- drawing settings
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
  SetIndexDrawBegin(0,200);
  SetIndexDrawBegin(1,200);
   IndicatorDigits(1);
   
   //---- indicator buffers mapping
   if(!SetIndexBuffer(0,AroonUpBuffer) && !SetIndexBuffer(1,AroonDnBuffer)
    && !SetIndexBuffer(2,HighBarBuffer) && !SetIndexBuffer(3,LowBarBuffer))
      Print("cannot set indicator buffers!");
   //---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Aroon Up & Dn("+AroonPeriod+")");
   //---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Aroon Up & Dn                                                    |
//+------------------------------------------------------------------+
int start()  
  {
   double   AroonUp,AroonDn;
   int      ArPer,limit,i;     
   int      UpBarDif,DnBarDif;
   int      counted_bars=IndicatorCounted(); 
   ArPer=AroonPeriod;                  //Short name
   
   //---- check for possible errors
   if(counted_bars<0) return(-1);
   if(AroonPeriod<1) return(-1);      

   //---- initial zero
   if(counted_bars<1)
     {
      for(i=1;i<=ArPer;i++) HighBarBuffer[Bars-i]=0.0;
      for(i=1;i<=ArPer;i++) LowBarBuffer[Bars-i]=0.0;
      for(i=1;i<=ArPer;i++) AroonUpBuffer[Bars-i]=0.0;
      for(i=1;i<=ArPer;i++) AroonDnBuffer[Bars-i]=0.0;
     } 

   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   //----Calculation---------------------------
   for( i=0; i<limit; i++)
   {
  	   HighBarBuffer[i] = Highest(NULL,0,MODE_HIGH,ArPer,i);   //Periods from HH  	   
  	   LowBarBuffer[i] = Lowest(NULL,0,MODE_LOW,ArPer,i);		  //Periods from LL

      UpBarDif = i-HighBarBuffer[i];	                       //Period substraction
      DnBarDif = i-LowBarBuffer[i];	                          //Period substraction
      
      AroonUpBuffer[i]=100+(100/ArPer)*(UpBarDif);            //Adjusted Aroon Up
      AroonDnBuffer[i]=100+(100/ArPer)*(DnBarDif);            //Adjusted Aroon Down
   }
   return(0);
  }
  

Comments