i-GentorLSMA&EMA_v[1].1.0

Download script
Author: FX Sniper, KimIV
i-GentorLSMA&EMA_v[1].1.0

This technical indicator is designed to provide traders with a visual representation of price momentum and trend strength by analyzing the relationship between current market prices and two specific types of moving averages: the Exponential Moving Average (EMA) and the Linear Weighted Moving Average (LSMA).

The script operates using the following core logic:

Trend Analysis via EMA The tool calculates an Exponential Moving Average based on a user-defined period. Unlike standard averages, the EMA gives more weight to recent price action, making it responsive to new trends. The indicator monitors whether the current closing price is above or below this average. When the price sits above the EMA, it signifies bullish momentum; when it falls below, it indicates bearish momentum. These signals are filtered through a "distance from zero" setting to ensure that only significant movements are highlighted on the visual display.

Momentum Dynamics via LSMA In addition to the EMA, the script employs a Linear Weighted Moving Average (LSMA). The LSMA is calculated by applying a linear weighting to price data over a specific period, which allows it to react more dynamically to sudden shifts in price than a standard moving average. The logic here specifically compares the current market closing price against the calculated LSMA value.

Visual Signal Generation The primary purpose of the script is to translate these mathematical comparisons into clear visual markers:

  • It identifies specific conditions where the price crosses or stays on a certain side of these averages.
  • By comparing the "High" and "Low" boundaries relative to these two different types of averages, it helps traders see whether the current price action is overextended or following a healthy trend.
  • The script uses a dedicated visual window (separate from the main price chart) to display these four distinct data lines (EMA High/Low and LSMA High/Low), allowing for a synchronized view of how different types of moving averages are reacting to the same market data simultaneously.

In summary, this tool serves as a multi-layered filter, helping users distinguish between temporary price fluctuations and sustained trend movements by layering two different averaging methodologies onto the price action.

Indicators Used
Moving average indicator
11 Views
0 Downloads
0 Favorites
i-GentorLSMA&EMA_v[1].1.0
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                       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