LSMA_Color

This tool is designed as a visual price analysis indicator for trading platforms. It provides traders with a smoothed representation of historical price movements, specifically tailored to help identify trend directions and potential shifts in market momentum.

Core Analytical Logic

The script functions by performing a weighted calculation on historical closing prices over a specific period (defined by the user). Instead of looking at prices as isolated data points, the tool examines a "window" of past performance and applies a mathematical weighting system to them. This means that certain price points within that window are given more significance than others, allowing the indicator to produce a smoother, more refined line that filters out minor market "noise."

Visual Representation and Trend Tracking

The primary output of this logic is a dynamic line displayed on your chart. The script uses these calculations to determine whether the current momentum is moving upward or downward. It achieves this by comparing the calculated value of the current price movement against the value of the previous one.

To make this information easy to read at a glance, the tool utilizes a color-coding system:

  • Trend Detection: The script monitors whether the weighted values are increasing or decreasing from one bar to the next.
  • Visual Filtering: By intelligently switching which "buffer" is active based on these comparisons, the indicator highlights the direction of the move. If the trend turns, the script clears the previous color and applies a new one, effectively "painting" the path of the market trend.
  • Real-time Updates: The logic continuously loops through the available historical data to ensure that as new price information enters the market, the lines update to reflect the most current trend dynamics.

Summary for the Trader

In simple terms, this tool acts as a momentum filter. It takes raw, choppy price data and converts it into a smooth, color-coded trend line. By looking at the color and direction of the line, you can more easily see whether the market is currently experiencing an uptrend or a downtrend, helping you stay aligned with the primary flow of the market.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
LSMA_Color
//+------------------------------------------------------------------+
//|                                                        |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005, FX Sniper "
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 3
#property indicator_color1 Yellow      
#property indicator_color2 Green
#property indicator_color3 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
int width;
extern int Rperiod = 50;
extern int Draw4HowLongg = 10000;
int Draw4HowLong;
int shift;
int i;
int loopbegin;
double sum[];
int length;
double lengthvar;
double tmp ;
double wt[];
int c;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
//---- drawing settings
   SetIndexBuffer(2,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(0,ExtMapBuffer3);
   SetIndexBuffer(3,sum);
   SetIndexBuffer(4,wt);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
//---- initialization done
   return(0);
  }
int start()
  {   Draw4HowLong = Bars-Rperiod - 5;
      length = Rperiod;
      loopbegin = Draw4HowLong - length - 1;
      for(shift = loopbegin; shift >= 0; shift--)
      { 
         sum[1] = 0;
         for(i = length; i >= 1  ; i--)
         {
         lengthvar = length + 1;
         lengthvar /= 3;
         tmp = 0;
         tmp = ( i - lengthvar)*Close[length-i+shift];
         sum[1]+=tmp;
         }
         wt[shift] = sum[1]*6/(length*(length+1));
//========== COLOR CODING ===========================================               
       ExtMapBuffer3[shift] = wt[shift]; //red 
       ExtMapBuffer2[shift] = wt[shift]; //green
       ExtMapBuffer1[shift] = wt[shift]; //yellow
        if (wt[shift+1] > wt[shift])
        {
        ExtMapBuffer2[shift+1] = EMPTY_VALUE;
        }
        else if (wt[shift+1] < wt[shift]) 
        {
        ExtMapBuffer1[shift+1] = EMPTY_VALUE; //-1 red/greem tight
        }
        else 
        {
        ExtMapBuffer1[shift+1]=CLR_NONE;//EMPTY_VALUE;
        ExtMapBuffer2[shift+1]=CLR_NONE;//EMPTY_VALUE;
        }
    }
      return(0);
  }
//+------------------------------------------------------------------+

Comments