NRMA
Download scriptThis script is a technical analysis tool designed to visualize and identify market trends and price momentum on a trading chart. Rather than just looking at the raw price of an asset, it works by calculating "support" and "resistance" levels dynamically to help traders understand where the price is heading and how strongly it is moving.
Core Logic Overview
The indicator operates through three primary stages of calculation:
1. Trend Identification & Boundary Tracking The tool first analyzes the relationship between the current market price and a calculated threshold (the NRTR). It determines the "Trend" by looking at whether the price is moving upward or downward relative to these boundaries:
- Upward Momentum: When the price stays above certain levels, the script identifies a positive trend. It tracks the "Low Price" boundary, adjusting it based on your specific sensitivity settings (the K parameter).
- Downward Momentum: When the price falls below established levels, the script flips the trend to negative and tracks a "High Price" boundary.
- Dynamic Updating: These boundaries aren't static; they constantly shift. If the market makes a new high or low that exceeds the previous boundary, the tool automatically updates the level to reflect the new reality of the market structure.
2. Oscillation & Deviation Analysis Once the trend and boundaries are established, the script calculates an "Oscillator." This represents the percentage distance between the current market price and the tracked NRTR boundary. By measuring this gap, the tool can see how "stretched" the price is—essentially determining if the market is overextended in one direction or pulling back toward its mean.
3. Smoothing and Signal Mapping To make the data usable for human eyes, the script performs two final processing steps:
- Smoothing: It takes the raw oscillation data and applies a moving average. This removes "noise" (minor, insignificant price flickers) so that only significant trend movements remain visible.
- The Final Map: Finally, it uses these smoothed values to create a visual line on your chart. This line represents a modified version of the price action that has been filtered through the trend strength and momentum calculations.
Visual Elements
On your trading platform, this logic manifests as:
- Trend Lines: A primary visual map showing the smoothed trajectory of the price.
- Signal Markers: The script identifies specific points where the trend shifts (reversals) and marks them on the chart using arrows. These serve as visual cues for when the market has officially switched from a bullish to a bearish state, or vice versa.
Summary for the Trader
Essentially, this tool acts as an automated "filter." It looks at the raw price, determines the current trend structure, calculates how far the price has deviated from its "normal" path, smooths out the distractions, and provides you with a clear visual representation of market direction and potential reversal points.
//+------------------------------------------------------------------+
//| NRMA.mq4 |
//| Rosh |
//| http://konkop.narod.ru/nrma.htm |
//+------------------------------------------------------------------+
#property copyright "Rosh"
#property link "http://konkop.narod.ru/nrma.htm"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Gold
//---- input parameters
extern double K=1;
extern int Smooth=3;
extern double Fast=2;
extern double Sharp=2;
//---- buffers
double ExtMapBuffer1[];
double HPrice[];
double LPrice[];
double NRTR[];
double Trend[];
double Oscil[];
double NRatio[];
//-----
double F;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(7);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,"NRMA");
SetIndexBuffer(1,NRTR);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,108);
SetIndexLabel(1,"NRTR");
SetIndexBuffer(2,LPrice);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,158);
SetIndexLabel(2,"LPrice");
SetIndexBuffer(3,HPrice);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,158);
SetIndexLabel(3,"HPrice");
SetIndexBuffer(4,Trend);
SetIndexBuffer(5,Oscil);
SetIndexBuffer(6,NRatio);
SetIndexEmptyValue(4,0.0);
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexEmptyValue(2,0.0);
SetIndexEmptyValue(3,0.0);
SetIndexEmptyValue(4,0.0);
SetIndexEmptyValue(5,0.0);
SetIndexEmptyValue(6,0.0);
//SetIndexEmptyValue(0,0.0);
F=2/(1.0+Fast); //áûëî F=1/(2.0+Fast);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i;
//----
int limit,limit2;
if (counted_bars==0) limit=Bars;
if (counted_bars>0) limit=Bars-counted_bars;
limit--;
if (counted_bars==0) //
{
if (Close[limit]>Open[limit])
{
Trend[limit]=1.0;
LPrice[limit]=NormalizeDouble(Close[limit]*(1.0-K*0.01),Digits);
HPrice[limit]=0.0;
NRTR[limit]=LPrice[limit];
}
else
{
Trend[limit]=-1.0;
HPrice[limit]=NormalizeDouble(Close[limit]*(1.0+K*0.01),Digits);
LPrice[limit]=0.0;
NRTR[limit]=HPrice[limit];
}
for(i=limit;i>limit-100;i--) ExtMapBuffer1[i]=Close[i];
limit--;
}
for (i=limit;i>=0;i--)
{
if (Trend[i+1]>0)
{
if (Close[i]<NRTR[i+1])
{
Trend[i]=-1.0;
HPrice[i]=NormalizeDouble(Close[i]*(1.0+K*0.01),Digits);
LPrice[i]=0.0;
NRTR[i]=HPrice[i];
}
else
{
Trend[i]=1.0;
LPrice[i]=NormalizeDouble(Close[i]*(1.0-K*0.01),Digits);
HPrice[i]=0.0;
if (LPrice[i]>NRTR[i+1]) NRTR[i]=LPrice[i]; else NRTR[i]=NRTR[i+1];
}
}
else
{
if (Close[i]>NRTR[i+1])
{
Trend[i]=1.0;
LPrice[i]=NormalizeDouble(Close[i]*(1.0-K*0.01),Digits);
HPrice[i]=0.0;
NRTR[i]=LPrice[i];
}
else
{
Trend[i]=-1.0;
HPrice[i]=NormalizeDouble(Close[i]*(1.0+K*0.01),Digits);
LPrice[i]=0.0;
if (HPrice[i]<NRTR[i+1]) NRTR[i]=HPrice[i]; else NRTR[i]=NRTR[i+1];
}
}
//if (Trend[i]!=Trend[i+1])Print("Trend[",i,"]=",Trend[i]);
}
for (i=limit;i>=0;i--)
{
Oscil[i]=(100.0*MathAbs(Close[i]-NRTR[i])/Close[i])/K;
}
for (i=limit;i>=0;i--)
{
NRatio[i]=MathPow(iMAOnArray(Oscil,0,Smooth,0,MODE_SMA,i),Sharp);
}
for (i=limit;i>=0;i--)
{
ExtMapBuffer1[i]=ExtMapBuffer1[i+1]+NRatio[i]*F*(Close[i]-ExtMapBuffer1[i+1]);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments