Perkytrend
Download scriptOverview of the PerkyTrend Indicator
The PerkyTrend is a visual trading tool designed to help market participants identify and follow prevailing price trends. By analyzing the momentum and strength of the market, it translates complex mathematical data into a color-coded histogram that simplifies decision-making for traders.
How the Logic Works
The indicator operates by processing the ADX (Average Directional Index), a common technical tool used to measure the strength of a trend regardless of its direction. Here is the step-by-step breakdown of how it interprets market behavior:
1. Establishing a Strength Baseline
The tool first calculates a baseline for "market activity." It looks at a specific timeframe (defaulting to 14 periods) and compares the current trend strength against a minimum threshold (defaulting to 20). This helps filter out "noisy" price movements where there is no significant momentum, allowing the indicator to focus only on meaningful trends.
2. Tracking Momentum Direction
Once the strength is established, the script tracks whether that momentum is increasing or decreasing:
- Rising Momentum: If the current trend strength is higher than the previous period, it indicates that the market move has accelerating force.
- Falling Momentum: If the strength begins to drop compared to the previous period, it suggests the trend is losing its push.
3. Visualizing with Color Coding
To make these movements easy to read at a glance, the indicator uses two distinct histogram colors:
- Green Histogram: This appears when the momentum is moving upward. It signals that the current trend has active strength and is pushing forward.
- Red Histogram: This appears when the momentum begins to decline. It serves as a visual cue that the price movement may be slowing down or losing its primary drive.
Key Trading Signals
The logic is designed to provide clarity on two main fronts:
- Trend Confirmation: The histogram helps confirm if a move has enough "weight" behind it to be considered a valid trend rather than a temporary fluctuation.
- Entry/Exit Cues: A primary signal occurs when the histogram crosses from below the zero line to above it while turning green. This transition suggests that the market is gaining enough strength to initiate a new upward move, providing a clear visual starting point for traders looking to join the momentum.
//+------------------------------------------------------------------+
//| Awesome.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
// Basically ADX mainline use..
//when the trend is moving up the histogram is green and rising.
// best signal - when the histgram moves from below the line to above
// it turns green - unless in range market suggests the trend has
// some strength.
#property copyright "Another perky marvel."
#property link "perky_z@yahoo.com"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//---- indicator buffers
double ind_buffer1[];
double ind_buffer2[];
double ind_buffer3[];
extern int trendperiod=14;
extern int trendlowerlimit=20;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 1 additional buffer used for counting.
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,3);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
SetIndexDrawBegin(0,34);
SetIndexDrawBegin(1,34);
//---- 3 indicator buffers mapping
if(!SetIndexBuffer(0,ind_buffer1) &&
!SetIndexBuffer(1,ind_buffer2) &&
!SetIndexBuffer(2,ind_buffer3))
Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("PerkyTrend");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Awesome Oscillator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double prev,current;
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st additional buffer
for(int i=0; i<limit; i++)
ind_buffer3[i]=iADX(NULL,0,trendperiod,PRICE_CLOSE,MODE_MAIN,i)-trendlowerlimit;
//---- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0; i--)
{
current=ind_buffer3[i];
prev=ind_buffer3[i+1];
if(current>prev) up=true;
if(current<prev) up=false;
if(!up)
{
ind_buffer2[i]=current;
ind_buffer1[i]=0.0;
}
else
{
ind_buffer1[i]=current;
ind_buffer2[i]=0.0;
}
}
//---- done
return(0);
}
Comments