--Aroon Horn----
Download scriptThe Aroon Horn is a custom technical analysis indicator designed for the MetaTrader platform. Its primary purpose is to measure the strength of a trend by determining how long it has been since the price reached a new high or a new low within a specific timeframe.
Core Logic and Functionality
The script functions by analyzing a user-defined period of recent price bars (the default being 10). It processes two distinct metrics simultaneously to create a visual representation of market momentum:
- Trend Strength Measurement: The indicator calculates the distance between the current price point and the highest/lowest points reached during the selected period. If the price hit a new high or low very recently, the indicator reflects a high value; if the price hasn't reached a new extreme for a long time, the value remains lower.
- Dual Tracking: The script generates two separate lines:
- One tracks "Aroon Up" (measuring the momentum of upward movement).
- The other tracks "Aroon Down" (measuring the momentum of downward movement).
How it Works Internally
- Scanning the History: The script moves backward through the price history, examining every candle within your chosen period.
- Identifying Extremes: For each point in time, it identifies where the highest peak and lowest valley occurred relative to the current candle.
- Calculating the Score: It converts these distances into a percentage-based score. This allows traders to see at a glance whether the market is currently in a "fresh" trend (where new highs/lows are being made rapidly) or if the market is becoming stagnant.
- Data Visualization: These scores are plotted as two separate lines in a dedicated sub-window on your trading chart. This allows you to see the interaction between bullish and bearish momentum without cluttering the main price action.
Purpose for the Trader
By using this logic, a trader can identify whether a trend is gaining strength or losing steam. When one line stays high while the other remains low, it indicates a sustained move in one direction. Conversely, when both lines are fluctuating significantly, it may suggest a period of consolidation or a lack of clear direction.
//+------------------------------------------------------------------+
//| Aroon Horn.mq4 |
//| tonyc2a@yahoo.com |
//| |
//+------------------------------------------------------------------+
#property copyright "tonyc2a@yahoo.com"
#property link "mailto:tonyc2a@yahoo.com"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//----
extern int Aroon_Period=10;
//----
double Buffer1[];
double Buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(0, Buffer1);
SetIndexStyle(1, DRAW_LINE,STYLE_SOLID, 1);
SetIndexBuffer(1, Buffer2);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Aroon Horn" + "(" + Aroon_Period + ")");
SetIndexLabel(0, "Aroon Up");
SetIndexLabel(1, "Aroon Down");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double HighestBar, LowestBar, aroonUp, aroonDn;
for(int shift = Bars - Aroon_Period; shift >= 0; shift--)
{
HighestBar = Highest(NULL, 0, MODE_HIGH, Aroon_Period - 1, shift);
LowestBar = Lowest(NULL, 0, MODE_LOW, Aroon_Period - 1, shift);
//----
aroonUp = 100 - ((HighestBar - shift) / Aroon_Period) * 100;
aroonDn = 100 - ((LowestBar - shift) / Aroon_Period) * 100;
//----
if(aroonUp == 0)
{
aroonUp = 0.0000001;
}
//----
if(aroonDn == 0)
{
aroonDn = 0.0000001;
}
Buffer1[shift]=aroonUp;
Buffer2[shift]=aroonDn;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments