LSMA_ind_01_v1
Download scriptThis tool is designed to analyze price movements and provide a visual representation of market momentum on your trading chart. Instead of simply looking at the current price, the script performs a sophisticated calculation over a specific window of time to determine the underlying trend of the market.
How the Logic Works
The core functionality of this script relies on a weighted mathematical approach. It looks back at a set number of historical data points (the "period") and assigns different levels of importance to each price point. This ensures that more recent price action carries more significance in the calculation than older data, allowing the tool to react more dynamically to new market information while still maintaining a view of the broader trend.
Visual Indicators
The script translates these complex calculations into a color-coded visual system on your chart:
- Momentum Tracking: The tool continuously calculates a weighted value based on price fluctuations. As the market moves, this value shifts up or down.
- Dynamic Color Coding: To make the data easy to read at a glance, the script changes the appearance of the lines based on the direction of the trend:
- When the calculated momentum is moving in one direction, the tool highlights it with a specific color (such as Green).
- When the momentum reverses or shifts downward, the colors update accordingly (switching to Red or Yellow).
- If there is no significant change in the momentum, the lines remain neutral.
Summary for the Trader
Essentially, this script acts as a trend-smoothing filter. It filters out "market noise" by weighing historical prices against current ones, providing you with a clear visual signal of whether the current market energy is trending upwards, downwards, or remaining stable. By following the color shifts on your screen, you can better identify potential reversals and the strength of the prevailing trend in real-time.
//+------------------------------------------------------------------+
//| |
//| 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[];
extern int Rperiod = 48;
extern int Draw4HowLong = 500;
//----- variables
int c;
int i;
int length;
double lengthvar;
int loopbegin;
int pos;
int width;
// arrays
double sum[];
double tmp ;
double wt[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//2 additional buffers are used for counting.
IndicatorBuffers(5);
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);
return(0);
}
int start()
{
length = Rperiod;
loopbegin = Draw4HowLong - length - 1;
for(pos = loopbegin; pos >= 0; pos--)
{
sum[1] = 0;
for(i = length; i >= 1 ; i--)
{
lengthvar = length + 1;
lengthvar /= 3;
tmp = 0;
tmp = ( i - lengthvar)*Close[length-i+pos];
sum[1]+=tmp;
}
wt[pos] = sum[1]*6/(length*(length+1));
//========== COLOR CODING ===========================================
// 1 Yellow
// 2 Green
// 3 Red
ExtMapBuffer3[pos] = wt[pos]; //red
ExtMapBuffer2[pos] = wt[pos]; //green
ExtMapBuffer1[pos] = wt[pos]; //yellow
if (wt[pos+1] > wt[pos])
{
ExtMapBuffer2[pos+1] = EMPTY_VALUE;
}
else if (wt[pos+1] < wt[pos])
{
ExtMapBuffer1[pos+1] = EMPTY_VALUE; //-1 red/greem tight
}
else
{
ExtMapBuffer1[pos+1]=CLR_NONE;//EMPTY_VALUE;
ExtMapBuffer2[pos+1]=CLR_NONE;//EMPTY_VALUE;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments