DayOpenFib-down

Download script
Author:
DayOpenFib-down

This tool is designed to provide traders with a visual roadmap of price levels based on daily historical data. Instead of cluttering your charts with manual calculations, this script automatically identifies key price points derived from the opening prices of past days.

Core Functionality

The primary purpose of this script is to project specific "Fibonacci-style" price levels onto your current chart. It looks back at a user-defined number of previous days (up to 100) and extracts the Opening Price for each of those days.

How the Logic Works

  1. Data Collection: The script scans through historical daily data to find the opening price of each day within your specified lookback period.
  2. Dynamic Projection: Once it identifies a daily opening price, it calculates four specific price levels. These levels are set at fixed offsets from that opening price: 34, 89, 144, and 233 units.
  3. Directional Bias: You can toggle the direction of these projections. Depending on your settings:
    • If the "Up" setting is active, the script projects these levels above the daily opening price.
    • If "Up" is inactive, it projects them below the daily opening price.
  4. Visual Display: The script plots these values as distinct lines on your chart. It also includes a specific line to mark the Yesterday's Close, providing a clear reference point for current price action relative to previous trading sessions.

Practical Use for Traders

By automatically plotting these levels, the tool helps you visualize potential support and resistance zones without having to manually draw lines. It allows you to see where historical daily openings sit in relation to current price movement, helping you identify significant "price milestones" based on past daily trends.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
DayOpenFib-down
//+------------------------------------------------------------------+
//|                                                  DayOpenFib.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
#property indicator_buffers 6
#property indicator_color1 Black
#property indicator_color2 FireBrick
#property indicator_color3 FireBrick
#property indicator_color4 FireBrick
#property indicator_color5 FireBrick
#property indicator_color6 FireBrick


double yc[];
double l1[]; //38
double l2[]; //89
double l3[]; //144
double l4[]; //233
//double l5[]; //233

extern int  HowManyDays = 100;
extern bool up=false;

int init()
  {
//---- indicators
//----
   SetIndexBuffer(0, yc); 
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID,2);
   SetIndexLabel(0, "Yesterday Close");
   SetIndexBuffer(1, l1);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID,2);
   SetIndexLabel(1, "Day Fib 38");
   SetIndexBuffer(2, l2); 
   SetIndexStyle(2, DRAW_LINE, STYLE_DOT);
   SetIndexLabel(2, "Day Fib 89");
   SetIndexBuffer(3, l3); 
   SetIndexStyle(3, DRAW_LINE, STYLE_DASHDOTDOT);
   SetIndexLabel(3, "Day Fib 144");
   SetIndexBuffer(4, l4); 
   SetIndexStyle(4, DRAW_LINE, STYLE_DASHDOT);
   SetIndexLabel(4, "Day Fib 233");
   //SetIndexBuffer(5, l5); 
   //SetIndexStyle(5, DRAW_LINE);
   //SetIndexLabel(5, "Line 5");
       
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int i=0,j=0;
   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;
//----
   datetime dailyTime[];
   double dailyClose[],dailyOpen[];
   bool newEndDay=false;
   
   ArrayCopySeries(dailyTime,MODE_TIME,Symbol(),PERIOD_D1);  
   ArrayCopySeries(dailyOpen,MODE_OPEN,Symbol(),PERIOD_D1);
   
  
   
   for (i=0;i<limit;i++){
      if ( j < HowManyDays && Period() < PERIOD_D1){
         if (newEndDay) {newEndDay=false; continue;}
         yc[i] = dailyOpen[j];
         if (up) {
            l1[i] = dailyOpen[j] + 34*Point;            
            l2[i] = dailyOpen[j] + 89*Point;
            l3[i] = dailyOpen[j] + 144*Point;
            l4[i] = dailyOpen[j] + 233*Point;
         }else{
            l1[i] = dailyOpen[j] - 34*Point;            
            l2[i] = dailyOpen[j] - 89*Point;
            l3[i] = dailyOpen[j] - 144*Point;
            l4[i] = dailyOpen[j] - 233*Point;

         }
         
         if (Time[i+1] < dailyTime[j]) {
            j++; 
            
            newEndDay=true;
         }
         
      }
      
      
   }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments