Aroon_v1_2

This custom technical indicator is designed to help traders visualize market momentum by measuring how recently the price has reached its highest and lowest points within a specific timeframe. It provides a visual representation of "strength" in both upward and downward directions, helping users identify whether the market is trending or moving sideways.

Core Logic Overview

The script operates by looking back at a user-defined number of candles (the Aroon Period) to calculate two distinct values: an Up Trend value and a Down Trend value.

Instead of simply looking at the current price, the logic focuses on the location of the extreme highs and lows. Here is how the calculation works step-by-step:

  • Identifying Extremes: The tool scans the most recent set of candles to find the exact point where the highest high occurred and the point where the lowest low occurred within that period.
  • Measuring Recency: It calculates the distance (in terms of candles) between the current moment and those extreme points.
    • If a new high was reached very recently, the "Up" value increases.
    • If a new low was reached very recently, the "Down" value increases.
  • Scaling the Data: These distances are converted into a percentage-based scale (from 0 to 100). This allows traders to see a standardized view of momentum:
    • A high score suggests that the price is actively breaking new ground in that direction.
    • A low score suggests that the price hasn't reached a significant new peak or trough for some time, potentially indicating a lack of momentum or a cooling-off period.

Visual Output

The indicator produces two separate lines on a dedicated sub-window:

  1. The Up Line (Dodger Blue): Represents the strength of the bullish trend.
  2. The Down Line (Red): Represents the strength of the bearish trend.

By observing these two lines together, users can better understand the market's behavior. For example, when one line is high and the other is low, it often suggests a strong trending move in one direction. When both lines are low, it may indicate that the market is consolidating or moving range-bound without clear direction.

Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
Aroon_v1_2
//+------------------------------------------------------------------+
//|                                         Custom Aroon_v1.mq4      |
//|                                                        rafcamara |
//|                                         Has corrected - Ramdass  |
//+------------------------------------------------------------------+
#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=10;
extern int CountBars=300;


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

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

   //---- drawing settings
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   IndicatorDigits(1);
   
   //---- indicator buffers mapping
   if(!SetIndexBuffer(0,AroonUpBuffer) && !SetIndexBuffer(1,AroonDnBuffer))
      Print("cannot set indicator buffers!");
   //---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Aroon Up & Dn_v1("+AroonPeriod+")");
   //---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Aroon Up & Dn                                                    |
//+------------------------------------------------------------------+
int start()  
  {
   if (CountBars>=Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars+AroonPeriod+1);
   SetIndexDrawBegin(1,Bars-CountBars+AroonPeriod+1);
   double   AroonUp,AroonDn;
   int      ArPer,limit,i;     
   int      UpBarDif,DnBarDif;
//   int        HighBarBuffer;
//   int        LowBarBuffer;
   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++) AroonUpBuffer[CountBars-i]=0.0;
      for(i=1;i<=ArPer;i++) AroonDnBuffer[CountBars-i]=0.0;
     } 

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

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

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

Comments