sell zone fibs

Download script
Author: Copyright � 2007, MetaQuotes Software Corp.
sell zone fibs

This script is a specialized technical analysis tool designed to identify potential "sell zones" on a trading chart by combining moving average trends with specific price offsets. It provides visual guidance for traders looking to identify areas where price might encounter resistance or enter a downward trend.

Core Operational Logic

1. Moving Average Foundation The primary engine of this script is a customizable Moving Average (MA). This serves as the "anchor" line for all other calculations. The user can choose from several different calculation methods to determine how the average price is smoothed:

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

The script specifically targets the Low Price of the candles to calculate these averages, focusing on the lower boundary of price action.

2. Dynamic Fibonacci Offsets Unlike a standard moving average which only shows one line, this script generates seven additional "Fibonacci" lines relative to the main moving average.

Instead of using static Fibonacci ratios (like 0.618), these lines are calculated by taking the value of the Moving Average and subtracting a specific number of price points (based on the user's input). This creates a "zone" or a series of parallel boundaries trailing just below the main average line.

3. Visual Execution When applied to a chart, the script renders:

  • A Primary Line: Representing the core Moving Average calculation.
  • Seven Supporting Lines: These appear as dotted lines positioned at precise intervals below the primary line.

How it functions in a trading context

By plotting these seven levels simultaneously, the script creates a visual "map" of potential price behavior. Because these lines are derived directly from a moving average, they move dynamically with the market. When the price interacts with this cluster of lines, traders can use them to identify:

  • Support/Resistance Clusters: Areas where price frequently stalls or reverses.
  • Trend Boundaries: A visual guide to see how far the price is "stretched" away from its moving average.
  • Entry Zones: Defining a specific area (rather than a single line) to look for sell opportunities as price enters the "Fibonacci zone" created by the script.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
sell zone fibs
//+------------------------------------------------------------------+
//|                                               sell zone fibs.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Black
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_color7 Red
#property indicator_color8 Red
#property indicator_width1  1
#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=55;
extern int       MAType=2;
extern int fibo1 = 1;
extern int fibo2 = 2;
extern int fibo3 = 3;
extern int fibo4 = 4;
extern int fibo5 = 5;
extern int fibo6 = 6;
extern int fibo7 = 7;

//---- 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_NONE);
   SetIndexBuffer(0,LineBuffer);
   SetIndexDrawBegin(0,MAPeriod);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Fib1);
   SetIndexDrawBegin(1,MAPeriod);
   SetIndexStyle(2,DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(2,Fib2);
   SetIndexDrawBegin(2,MAPeriod);
   SetIndexStyle(3,DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(3,Fib3);
   SetIndexDrawBegin(3,MAPeriod);
   SetIndexStyle(4,DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(4,Fib4);
   SetIndexDrawBegin(4,MAPeriod);
   SetIndexStyle(5,DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(5,Fib5);
   SetIndexDrawBegin(5,MAPeriod);
   SetIndexStyle(6,DRAW_LINE,STYLE_DOT,1);
   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_LOW,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