NRTR 1

This script functions as a visual trend-tracking indicator designed to help traders identify the direction of market momentum by highlighting significant shifts in price movement. Rather than just showing where the price is currently, it attempts to define the "path" of the trend based on historical behavior and specific mathematical boundaries.

How the Logic Works

1. Establishing the Baseline (The Range) The indicator starts by looking at a specific number of previous bars (set by the user) to calculate an average price range. It measures the distance between the highest and lowest points reached during that period. This "Average Range" acts as a ruler; it determines how much the price needs to move before the script considers a trend change to be significant.

2. Dynamic Scaling The script includes a specific adjustment for certain currency pairs (like USDJPY, GBPJPY, and EURJPY). Because these assets often have different decimal structures, the logic automatically scales the "ruler" mentioned above to ensure that the indicator remains accurate and readable regardless of which currency you are trading.

3. Identifying the Trend Direction The logic operates by constantly comparing the current closing price against a moving reference point:

  • Uptrend Detection: If the price is moving upward, the script tracks the highest price reached. It creates a "buffer zone" below that high point. If the price stays above this buffer, the trend remains bullish (upward).
  • Downtrend Detection: Conversely, if the price is moving downward, it tracks the lowest price reached and creates a "buffer zone" above that low point. If the price stays below this zone, the trend remains bearish (downward).

4. Signaling a Reversal The core "intelligence" of the script lies in how it handles a reversal. The trend only flips when the price breaks through its own buffer zone.

  • If you are in an uptrend and the price drops significantly enough to pierce the lower buffer, the script immediately switches its logic to track a downtrend.
  • If you are in a downtrend and the price climbs high enough to pierce the upper buffer, it switches back to tracking an uptrend.

5. Visual Output The results are displayed on your chart as specific markers (arrows). The logic ensures that only one trend is active at any given time:

  • When the market is moving up based on these rules, one set of markers appears.
  • When the market flips to a downward move, the first set disappears and the second set takes over.

In simple terms, this script filters out minor "noise" in the market. It ignores small price fluctuations and only updates its trend direction when the price movement is large enough to suggest a genuine shift in momentum.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
NRTR 1
//+------------------------------------------------------------------+
//|                                                         NRTR.mq4 |
//|                                                                  |
//|                                        Ramdass - Conversion only |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Violet
//---- input parameters
extern int AveragePeriod=10;
extern int CountBars=300;
//---- buffers
double value1[];
double value2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,158);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,158);
   SetIndexBuffer(0,value1);
   SetIndexBuffer(1,value2);
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| NRTR                                                             |
//+------------------------------------------------------------------+
int start()
  {
   if (CountBars>Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars+1);
   SetIndexDrawBegin(1,Bars-CountBars+1);
   int i,counted_bars=IndicatorCounted();
   double value;
   double trend=0,dK,AvgRange,price;
//----
   if(Bars<=AveragePeriod) return(0);
//---- initial zero
   if(counted_bars<1)
   {
      for(i=1;i<=AveragePeriod;i++) value1[Bars-i]=0.0;
      for(i=1;i<=AveragePeriod;i++) value2[Bars-i]=0.0;
   }


AvgRange=0;
for (i=1 ; i<=AveragePeriod ; i++) AvgRange+= MathAbs(High[i]-Low[i]);
if (Symbol() == "USDJPY" || Symbol() == "GBPJPY" || Symbol() == "EURJPY")
{dK = (AvgRange/AveragePeriod)/100;}
else {dK = AvgRange/AveragePeriod;}

if (Close[CountBars-1] > Open[CountBars-1])
   {
   value1[CountBars - 1] = Close[CountBars - 1] * (1 - dK);
   trend = 1; value2[CountBars - 1] = 0.0;
   }
if (Close[CountBars-1] < Open[CountBars-1])  {
   value2[CountBars - 1] = Close[CountBars - 1] * (1 + dK);
   trend = -1; value1[CountBars - 1] = 0.0;
   }
//----
   i=CountBars-1;
   while(i>=0)
     {
value1[i]=0; value2[i]=0;
if (trend >= 0)
       {
       if (Close[i] > price) price = Close[i];
       value = price * (1 - dK);
       if (Close[i] < value)
          {
          price = Close[i];
          value = price * (1 + dK);
          trend = -1;
          }
       } 
    else
       { 
    if (trend <= 0)
       {
       if (Close[i] < price) price = Close[i];
       value = price * (1 + dK);
       if (Close[i] > value) 
          {
          price = Close[i];
          value = price * (1 - dK);
          trend = 1;
          }
       }
       }
if (trend == 1)  {value1[i]=value; value2[i]=0.0;}
if (trend == -1)  {value2[i]=value; value1[i]=0.0;}

      i--;
     }
   return(0);
  }

Comments