Author: Copyright � 2008, Bookkeeper
NavelEMA

This tool is designed to provide a customized visual representation of price trends on your trading charts. It functions as a modified moving average, which helps traders identify the general direction and momentum of the market by smoothing out short-term price fluctuations.

How the Logic Works

1. Custom Price Calculation (The "Navel" Basis) Unlike standard indicators that might rely solely on the closing price of a candle, this script uses a unique weighted average to determine each point of data. It takes into account four different pieces of information from every price bar:

  • The Closing Price (given the highest weight)
  • The Opening Price
  • The Highest Price reached
  • The Lowest Price reached

By combining these four elements into a single weighted value, the script creates a more balanced "center of gravity" for each price candle.

2. Smoothing and Trend Tracking Once the specific price for each bar is calculated, the script applies an Exponential Moving Average (EMA) logic. Instead of just plotting the raw data points, it blends the current value with previous values.

This creates a "smoothing" effect where the resulting line flows more fluidly across the chart. The intensity of this smoothing is determined by the "MA_Period" setting; a higher period will result in a smoother, slower-moving line, while a lower period will make the line more reactive to recent price changes.

3. Visual Positioning The indicator includes a shifting mechanism. This allows the resulting trend line to be offset forward or backward on the chart visually, providing flexibility for traders who prefer to see the data aligned differently relative to the current live candle.

Summary for the User

Essentially, this script looks at the "heart" of each price candle (the weighted average of its high, low, open, and close) and then connects those points using an exponential smoothing formula. The result is a red trend line that helps you see the underlying market direction while filtering out the "noise" of erratic price movements.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
NavelEMA
//+------------------------------------------------------------------+
//|                                                     NavelEMA.mq4 |
//+------------------------------------------------------------------+
//|   Íà áàçå (êîä ïîñòàðàëñÿ ñîõðàíèòü, êàê â îðèãèíàëå):
//|                                        Custom Moving Average.mq4 
//|                      Copyright © 2004, MetaQuotes Software Corp. 
//|                                       http://www.metaquotes.net/ 
//|   Âûçîâ:
//|   Val=iCustom(symbol,
//|               timeframe,
//|               "NavelEMA",
//|               MA_Period,
//|               MA_Shift,
//|               0,
//|               NumBar);
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Bookkeeper"
#property link      "yuzefovich@gmail.com"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
extern int MA_Period=13;
extern int MA_Shift=0;
double ExtMapBuffer[];
int ExtCountedBars=0;
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexShift(0,MA_Shift);
   if(MA_Period<2) MA_Period=13;
   SetIndexBuffer(0,ExtMapBuffer);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   if(Bars<=MA_Period) return(0);
   ExtCountedBars=IndicatorCounted();
   if (ExtCountedBars<0) return(-1);
   if (ExtCountedBars>0) ExtCountedBars--;
   double pr=2.0/(MA_Period+1);
   int    pos=Bars-2;
   if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
   while(pos>=0)
     {
      if(pos==Bars-2) ExtMapBuffer[pos+1]=Navel(pos+1);
      ExtMapBuffer[pos]=Navel(pos)*pr+ExtMapBuffer[pos+1]*(1-pr);
 	   pos--;
     }
   return(0);
  }
//+------------------------------------------------------------------+
double Navel(int bar)
{
   double price=(Close[bar]*5+Open[bar]*2+High[bar]+Low[bar])/9;
   return(price);
}

Comments