SRDC Fibo AHA V0_1

Download script
Author: Copyright ?2006, AHA
SRDC Fibo AHA V0_1

This script is designed for the MetaTrader platform to automate the drawing of Fibonacci retracement levels based on daily price action. It serves as a visual aid for traders who use daily price ranges to identify potential support and resistance zones.

Core Functionality

The primary purpose of this tool is to automatically scan the current day's trading data, identify the highest and lowest prices reached, and plot a Fibonacci retracement tool on your chart. This removes the need for manual calculation or precise clicking to place the tool correctly based on the previous day's boundaries.

How It Works

The logic follows a specific sequence every time the price moves or a new day begins:

  • Daily Range Scanning: The script looks back through all the price candles recorded during the current trading day. It systematically scans these candles to find the absolute maximum high and the absolute minimum low reached within that 24-hour period.
  • Dynamic Placement: Once the high and low points are identified, the script determines the correct orientation for the Fibonacci tool. It ensures that the "zero" and "one hundred percent" levels are anchored correctly based on whether the price moved upward or downward most significantly during the session.
  • Automated Drawing: After identifying the range, the tool automatically creates or updates a visual Fibonacci object on your chart. This object is colored according to the user's preference (set as Purple by default).
  • Predefined Levels: The script populates the Fibonacci tool with a specific set of 12 key levels, including standard retracements (like 38.2%, 50.0%, and 61.8%) as well as extension levels (such as 161.8% and 261.8%).

Key Features for the User

  • Real-Time Updates: The tool is designed to refresh its logic, ensuring that as new highs or lows are hit during the day, the Fibonacci levels adjust accordingly.
  • Clean Visualization: By automating the "Draw," the script keeps your chart clean and ensures that the Fibonacci levels remain consistent with the daily price action without manual intervention.
  • Standardized Levels: Since it provides a fixed set of descriptions and percentage levels (from 0.236 up to 2.618), it ensures that every trader looking at the chart sees the exact same mathematical breakdown of the daily move.
Price Data Components
Series array that contains open time of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
5 Views
0 Downloads
0 Favorites
SRDC Fibo AHA V0_1
//+------------------------------------------------------------------+
//|                                           SRDC Fibo AHA V0_1.mq4 |
//|                                             Copyright ?2006, AHA |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2006, AHA"
#property link      ""

#property indicator_chart_window
extern color dailyfibocolor=Purple;

string fiboobjname="Daily Fibo from SRDC Fibo AHA";
bool startup;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   startup=true;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
void drawdailyfibo()
{
   if(TimeDay(Time[0])==TimeDay(Time[1])&&!startup) return;
   ObjectDelete(fiboobjname);
   
   datetime aday=iTime(NULL,PERIOD_D1,1);
   int bar=iBarShift(NULL,0,aday);
   double dailyhigh=0.0, dailylow=100000.0;
   int highbar, lowbar, i=bar;
   
   while(TimeDay(iTime(NULL,0,i))==TimeDay(iTime(NULL,0,bar)))
   {
      if(iHigh(NULL,0,i)>dailyhigh)
      {
         dailyhigh=iHigh(NULL,0,i);
         highbar=i;
      }
      if(iLow(NULL,0,i)<dailylow)
      {
         dailylow=iLow(NULL,0,i);
         lowbar=i;
      }
      i--;
   }
   if (highbar>lowbar) 
      ObjectCreate(fiboobjname, OBJ_FIBO, 0, Time[lowbar], dailylow, Time[highbar], dailyhigh);
   else if (highbar<lowbar) 
      ObjectCreate(fiboobjname, OBJ_FIBO, 0, Time[highbar], dailyhigh, Time[lowbar], dailylow);
   else 
   {
      if (Close[highbar]>Open[highbar])
         ObjectCreate(fiboobjname, OBJ_FIBO, 0, Time[highbar], dailyhigh, Time[lowbar], dailylow);
      else if (Close[highbar]>Open[highbar])
         ObjectCreate(fiboobjname, OBJ_FIBO, 0, Time[lowbar], dailylow, Time[highbar], dailyhigh);
   }   
   ObjectSet(fiboobjname, OBJPROP_LEVELCOLOR, dailyfibocolor);
   ObjectSet(fiboobjname, OBJPROP_FIBOLEVELS, 11);
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+1, 0.236);
   ObjectSetFiboDescription(fiboobjname,1,"23.6");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+2, 0.382);
   ObjectSetFiboDescription(fiboobjname,2,"38.2");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+3, 0.50);
   ObjectSetFiboDescription(fiboobjname,3,"50.0");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+4, 0.618);
   ObjectSetFiboDescription(fiboobjname,4,"61.8");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+5, 0.764);
   ObjectSetFiboDescription(fiboobjname,5,"76.4");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+6, 1.000);
   ObjectSetFiboDescription(fiboobjname,6,"100.0");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+7, 1.214);
   ObjectSetFiboDescription(fiboobjname,7,"121.4");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+8, 1.382);
   ObjectSetFiboDescription(fiboobjname,8,"138.2");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+9, 1.618);
   ObjectSetFiboDescription(fiboobjname,9,"161.8");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+10, 2.000);
   ObjectSetFiboDescription(fiboobjname,10,"200.0");
   ObjectSet(fiboobjname, OBJPROP_FIRSTLEVEL+11, 2.618);
   ObjectSetFiboDescription(fiboobjname,11,"261.8");
   ObjectsRedraw();
   
   return;
}//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   //int    counted_bars=IndicatorCounted();
//----
   drawdailyfibo();

   startup=false;
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments