i-GentorLSMA&EMA_v[1].0.2

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

This script is a specialized financial analysis tool designed to help traders identify potential momentum shifts and trend directions by comparing current market prices against two distinct types of moving averages. It provides visual cues on a chart to highlight when the price action deviates from established historical norms.

Core Logic Overview

The tool operates by calculating two specific mathematical models—the Exponential Moving Average (EMA) and the Linear Weighted Moving Average (LSMA)—and monitoring how the current market price interacts with them.

1. Trend Identification (EMA)

The script first looks at the Exponential Moving Average, which gives more importance to recent price data. It acts as a baseline for the general trend:

  • Upper Bound Tracking: When the price stays above this average, the script identifies a specific condition (High EMA).
  • Lower Bound Tracking: When the price falls below this average, it identifies the opposite condition (Low EMA). Essentially, this part of the logic helps filter out "noise" and focuses on whether the current price is currently leading or trailing the recent momentum.

2. Momentum Analysis (LSMA)

The second layer of logic uses a Linear Weighted Moving Average. Unlike a standard average that treats all days equally, this calculation applies a progressively heavier weight to the most recent prices. This makes it highly sensitive to sudden changes in price velocity.

  • Price Comparison: The script calculates a weighted value and compares it directly against the current closing price.
  • Signal Filtering: It looks for "crossovers" or breaches where the price moves significantly above or below this weighted average.

How it Works Together

The indicator does not just plot lines; it acts as a filter. By comparing the live price against both the smoothed trend (EMA) and the weighted momentum (LSMA), the script highlights specific moments of interest.

Instead of cluttering your screen with constant data, the logic is designed to leave "empty" space unless the specific price conditions are met. This allows a trader to quickly see where the market is reacting strongly to moving averages, potentially signaling areas of overextension or significant trend reversals.

Indicators Used
Moving average indicator
15 Views
0 Downloads
0 Favorites
i-GentorLSMA&EMA_v[1].0.2
//+------------------------------------------------------------------+
//|                                       i-GentorLSMA&EMA_v.0.2.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        |
//+------------------------------------------------------------------+
#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

//---- Áóôåðû èíäèêàòîðà ---------------------------------------------
double LineHighEMA[];
double LineLowEMA[];
double LSMABuffer1[];
double LSMABuffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init() {
  IndicatorDigits(2);

  SetIndexStyle (0, DRAW_LINE, STYLE_SOLID, 3);
  SetIndexBuffer(0, LineHighEMA);
  SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, 3);
  SetIndexBuffer(1, LineLowEMA);
  SetIndexBuffer(2, LSMABuffer1);
  SetIndexStyle (2, DRAW_LINE, STYLE_SOLID, 3);
  SetIndexBuffer(3, LSMABuffer2);
  SetIndexStyle (3, DRAW_LINE, STYLE_SOLID, 3);
  Comment("");
}

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
void deinit() {
  Comment("");
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
  int i, shift, counted_bars = IndicatorCounted();
  int Draw4HowLong, loopbegin;
  double sum, lengthvar, tmp, wt;

  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] = -1;
    LineHighEMA[shift] = -1;

    double EmaValue = iMA(NULL, 0, EMAPeriod, 0, MODE_EMA, PRICE_TYPICAL, shift);
    if (Close[shift] > EmaValue) LineHighEMA[shift] = EMPTY_VALUE;
    else
      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] = 1;
    LSMABuffer2[shift] = 1;

    if (wt > Close[shift]) LSMABuffer2[shift] = EMPTY_VALUE;
    else
      if (wt < Close[shift]) LSMABuffer1[shift] = EMPTY_VALUE;
  }
}
//+------------------------------------------------------------------+

Comments