ma_Navel_price

Download script
Author:
ma_Navel_price

This tool is designed to provide a specialized moving average on your trading charts, offering a way to smooth out price data based on specific mathematical calculations. Rather than relying solely on standard closing prices, this script allows you to choose between different ways of defining "price" before calculating the average.

How the Logic Works

The script operates in two distinct stages: defining the base price and then applying the moving average.

1. Price Definition Selection The core logic relies on a setting that determines which data point from each candle is used for the calculation. You can choose between several methods:

  • Standard Calculation: If you select a standard setting (under index 7), the script calculates an average of the four main price points: the Open, High, Low, and Close.
  • Navel Price Calculation: This is a specialized formula (index 8) that gives more weight to the Close and Open prices while still factoring in the High and Low. It uses a weighted calculation where the closing price carries the most influence, helping to identify a "navel" or center point of the price action.
  • Standard Price Points: If other settings are chosen, the script defaults to using standard market data (such as just the Close) for its calculations.

2. Moving Average Processing Once the script determines which price point to use for each candle, it then applies a Moving Average (MA).

  • If you are using a standard price point, the script calculates the moving average normally across the chart.
  • If you have chosen one of the custom calculations (like the Navel Price), the script first builds a secondary internal list of these "custom prices" and then runs the moving average calculation specifically on that list.

Summary for the User

In simple terms, this indicator gives you more control over how your trend lines are drawn. Instead of just following the closing price, it allows you to use weighted averages—specifically the Navel SMA—to create a smoother, more nuanced trend line that reflects a specific mathematical balance of the candle's range.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
ma_Navel_price
//+------------------------------------------------------------------+
//|                                                   ma Navel price |
//|                                                                  |
//+------------------------------------------------------------------+
//ideas: Bookkeeper (08.01.2009) BO.mq4 NavelSMA.mq4   
//http://codebase.mql4.com/ru/5115 
//2009fxtsd     ki

#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers    1
#property indicator_color1     Green
#property indicator_width1     1




extern int ma_period  =  14;
extern int ma_method  =  0;
extern int ma_shift   =  0;
extern int ma_price   =  8;


extern string   note__Price   ="0C 1O 2H 3L 4Md 5Tp 6WghC: 4Md(HL/2),5Tp(HLC/3),6Wgh(HLCC/4)";
extern string   _______       ="7 HA close: haC =(O+H+L+C)/4";
extern string   ___           ="8 Navel SMA price: nvC =(2O+H+L+5C)/9";




double buffer1[];
double price[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+


int init()
{

      IndicatorBuffers(2); 

      SetIndexStyle(0,DRAW_LINE);
      SetIndexShift(0,ma_shift);


      SetIndexBuffer(0,buffer1);
      SetIndexBuffer(1,price);
  
   
   string shortnme;
   shortnme = "MA Navel Price ("+ma_period+","+ma_method+", pr "+ma_price+") ";
   
   IndicatorShortName(shortnme);  
   SetIndexLabel(0,shortnme);


   return(0);
}

int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+


int start()
{
   int counted_bars=IndicatorCounted();
   int limit,i;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;




   for(i=limit; i>=0; i--)
     
    {                                                 
         if (ma_price<0 || ma_price>8)    ma_price=0;
    
      
         if (ma_price==7)       price[i]=(Close[i]+Open[i]+High[i]+Low[i])/4;  
         if (ma_price==8)       price[i]=(Close[i]*5+Open[i]*2+High[i]+Low[i])/9;

    }
      
         for(i=limit; i>=0; i--) 
         {
      
  
            if (ma_price<7)   buffer1[i] = iMA(NULL,0,ma_period,0,ma_method,ma_price,i);
            else              buffer1[i] = iMAOnArray(price,0,ma_period,0,ma_method,i);
             
         }
         


  
   return(0);
}

Comments