i-GentorLSMA&EMA_v[1]2.1.0
Download scriptThis indicator is designed to help traders visualize price momentum and trend direction by analyzing two distinct types of moving averages: the Exponential Moving Average (EMA) and the Linear Weighted Moving Average (LSMA). Instead of just showing you lines on a chart, this tool focuses on identifying specific "breakout" moments where current price action moves significantly relative to these averages.
Core Logic and Components
The script operates by calculating two primary layers of data:
1. EMA Dynamic Filtering The indicator monitors the Exponential Moving Average (EMA), which gives more weight to recent price data. It checks the relationship between the current closing price and this average.
- If the price is trading above the EMA, it recognizes a bullish sentiment.
- If the price is trading below the EMA, it recognizes a bearish sentiment.
- The tool specifically highlights these conditions by identifying when the price "clears" the average, helping to filter out market noise.
2. LSMA Weighted Analysis Simultaneously, the script calculates a Linear Weighted Moving Average (LSMA). Unlike a standard average, the LSMA applies a linear weighting to each data point in a period, making it highly sensitive to very recent price changes.
- The logic performs a specific mathematical summation of these weighted prices over a set duration.
- It then compares this resulting weighted value against the current market price.
How It Works Together
The primary goal of this script is to detect "gaps" or shifts in momentum. Rather than providing a continuous line, the indicator logic focuses on the distance between the price and these averages:
- Distance Tracking: The script uses a user-defined "distance from zero" parameter. This acts as a threshold to determine how significant a movement is.
- Signal Detection: By comparing the current price against both the EMA and the LSMA weighted values, the indicator highlights specific points where the price is moving aggressively in one direction or the other.
Summary for the Trader
In practical terms, this tool serves as a visual filter. It looks for confirmation between two different types of averages (one that respects recent history and one that weights the very latest moves heavily). When the price behaves in a way that aligns with these specific mathematical conditions—specifically moving away from or crossing these calculated thresholds—it provides the trader with a clearer picture of the current trend's strength.
//+------------------------------------------------------------------+
//| i-GentorLSMA&EMA_v.1.0.mq4 |
//| FX Sniper, KimIV |
//| 2005.08.20 KimIV v.0.0 |
//| Ñîåäèíèë â LSMA è EMA |
//| 2005.08.20 KimIV v.0.2 |
//| Ñèíõðîíèçèðîâàë íóìåðàöèþ âåðñèé ñ i-GentorCCIM_v.0.2.mq4 |
//| 2005.08.21 KimIV v.1.0 |
//| Âûíåñ âî âíåøíèé ïàðàìåòð ðàññòîÿíèå îò íóëÿ äëÿ ÅÌÀ è LSMA |
//+------------------------------------------------------------------+
#property copyright "FX Sniper, KimIV"
#property link "http://www.kimiv.ru"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Yellow
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Lime
//------- Âíåøíèå ïàðàìåòðû ------------------------------------------
extern int EMAPeriod = 34; // Ïåðèîä ÅÌÀ
extern int LSMAPeriod = 25; // Ïåðèîä LSMA
extern int FromZero = 3; // Ðàññòîÿíèå îò íóëåâîãî óðîâíÿ
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double LineHighEMA[];
double LineLowEMA[];
double LSMABuffer1[];
double LSMABuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init() {
IndicatorDigits(2);
SetIndexBuffer(0, LineHighEMA);
SetIndexLabel (0, "EMA âûøå öåíû");
SetIndexStyle (0, DRAW_LINE, STYLE_SOLID, 3);
SetIndexBuffer(1, LineLowEMA);
SetIndexLabel (1, "EMA íèæå öåíû");
SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, 3);
SetIndexBuffer(2, LSMABuffer1);
SetIndexLabel (2, "LSMA âûøå öåíû");
SetIndexStyle (2, DRAW_LINE, STYLE_SOLID, 3);
SetIndexBuffer(3, LSMABuffer2);
SetIndexLabel (3, "LSMA íèæå öåíû");
SetIndexStyle (3, DRAW_LINE, STYLE_SOLID, 3);
Comment("");
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
double sum, lengthvar, tmp, wt;
int i, shift, counted_bars = IndicatorCounted();
int Draw4HowLong, loopbegin;
if (counted_bars<0) return;
if (counted_bars>0) counted_bars--;
counted_bars = Bars - counted_bars;
for (shift=0; shift<counted_bars; shift++) {
LineLowEMA[shift] = -FromZero;
LineHighEMA[shift] = -FromZero;
double EmaValue = iMA(NULL, 0, EMAPeriod, 0, MODE_EMA, PRICE_TYPICAL, shift);
if (Close[shift]>EmaValue) LineHighEMA[shift] = EMPTY_VALUE;
if (Close[shift]<EmaValue) LineLowEMA[shift] = EMPTY_VALUE;
}
Draw4HowLong = Bars-LSMAPeriod - 5;
loopbegin = Draw4HowLong - LSMAPeriod - 1;
for(shift=loopbegin; shift>=0; shift--) {
sum = 0;
for (i=LSMAPeriod; i>=1; i--) {
lengthvar = LSMAPeriod + 1;
lengthvar /= 3;
tmp = 0;
tmp = (i - lengthvar) * Close[LSMAPeriod-i+shift];
sum+=tmp;
}
wt = sum * 6 / (LSMAPeriod * (LSMAPeriod + 1));
LSMABuffer1[shift] = FromZero;
LSMABuffer2[shift] = FromZero;
if (wt>Close[shift]) LSMABuffer2[shift] = EMPTY_VALUE;
if (wt<Close[shift]) LSMABuffer1[shift] = EMPTY_VALUE;
}
}
//+------------------------------------------------------------------+
Comments