Overview
The FibonacciPivot script is a technical analysis tool designed to project potential support and resistance levels on your trading charts. It automates the calculation of various price milestones by blending two well-known financial concepts: Fibonacci Retracements and Pivot Points, specifically utilizing data from previous daily price action.
Core Logic and Functionality
1. Data Foundation (Daily Reference) The tool operates by looking "backward" at the previous day's market activity. It automatically identifies three key pieces of information from the preceding 24-hour period:
- High: The highest price reached during the day.
- Low: The lowest price reached during the day.
- Close: The final price at which the market settled.
By calculating the difference between the High and the Low, the script determines the total "range" or volatility of the previous day's movement.
2. Dynamic Level Calculation Instead of using static numbers, the script takes the Closing Price of the previous day as a baseline (the anchor). It then projects various levels above and below that price based on the previous day's range.
These levels are calculated using specific Fibonacci ratios (such as 0.236, 0.382, 0.500, 0.618, etc.). This means the script is essentially telling you: "Based on how much the market moved yesterday, where might it find balance today?"
3. The "Koeff" (Coefficient) Modifier
A unique feature of this specific script is the koeff variable. This acts as a multiplier that allows you to "stretch" or "squeeze" the projected levels:
- Squeeze: Using a lower coefficient brings the levels closer to the current price, highlighting immediate areas of potential interaction.
- Stretch: Using a higher coefficient pushes the levels further out, identifying broader structural zones where the price might react in the future.
4. Special Handling for Mondays (Gap Logic) The script includes logic specifically for Monday market openings. Because markets often "gap" (open at a significantly different price than where they closed on Friday), there is an optional setting to ignore the Friday close and instead base all calculations on the Monday opening price. This ensures that the levels remain relevant even if the market jumped overnight.
5. Visual Organization The script organizes these calculations into 18 distinct visual buffers:
- Primary Levels: A series of lines mapped out based on the Fibonacci ratios provided above.
- Reference Lines: It also plots the Previous Day's Close and the Monday Opening price to provide a clear visual context for your trading session.
Summary for Traders
Essentially, this tool removes the manual math of drawing Fibonacci levels. It automatically looks at yesterday's performance, applies a customizable multiplier to "stretch" or "shrink" those values, and draws a roadmap of potential support and resistance zones on your current chart. This helps traders identify where the market might pause, reverse, or accelerate based on historical volatility.
//+------------------------------------------------------------------+
//| FibonacciPivot.mq4 |
//| Copyright © 2010, LeMan. |
//| modification © 2015, noloxe |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, LeMan. && modification 2015, noloxe"
//----
#property indicator_chart_window
#property indicator_buffers 18
#property indicator_color1 LimeGreen
#property indicator_color2 LimeGreen
#property indicator_color3 LimeGreen
#property indicator_color4 LimeGreen
#property indicator_color5 LimeGreen
#property indicator_color6 LimeGreen
#property indicator_color7 LimeGreen
#property indicator_color8 LimeGreen
#property indicator_color9 DarkOrange
#property indicator_color10 DarkOrange
#property indicator_color11 DarkOrange
#property indicator_color12 DarkOrange
#property indicator_color13 DarkOrange
#property indicator_color14 DarkOrange
#property indicator_color15 DarkOrange
#property indicator_color16 DarkOrange
#property indicator_color17 Blue
#property indicator_color18 Black
//----
extern bool mondayGAP=false;
extern int Days=5;
extern double koeff=0.55;
extern string kof0 = "-- The recommended values of koeff ---";
extern string kof1 = "0.55 - to squeeze levels";
extern string kof2 = "0.89 - to squeeze levels";
extern string kof3 = "1.00 - changes won't be";
extern string kof4 = "1.44 - to stretch levels";
extern string kof5 = "2.33 - to stretch levels";
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];
double ExtMapBuffer9[];
double ExtMapBuffer10[];
double ExtMapBuffer11[];
double ExtMapBuffer12[];
double ExtMapBuffer13[];
double ExtMapBuffer14[];
double ExtMapBuffer15[];
double ExtMapBuffer16[];
double ExtMapBuffer17[];
double ExtMapBuffer18[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(18);
IndicatorDigits(Digits);
//---- indicators
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexBuffer(5,ExtMapBuffer6);
SetIndexBuffer(6,ExtMapBuffer7);
SetIndexBuffer(7,ExtMapBuffer8);
SetIndexBuffer(8,ExtMapBuffer9);
SetIndexBuffer(9,ExtMapBuffer10);
SetIndexBuffer(10,ExtMapBuffer11);
SetIndexBuffer(11,ExtMapBuffer12);
SetIndexBuffer(12,ExtMapBuffer13);
SetIndexBuffer(13,ExtMapBuffer14);
SetIndexBuffer(14,ExtMapBuffer15);
SetIndexBuffer(15,ExtMapBuffer16);
SetIndexBuffer(16,ExtMapBuffer17);
SetIndexBuffer(17,ExtMapBuffer18);
SetIndexStyle(0,DRAW_LINE,2);
SetIndexStyle(1,DRAW_LINE,2);
SetIndexStyle(2,DRAW_LINE,2);
SetIndexStyle(3,DRAW_LINE,1);
SetIndexStyle(4,DRAW_LINE,1);
SetIndexStyle(5,DRAW_LINE);
SetIndexStyle(6,DRAW_LINE);
SetIndexStyle(7,DRAW_LINE);
SetIndexStyle(8,DRAW_LINE,2);
SetIndexStyle(9,DRAW_LINE,2);
SetIndexStyle(10,DRAW_LINE,2);
SetIndexStyle(11,DRAW_LINE,1);
SetIndexStyle(12,DRAW_LINE,1);
SetIndexStyle(13,DRAW_LINE);
SetIndexStyle(14,DRAW_LINE);
SetIndexStyle(15,DRAW_LINE);
SetIndexStyle(16,DRAW_LINE,2);
SetIndexStyle(17,DRAW_LINE,2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
if(Period()>1439)
{
Comment("FibonacciPivot: Timeframe must be less D1 candles");
return(-1);
}
//----
int i,limit2,limit,PrevDay,counted_bars;
double hhv,llv,cl,tr,optoday;
//----
counted_bars=IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if(Days!=0) limit2=Days*1440/Period(); // calculation number of days for drawing
else limit2=limit;
limit=fmin(limit,limit2);
if(counted_bars==0) limit--;
//----
for(i=limit; i>=0; i--)
{
PrevDay=iBarShift(Symbol(),PERIOD_D1,Time[i])+1;
cl=iClose(NULL,PERIOD_D1,PrevDay);
hhv = iHigh(NULL, PERIOD_D1, PrevDay);
llv = iLow(NULL, PERIOD_D1, PrevDay);
tr=hhv-llv; // height of a day candle of previous day
ExtMapBuffer17[i]=cl; // Level of Closing of previous day
//----
if(TimeDayOfWeek(Time[i])==1) // if Monday
{
optoday=iOpen(NULL,PERIOD_D1,PrevDay-1);
ExtMapBuffer18[i]=optoday; // Level Opening of Monday. It is possible to hide EMPTY_VALUE
if(mondayGAP==true)
{
cl=optoday; // if GAP levels drawing from Opening of Monday
}
}
ExtMapBuffer1[i]=cl+tr*0.236*koeff;
ExtMapBuffer2[i] = cl+tr*0.382*koeff;
ExtMapBuffer3[i] = cl+tr*0.50*koeff;
ExtMapBuffer4[i] = cl+tr*0.618*koeff;
ExtMapBuffer5[i] = cl+tr*0.764*koeff;
ExtMapBuffer6[i] = cl+tr*1*koeff;
ExtMapBuffer7[i] = cl+tr*1.618*koeff;
ExtMapBuffer8[i] = cl+tr*2.618*koeff;
ExtMapBuffer9[i]=cl-tr*0.236*koeff;
ExtMapBuffer10[i] = cl-tr*0.382*koeff;
ExtMapBuffer11[i] = cl-tr*0.50*koeff;
ExtMapBuffer12[i] = cl-tr*0.618*koeff;
ExtMapBuffer13[i] = cl-tr*0.764*koeff;
ExtMapBuffer14[i] = cl-tr*1*koeff;
ExtMapBuffer15[i] = cl-tr*1.618*koeff;
ExtMapBuffer16[i] = cl-tr*2.618*koeff;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments