iMA_TrueFibs_Below

Download script
Author: Copyright � 2005, Metaquotes
iMA_TrueFibs_Below

This tool is designed to enhance your trading charts by combining two fundamental technical analysis concepts: Moving Averages and Fibonacci-based price levels. Instead of simply showing a single trend line, it creates a dynamic "zone" or "cluster" of levels that move in real-time with the market price.

Core Functionality

The script operates by first calculating a primary Moving Average (MA). You have the flexibility to choose between several different types of averages depending on how "smooth" or "reactive" you want the data to be, including:

  • SMA (Simple Moving Average)
  • EMA (Exponential Moving Average)
  • SMMA (Smoothed Moving Average)
  • LWMA (Linear Weighted Moving Average)
  • LSMA (Least Squares Moving Average)

The Fibonacci Logic

What makes this specific script unique is what it does with that Moving Average. Rather than leaving the average as a single line, the tool uses it as a base anchor point.

From this base anchor, the script automatically projects seven distinct levels downward using specific Fibonacci numbers (21, 34, 55, 89, 144, 233, and 377). These levels are calculated based on the current "Point" value of your currency pair or asset.

How it appears on your chart

When you apply this to a chart:

  1. The Base Line: You will see a primary moving average representing the core trend.
  2. The Fibonacci Cluster: Below that main line, the script draws seven additional lines. These lines act as a visual map of potential support areas or "rebound zones" based on Fibonacci proportions.

Practical Use for Traders

By using this logic, you aren't just looking at where the price is now; you are looking at a dynamic grid of potential price targets. As the market moves and the Moving Average shifts up or down, the entire cluster of seven Fibonacci levels moves with it. This allows traders to see a "moving" support zone that adapts automatically to changing market conditions without having to manually redraw lines every time the trend changes.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
6 Views
0 Downloads
0 Favorites
iMA_TrueFibs_Below
//+------------------------------------------------------------------+
//|                                                     iMA_Fibs.mq4 |
//|                                Copyright © 2006, Robert L Hill   |
//|                                     mailto:robydoby314@yahoo.com |
//+------------------------------------------------------------------+
// This indicator allows selection of MA type and sets levels based on Fib values
// Added MAType 4 to use LSMA
#property copyright "Copyright © 2005, Metaquotes"
#property link      "mailto:metaquotes@metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Blue
#property indicator_color2 Aqua
#property indicator_color3 Aqua
#property indicator_color4 Aqua
#property indicator_color5 Aqua
#property indicator_color6 Aqua
#property indicator_color7 Aqua
#property indicator_color8 Aqua
#property indicator_width1  2
#property indicator_width2  1
#property indicator_width3  1
#property indicator_width4  1
#property indicator_width5  1
#property indicator_width6  1
#property indicator_width7  1
#property indicator_width8  1


//---- input parameters
extern int       MAPeriod=157;
extern int       MAType=1;
extern int fibo1 = 21;
extern int fibo2 = 34;
extern int fibo3 = 55;
extern int fibo4 = 89;
extern int fibo5 = 144;
extern int fibo6 = 233;
extern int fibo7 = 377;

//---- buffers
double LineBuffer[];
double Fib1[];
double Fib2[];
double Fib3[];
double Fib4[];
double Fib5[];
double Fib6[];
double Fib7[];


//---- variables
int    MAMode;
string strMAType;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
   //---- indicators
   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,LineBuffer);
   SetIndexDrawBegin(0,MAPeriod);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Fib1);
   SetIndexDrawBegin(1,MAPeriod);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Fib2);
   SetIndexDrawBegin(2,MAPeriod);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,Fib3);
   SetIndexDrawBegin(3,MAPeriod);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,Fib4);
   SetIndexDrawBegin(4,MAPeriod);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,Fib5);
   SetIndexDrawBegin(5,MAPeriod);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,Fib6);
   SetIndexDrawBegin(6,MAPeriod);
   SetIndexStyle(7,DRAW_LINE);
   SetIndexBuffer(7,Fib7);
   SetIndexDrawBegin(7,MAPeriod);
   //---- name for DataWindow and indicator subwindow label
   IndicatorShortName( strMAType+ " (" +MAPeriod + ") ");
   
   //----
switch (MAType)
   {
      case 1: strMAType="EMA"; MAMode=MODE_EMA; break;
      case 2: strMAType="SMMA"; MAMode=MODE_SMMA; break;
      case 3: strMAType="LWMA"; MAMode=MODE_LWMA; break;
      case 4: strMAType="LSMA"; break;
      default: strMAType="SMA"; MAMode=MODE_SMA; break;
   }
   //----
   return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   //---- 
   
   //----
   return(0);
}

double LSMA(int Rperiod, int shift)
{
   int i;
   double sum;
   int length;
   double lengthvar;
   double tmp;
   double wt;

   length = Rperiod;
 
   sum = 0;
   for(i = length; i >= 1  ; i--)
   {
     lengthvar = length + 1;
     lengthvar /= 3;
     tmp = 0;
     tmp = ( i - lengthvar)*Close[length-i+shift];
     sum+=tmp;
    }
    wt = sum*6/(length*(length+1));
    
    return(wt);
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   double MA;
   int limit;
   int counted_bars = IndicatorCounted();
   //---- check for possible errors
   if (counted_bars<0) return(-1);
   //---- last counted bar will be recounted
   if (counted_bars>0) counted_bars--;
   limit = Bars - counted_bars;

   for(int i=limit; i>=0; i--)
   {
      if (MAType == 4)
      {
        MA = LSMA(MAPeriod,i);
      }
      else
      {
        MA = iMA(NULL,0,MAPeriod,0,MAMode,PRICE_CLOSE,i);
      }
     
      
      LineBuffer[i] = MA;
      Fib1[i] = MA - fibo1*Point;
      Fib2[i] = MA - fibo2*Point;
      Fib3[i] = MA - fibo3*Point;
      Fib4[i] = MA - fibo4*Point;
      Fib5[i] = MA - fibo5*Point;
      Fib6[i] = MA - fibo6*Point;
      Fib7[i] = MA - fibo7*Point;

   }
   
   //----
   return(0);
}
//+------------------------------------------------------------------+

Comments