VX_FibPiv_rws

Download script
Author: Copyright � 2008, V-X
VX_FibPiv_rws

This script is designed to provide traders with a clean, on-screen dashboard of Support and Resistance (S&R) levels based on Fibonacci calculations. Instead of cluttering your main price chart with multiple lines, it concentrates this data into a readable "Gauge" or summary list located in a specific corner of your screen.

Core Logic Overview

1. Historical Data Gathering The script begins by identifying the price action from the previous trading day. It specifically looks for three key pieces of information:

  • The highest price reached (High)
  • The lowest price reached (Low)
  • The final closing price (Close)

A notable feature of its logic is its awareness of the market week. If it detects a weekend or a specific day transition, it intelligently searches backward to ensure it grabs the correct "previous" session data so that calculations remain consistent.

2. The Pivot Point Calculation Once it has the High, Low, and Close prices from the previous day, it calculates several dynamic price levels:

  • Standard Pivot (P): This is the average of the high, low, and close. It serves as the central "balance" point for the current day.
  • Resistance Levels (R1, R2, R3): These represent potential "ceilings" where price might struggle to move higher. They are calculated by adding specific percentages of the previous day's total range to the Pivot point.
  • Support Levels (S1, S2, S3): These represent potential "floors" where price might find buyers and stop falling. These are calculated by subtracting those same percentages from the Pivot point.

3. Dynamic Fibonacci Scaling The script uses specific coefficients to determine these levels:

  • R1 / S1: Uses a 0.382 multiplier.
  • R2 / S2: Uses a 0.618 multiplier (the classic "Golden Ratio").
  • R3 / S3: Uses a 1.000 multiplier.

4. Visual Dashboard Display Instead of drawing these numbers as moving lines on your candles, the script creates a formatted text display. It automatically:

  • Identifies the current timeframe you are viewing (e.g., M15, H1, D1).
  • Labels each level clearly (e.g., "R1", "Piv", "S2").
  • Displays the exact numerical price for every level in a vertical list.
  • Allows for customization of colors and fonts so the information remains easy to read against any background.

Summary for the User

Essentially, this tool acts as an automated "Price Map." It looks at what happened yesterday, calculates where the major psychological boundaries are for today using Fibonacci math, and neatly lists those prices on your screen so you can quickly identify where to place stop-losses or look for entry opportunities without having to do the manual math yourself.

Price Data Components
Series array that contains open time of each bar
7 Views
0 Downloads
0 Favorites
VX_FibPiv_rws
//+------------------------------------------------------------------+ 
//|   VX_FibPiv_rws                                                  | 
//|                                                                  | 
//|   Copyright © 2008, V-X                                          |
//|                                                                  |
//|   Thanks to Kalenzo for S&R formula                              |
//|   Thanks to TRO for the source code                              |
//+------------------------------------------------------------------+ 

#property copyright "Copyright © 2008, V-X"
#property link      "vogimerox_x@hotmail.com"

#property indicator_chart_window

extern int myChartY = 100 ;
extern string myFont  = "Courier" ; // "Verdana"
extern int myFontSize = 12 ; //9
extern int myCorner   = 0;
extern int myChartPeriod = 1440 ;
extern color myColorH = Gold ;
extern color myColor1 = Gold ;
extern color myColor2 = Gold ;
extern color myColor3 = Gold ;
extern color myColor4 = Gold ;
extern color myColor5 = Gold ;
extern color myColor6 = Gold ;
extern color myColor7 = Gold ;


int i;

double X01,X02,X03,X04,X05 ;
double X06 ;   
double X07 ;
double r3, r2, r1, p, s1, s2, s3 ; 
string symbol, tChartPeriod ;  
int    digits, period, win ;
double point ;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   if(myChartPeriod == 0) { myChartPeriod = Period() ; }    
   tChartPeriod =  TimeFrameToString(myChartPeriod) ;
   symbol       =  Symbol() ;
   digits       =  Digits ;
   point        =  Point ;
 
   win          = 0 ;
    
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
ObjectsDeleteAll( win, 21);
ObjectsDeleteAll( win, 22);
ObjectsDeleteAll( win, 23);     
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
//----
double rates[1][6],yesterday_close,yesterday_high,yesterday_low;
ArrayCopyRates(rates, Symbol(), PERIOD_D1);

if(DayOfWeek() == 1)
{
   if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,1)) == 5)
   {
       yesterday_close = rates[1][4];
       yesterday_high = rates[1][3];
       yesterday_low = rates[1][2];
   }
   else
   {
      for(int d = 5;d>=0;d--)
      {
         if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,d)) == 5)
         {
             yesterday_close = rates[d][4];
             yesterday_high = rates[d][3];
             yesterday_low = rates[d][2];
         }
         
      }  
      
   }
}
else
{
    yesterday_close = rates[1][4];
    yesterday_high = rates[1][3];
    yesterday_low = rates[1][2];
}


//---- Calculate Pivots

