Author: xbox forex
xb4b

This tool is designed to provide traders with a visual representation of price trends and momentum by analyzing historical price data. It operates by calculating two distinct mathematical layers over the market chart to help identify the direction of price movement and potential turning points.

Core Functionality

The script works by processing recent closing prices through a series of calculations to generate two primary signals:

  • Trend Smoothing: The tool first establishes a base trend line. It looks at a specific window of historical data (defined by the "Rperiod" setting) and applies a weighted mathematical formula to smooth out minor market "noise." This helps in seeing the broader direction of the price without being distracted by every small fluctuation.
  • Momentum & Projection: Building upon that smoothed trend, the tool calculates a secondary line. This second line acts as a dynamic projection, comparing the current moving average against its own past values to determine the strength and speed of the market's movement.

Visual Logic and Interpretation

The script translates these complex calculations into visual cues on your trading chart:

  • Trend Identification: By plotting these two lines, the tool allows you to see how the current price momentum relates to the overall trend. When the lines move in harmony, it typically signifies a strong, established trend.
  • Signal Filtering: The logic includes a specific condition where certain data points are hidden (set to "Empty"). This is intended to filter out weak signals or contradictory information. Specifically, the tool ensures that the primary visual indicator only appears when the calculated price levels meet a specific mathematical threshold, reducing "market clutter" and helping you focus on more significant movements.

User Configuration

The behavior of the script can be adjusted through two main settings:

  1. Rperiod: This determines how far back into the past the tool looks to calculate the base trend. Increasing this will make the lines smoother and slower; decreasing it will make them more reactive to recent price changes.
  2. LSMA_Period: This influences the smoothing of the projection line, affecting how "tightly" the indicator follows the primary trend.

In summary, this script serves as a visual aid to distinguish between temporary price spikes and sustained market trends, providing a cleaner perspective on where the market momentum is heading.

Miscellaneous
Implements a curve of type %1
11 Views
1 Downloads
0 Favorites
xb4b

#property copyright "xbox forex"
#property link      "http://community.strangled.net"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Black
#property indicator_color3 Blue
#property indicator_color4 Black

double g_ibuf_76[];
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
extern int Rperiod = 18;
extern int LSMA_Period = 20;
int gi_104;
int gi_108;
int gi_112;
int gi_116;
int gi_120;
int gi_124;
int gi_128;
double gd_132;
double gd_140;
double g_ibuf_156[];
double g_ibuf_160[];
double gda_unused_164[];
double g_ibuf_168[];
double gda_unused_172[];

int init() {
  
   IndicatorBuffers(7);
   SetIndexBuffer(0, g_ibuf_76);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexBuffer(1, g_ibuf_80);
   SetIndexStyle(1, DRAW_NONE);
   SetIndexBuffer(2, g_ibuf_84);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexBuffer(3, g_ibuf_88);
   SetIndexStyle(3, DRAW_NONE);
   SetIndexBuffer(4, g_ibuf_160);
   SetIndexBuffer(5, g_ibuf_156);
   SetIndexBuffer(6, g_ibuf_168);
   return (0);
}

int start() {

   gi_104 = Bars - Rperiod - 5;
   gi_124 = Rperiod;
   gi_128 = LSMA_Period;
   gi_120 = gi_104 - gi_124 - 1;
   for (gi_108 = gi_120; gi_108 >= 0; gi_108--) {
      g_ibuf_160[1] = 0;
      for (gi_112 = gi_124; gi_112 >= 1; gi_112--) {
         gd_132 = gi_124 + 1;
         gd_132 /= 3.0;
         gd_140 = 0;
         gd_140 = (gi_112 - gd_132) * (Close[gi_124 - gi_112 + gi_108]);
         g_ibuf_160[1] += gd_140;
      }
      g_ibuf_156[gi_108] = 6.0 * g_ibuf_160[1] / (gi_124 * (gi_124 + 1));
      gi_116 = gi_108;
      g_ibuf_168[gi_108] = g_ibuf_156[gi_116 + 1] + 2.0 * (g_ibuf_156[gi_116] - (g_ibuf_156[gi_116 + 1])) / (gi_128 + 1);
      g_ibuf_76[gi_108] = g_ibuf_156[gi_108];
      g_ibuf_80[gi_108] = g_ibuf_168[gi_108];
      g_ibuf_84[gi_108] = g_ibuf_156[gi_108];
      g_ibuf_88[gi_108] = g_ibuf_168[gi_108];
      if (g_ibuf_156[gi_108] < g_ibuf_168[gi_108]) {
         g_ibuf_88[gi_108] = EMPTY_VALUE;
         g_ibuf_84[gi_108] = EMPTY_VALUE;
      }
   }
   return (0);
}


Comments