i-GentorLSMA&EMA_v[1]

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

This indicator is designed to help traders visualize 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). By plotting these relationships in a separate window, it allows for a clearer view of price momentum and trend direction.

Core Functionality

The tool processes price data to identify when the market is trading above or below specific calculated thresholds. It focuses on two distinct components:

1. EMA Analysis (Exponential Moving Average) The script calculates an EMA based on a user-defined period. Rather than showing the average itself, it acts as a "filter":

  • When the market price is higher than the EMA value, the indicator marks a high point.
  • When the market price falls below the EMA value, it marks a low point. This helps in identifying basic trend shifts based on the exponential weighting of recent prices.

2. LSMA Analysis (Linear Weighted Moving Average) The script also calculates an LSMA, which gives more weight to the most recent price data. The logic for this section is structured to detect crossovers:

  • It performs a specific mathematical weighting calculation to determine the LSMA value.
  • It then compares this value against the current closing price.
  • Depending on whether the price is above or below this weighted average, it plots corresponding signals.

Visual Logic and Customization

The indicator simplifies complex data into visual cues:

  • Dynamic Filtering: The script uses a "Distance from Zero" parameter. This creates a baseline offset, ensuring that the signals are plotted clearly and are not clustered directly on a zero axis, making them easier for the human eye to track during live trading.
  • Trend Visualization: By separating the high and low signals into different buffers (colors), the tool provides a distinct visual representation of market strength. You can see at a glance whether the price is maintaining a position of strength (above the averages) or weakness (below the averages).

Summary for the User

Essentially, this tool acts as a momentum filter. Instead of cluttering your main chart with dozens of lines, it takes the technical data from the EMA and LSMA and "translates" them into high/low markers in a separate window. This allows you to observe trend confirmation and price action dynamics more cleanly, helping you identify whether the current market move has enough strength to stay above (or below) key moving average thresholds.

Indicators Used
Moving average indicator
9 Views
0 Downloads
0 Favorites
i-GentorLSMA&EMA_v[1]
//+------------------------------------------------------------------+
//|                                       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 DodgerBlue
#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, 5);
  SetIndexBuffer(1, LineLowEMA);
  SetIndexLabel (1, "EMA íèæå öåíû");
  SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, 5);
  SetIndexBuffer(2, LSMABuffer1);
  SetIndexLabel (2, "LSMA âûøå öåíû");
  SetIndexStyle (2, DRAW_LINE, STYLE_SOLID, 5);
  SetIndexBuffer(3, LSMABuffer2);
  SetIndexLabel (3, "LSMA íèæå öåíû");
  SetIndexStyle (3, DRAW_LINE, STYLE_SOLID, 5);
  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