ang_ALR(V)
Download scriptThis indicator is designed to analyze market price trends by calculating the velocity and direction of price movement over a specific timeframe. Instead of simply looking at where the price is currently sitting, it focuses on the "momentum" or the speed at which the market is moving toward a target.
Core Methodology
1. Linear Trend Projection
The script calculates a linear regression for the price data based on a user-defined time window (related to the hrLR setting). By performing this calculation, the tool determines the "line of best fit" for recent price action. This helps smooth out temporary market noise to identify the underlying direction of the trend.
2. Velocity Calculation Once the trend line is established, the script calculates the velocity of that trend. Essentially, it measures how aggressively the price is pushing in a specific direction. This value is then normalized so that users can see the strength of the move regardless of the asset's absolute price.
3. Noise Reduction and Smoothing To ensure the data is usable for trading decisions, the script employs two main smoothing techniques:
- Rounding: It applies a "rounding" logic to the velocity values. This prevents small, insignificant fluctuations from creating "choppy" signals, ensuring that only significant changes in momentum are highlighted.
- Moving Averages: The tool then calculates a secondary moving average of these smoothed velocity values. This provides a final, polished curve that represents the sustained trend rather than fleeting moments of volatility.
Visual Representation
The indicator translates these complex calculations into a visual layout on your chart:
- Dynamic Histograms: The primary data is displayed as histograms. When the momentum is positive (moving up), it highlights the upward pressure; when negative, it shows the downward pressure. The script specifically separates these to clearly distinguish between "growth" and "contraction" phases.
- Symmetry Indicators: The tool also plots symmetrical lines (upper and lower bounds) based on the absolute value of the momentum. These serve as a visual guide to the intensity of the current trend, helping you see how far the price is deviating from its mean speed.
Summary for the User
In plain terms, this script tells you not just where the price is going, but how fast and with what conviction it is getting there. It filters out the "jitter" of the market to show you the smooth, underlying pulse of the trend, making it easier to identify whether a move has real strength or is simply losing steam.
//------at_ALR(V)-------------------
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 SlateGray
#property indicator_color4 SlateGray
#property indicator_color5 Gold
#property indicator_width1 2
#property indicator_width2 2
#property indicator_style3 2
#property indicator_style4 2
#property indicator_style5 2
#property indicator_level1 0
//---------------------------------
extern double hrLR=24;
extern double kSig=0.3;
extern double k=1.0;
extern double Rd=0.05;
//---------------------------------
double alr[],alra[],alrH[],alrL[],sqH[],sqL[],ma[];
//---------------------------------
double sx,sy,syp,sxy,sxyp,sxx,aa,bb,S;
double rd,abs;
int p,pma,fs,fss;
//------------------------------------
int init()
{
IndicatorBuffers(7);
//---------------------------------------------------
IndicatorShortName("ang_ALR(V) "+DoubleToStr(hrLR,0));
//---------------------------------------------------
SetIndexBuffer(0,alrH);
SetIndexBuffer(1,alrL);
SetIndexBuffer(2,sqH);
SetIndexBuffer(3,sqL);
SetIndexBuffer(4,ma);
//------------------------
SetIndexBuffer(5,alr);
SetIndexBuffer(6,alra);
//------------------------
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
//-------------------------------
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
//-------------------------------
return(0);
}
//*************************************************
int start()
{
int cbi,cbi2,IC=IndicatorCounted();
if (Bars-IC<3) cbi=Bars-IC-1; else
{
p=hrLR*60/Period()+1;
pma=p*kSig;
cbi=Bars-p-1;
cbi2=cbi-p-pma;
}
//==========================================
for(int i=cbi; i>=0; i--)
{
sx=0.0; sy=0.0; sxy=0.0; sxx=0.0;
for (int n=i; n<i+p; n++)
{
sx+=n;
sy+=Close[n];
sxy+=n*Close[n];
sxx+=MathPow(n,2);
}
aa=(sx*sy-p*sxy)/(MathPow(sx,2)-p*sxx);
bb=(sy-aa*sx)/p;
//-----------------------------
alr[i]=-aa*p/Point/hrLR;
alra[i]=MathAbs(alr[i]);
if (Rd!=0)
{
if (alr[i]>0) {if (fss==2) rd=0.0; fss=1;}
if (alr[i]<0) {if (fss==1) rd=0.0; fss=2;}
if (alr[i]>=rd+Rd || alr[i]<=rd-Rd) rd=MathRound(alr[i]/Rd)*Rd;
alr[i]=rd;
}
if (alr[i]>alr[i+1]) fs=1;
if (alr[i]<alr[i+1]) fs=2;
if (fs==1) {alrH[i]=alr[i]; alrL[i]=0.0;}
if (fs==2) {alrL[i]=alr[i]; alrH[i]=0.0;}
}
//===========================================
for (i=cbi2; i>=0; i--)
{
ma[i]=iMAOnArray(alr,0,pma,0,0,i);
abs=iMAOnArray(alra,0,p,0,0,i)*k;
sqH[i]=abs;
sqL[i]=-abs;
}
//===========================================
return(0);
}
//**************************************************
Comments