Comment("\nYesterday quotations:\nH ",yesterday_high,"\nL ",yesterday_low, "\nC ",yesterday_close);
double R = yesterday_high - yesterday_low;//range
p = (yesterday_high + yesterday_low + yesterday_close)/3;// Standard Pivot
r3 = p + (R * 1.000);
r2 = p + (R * 0.618);
r1 = p + (R * 0.382);
s1 = p - (R * 0.382);
s2 = p - (R * 0.618);
s3 = p - (R * 1.000);

DoShowGauge() ;
   return(0);
  }

void DoShowGauge()
{

X01  = r3 ;
X02  = r2 ;
X03  = r1 ;
X04  = p ;
X05  = s1 ;
X06  = s2 ;
X07  = s3 ;

string StrH   = " S&R" ;
string StrX01 = "R3  " ; 
string StrX02 = "R2  " ; 
string StrX03 = "R1  " ; 
string StrX04 = "Piv  " ;  
string StrX05 = "S1  " ; 
string StrX06 = "S2  " ;
string StrX07 = "S3  " ;

  
color color_X01=myColor1;
color color_X02=myColor2;
color color_X03=myColor3;  
color color_X04=myColor4;
color color_X05=myColor5;
color color_X06=myColor6;
color color_X07=myColor7;  


   int WindowToUse;
   int Corner_line, Xdist_line;
   int Corner_text, Corner_vSRFP, Xdist_text, Xdist_vSRFP;
   int Ydist_line5;
   int Corner_pivots, Xdist_pivots, Ydist_pivots;
   int Ydist_X01, Ydist_X02, Ydist_X03, Ydist_X04, Ydist_X05, Ydist_X06, Ydist_X07, Ydist_X08, Ydist_X09, Ydist_X10 ;
  
   int YdistInc ;
   
    WindowToUse =  0;
    Corner_line = myCorner;
    Corner_text = myCorner; Corner_vSRFP = myCorner;
    Xdist_line = 21; Xdist_text = 93; Xdist_vSRFP = 23;
    Corner_pivots = myCorner; Xdist_pivots = 21; 
    
    Ydist_pivots = myChartY;  
    Ydist_line5 = Ydist_pivots + 11; YdistInc = 15 ;
    
    Ydist_X01 = Ydist_pivots + 25; 
    Ydist_X02 = Ydist_X01 + YdistInc; 
    Ydist_X03 = Ydist_X01 + YdistInc*2; 
    Ydist_X04 = Ydist_X01 + YdistInc*3; 
    Ydist_X05 = Ydist_X01 + YdistInc*4;
    Ydist_X06 = Ydist_X01 + YdistInc*5;    
    Ydist_X07 = Ydist_X01 + YdistInc*6; 

   ObjectCreate("SRFP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("SRFP",tChartPeriod + StrH,myFontSize, myFont, myColorH);
   ObjectSet("SRFP", OBJPROP_CORNER, Corner_pivots);
   ObjectSet("SRFP", OBJPROP_XDISTANCE, Xdist_pivots);
   ObjectSet("SRFP", OBJPROP_YDISTANCE, Ydist_pivots);
   
   ObjectCreate("line5SRFP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("line5SRFP","-------------",myFontSize, myFont, myColorH);
   ObjectSet("line5SRFP", OBJPROP_CORNER, Corner_line);
   ObjectSet("line5SRFP", OBJPROP_XDISTANCE, Xdist_line);
   ObjectSet("line5SRFP", OBJPROP_YDISTANCE, Ydist_line5);
   
   ObjectCreate("X01_LabelRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X01_LabelRGE",StrX01,myFontSize, myFont, myColor1 );
   ObjectSet("X01_LabelRGE", OBJPROP_CORNER, Corner_text);
   ObjectSet("X01_LabelRGE", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X01_LabelRGE", OBJPROP_YDISTANCE, Ydist_X01);
   
   ObjectCreate("X01_ValueRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X01_ValueRGE"," "+DoubleToStr(X01,digits),myFontSize, myFont, color_X01);
   ObjectSet("X01_ValueRGE", OBJPROP_CORNER, Corner_vSRFP);
   ObjectSet("X01_ValueRGE", OBJPROP_XDISTANCE, Xdist_vSRFP);
   ObjectSet("X01_ValueRGE", OBJPROP_YDISTANCE, Ydist_X01);
    
   ObjectCreate("X02_LabelRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X02_LabelRGE",StrX02,myFontSize, myFont, myColor2 );
   ObjectSet("X02_LabelRGE", OBJPROP_CORNER, Corner_text);
   ObjectSet("X02_LabelRGE", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X02_LabelRGE", OBJPROP_YDISTANCE, Ydist_X02);
   
   ObjectCreate("X02_ValueRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X02_ValueRGE"," "+DoubleToStr(X02,digits),myFontSize, myFont, color_X02);
   ObjectSet("X02_ValueRGE", OBJPROP_CORNER, Corner_vSRFP);
   ObjectSet("X02_ValueRGE", OBJPROP_XDISTANCE, Xdist_vSRFP);
   ObjectSet("X02_ValueRGE", OBJPROP_YDISTANCE, Ydist_X02);

   ObjectCreate("X03_LabelRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X03_LabelRGE",StrX03,myFontSize, myFont, myColor3 );
   ObjectSet("X03_LabelRGE", OBJPROP_CORNER, Corner_text);
   ObjectSet("X03_LabelRGE", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X03_LabelRGE", OBJPROP_YDISTANCE, Ydist_X03);
   
   ObjectCreate("X03_ValueRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X03_ValueRGE"," "+DoubleToStr(X03,digits),myFontSize, myFont, color_X03);
   ObjectSet("X03_ValueRGE", OBJPROP_CORNER, Corner_vSRFP);
   ObjectSet("X03_ValueRGE", OBJPROP_XDISTANCE, Xdist_vSRFP);
   ObjectSet("X03_ValueRGE", OBJPROP_YDISTANCE, Ydist_X03);

   ObjectCreate("X04_LabelRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X04_LabelRGE",StrX04,myFontSize, myFont, myColor4 );
   ObjectSet("X04_LabelRGE", OBJPROP_CORNER, Corner_text);
   ObjectSet("X04_LabelRGE", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X04_LabelRGE", OBJPROP_YDISTANCE, Ydist_X04);
   
   ObjectCreate("X04_ValueRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X04_ValueRGE"," "+DoubleToStr(X04,digits),myFontSize, myFont, color_X04);
   ObjectSet("X04_ValueRGE", OBJPROP_CORNER, Corner_vSRFP);
   ObjectSet("X04_ValueRGE", OBJPROP_XDISTANCE, Xdist_vSRFP);
   ObjectSet("X04_ValueRGE", OBJPROP_YDISTANCE, Ydist_X04);  
       
   
   ObjectCreate("X05_LabelRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X05_LabelRGE",StrX05,myFontSize, myFont, myColor5 );
   ObjectSet("X05_LabelRGE", OBJPROP_CORNER, Corner_text);
   ObjectSet("X05_LabelRGE", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X05_LabelRGE", OBJPROP_YDISTANCE, Ydist_X05);
   
   ObjectCreate("X05_ValueRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X05_ValueRGE"," "+DoubleToStr(X05,digits),myFontSize, myFont, color_X05);
   ObjectSet("X05_ValueRGE", OBJPROP_CORNER, Corner_vSRFP);
   ObjectSet("X05_ValueRGE", OBJPROP_XDISTANCE, Xdist_vSRFP);
   ObjectSet("X05_ValueRGE", OBJPROP_YDISTANCE, Ydist_X05);
    
   ObjectCreate("X06_LabelRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X06_LabelRGE",StrX06,myFontSize, myFont, myColor6 );
   ObjectSet("X06_LabelRGE", OBJPROP_CORNER, Corner_text);
   ObjectSet("X06_LabelRGE", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X06_LabelRGE", OBJPROP_YDISTANCE, Ydist_X06);
   
   ObjectCreate("X06_ValueRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X06_ValueRGE"," "+DoubleToStr(X06,digits),myFontSize, myFont, color_X06);
   ObjectSet("X06_ValueRGE", OBJPROP_CORNER, Corner_vSRFP);
   ObjectSet("X06_ValueRGE", OBJPROP_XDISTANCE, Xdist_vSRFP);
   ObjectSet("X06_ValueRGE", OBJPROP_YDISTANCE, Ydist_X06);

   ObjectCreate("X07_LabelRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X07_LabelRGE",StrX07,myFontSize, myFont, myColor7 );
   ObjectSet("X07_LabelRGE", OBJPROP_CORNER, Corner_text);
   ObjectSet("X07_LabelRGE", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X07_LabelRGE", OBJPROP_YDISTANCE, Ydist_X07);
   
   ObjectCreate("X07_ValueRGE", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X07_ValueRGE"," "+DoubleToStr(X07,digits),myFontSize, myFont, color_X07);
   ObjectSet("X07_ValueRGE", OBJPROP_CORNER, Corner_vSRFP);
   ObjectSet("X07_ValueRGE", OBJPROP_XDISTANCE, Xdist_vSRFP);
   ObjectSet("X07_ValueRGE", OBJPROP_YDISTANCE, Ydist_X07);


}

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

string TimeFrameToString(int tf)
{
   string tfs;
   switch(tf) {
      case PERIOD_M1:  tfs="M1"  ; break;
      case PERIOD_M5:  tfs="M5"  ; break;
      case PERIOD_M15: tfs="M15" ; break;
      case PERIOD_M30: tfs="M30" ; break;
      case PERIOD_H1:  tfs="H1"  ; break;
      case PERIOD_H4:  tfs="H4"  ; break;
      case PERIOD_D1:  tfs="D1"  ; break;
      case PERIOD_W1:  tfs="W1"  ; break;
      case PERIOD_MN1: tfs="MN";
   }
   return(tfs);
}

Comments