BZ_everyhour

Download script
Author: Copyright � 2007, MetaQuotes Software Corp.
BZ_everyhour

This script is designed to provide traders with a clear visual reference on their trading charts by identifying and marking specific price levels based on the market opening price. It simplifies the process of visualizing "zones" around a key price point, allowing for a more structured approach to analyzing potential entry or exit areas.

Core Functionality

1. Identification of the Opening Price The script automatically identifies the current opening price of the H1 (one-hour) timeframe. This serves as the primary anchor point for all subsequent visual data on your chart.

2. Dynamic Visual Mapping Once the opening price is established, the script automatically draws five distinct horizontal lines on your screen to represent different market zones:

  • The Anchor Line: A dotted line marks the exact opening price.
  • Buy Zones: Two dashed blue lines are projected above the opening price. These are calculated based on a "straddle width" and a "channel" value, which you can customize to define how far above the open you want to see these zones.
  • Sell Zones: Two dashed red lines are projected below the opening price using the same logic, highlighting potential areas of interest beneath the opening mark.

3. Real-Time Updates The script is designed to be dynamic. As new price data becomes available, it constantly monitors the current market state and moves the labels and lines accordingly. This ensures that the "zones" remain accurately aligned with the most recent price information without requiring the user to manually redraw them.

4. Customizable Visuals Users can personalize the experience through several input settings:

  • Session Naming: You can change the label text displayed on the chart (e.g., "Hour open").
  • Color Coordination: The script allows you to choose the specific color for the primary session labels.
  • Zone Dimensions: You can adjust the thickness (width) of the buy and sell zones by modifying the straddle and channel parameters, allowing the tool to adapt to different levels of market volatility.

Summary for the Trader

Essentially, this tool cleans up your chart by instantly highlighting a "balanced" area around the current hour's open. By providing clear blue (Buy) and red (Sell) boundaries, it helps you quickly see where price is sitting in relation to the opening equilibrium, making it easier to manage your risk and identify potential reaction areas at a glance.

Price Data Components
Series array that contains open prices of each bar
8 Views
0 Downloads
0 Favorites
BZ_everyhour
//+------------------------------------------------------------------+
//|                                                          MTC.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

// Thanks Avery Da RumpledOne for sharing his brilliant ideas



#property indicator_chart_window
//---- input parameters
extern string    session_name = "Hour open";
extern color     session_color = White;
//extern int       open_time=8;
extern int       straddle_width=3;
extern int       channel=1;


double open_price;
double rates_h1[2][6];
string OP, BZ, BZW, SZ, SZW;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators


  OP = "Open " + session_name;
  BZ = "Buy zone " + session_name;
  BZW = "Buy zone width " + session_name;
  SZ = "Sell zone " + session_name;
  SZW = "Sell zone width " + session_name;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete(OP);
   ObjectDelete(BZ);
   ObjectDelete(BZW);
   
   ObjectDelete(SZ);
   ObjectDelete(SZW);
   
   ObjectDelete(session_name);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----



/*  ArrayCopyRates(rates_h1, Symbol(), PERIOD_H1);
   for (int i=0;i<=25;i++)
   {
       if (TimeMinute(rates_h1[i][0])==0 && (TimeHour(rates_h1[i][0])-open_time)==0)
       {
           
      open_price = rates_h1[i][1];
    //  today_open = rates_h1[i][1];      
      break;
       }
   }
   
 */
 
 
    open_price = iOpen(NULL,PERIOD_H1,0);  

    if (ObjectFind(OP) != 0)
    
      {
      
      
          ObjectCreate(session_name,OBJ_TEXT,0,CurTime(),open_price+4*Point);
          ObjectSetText(session_name, session_name+"                                                                                                                                                        ",
                                                                                  8, "Arial",session_color);
      //    ObjectSet(session_name, OBJPROP_YDISTANCE, 100);
          
          
          ObjectCreate(OP, OBJ_HLINE, 0, CurTime(), open_price);
          ObjectSet(OP, OBJPROP_STYLE, STYLE_DOT);
          ObjectSet(OP, OBJPROP_COLOR, session_color);
          
          ObjectCreate(BZ, OBJ_HLINE, 0, CurTime(), open_price+straddle_width*Point);
          ObjectSet(BZ, OBJPROP_STYLE, STYLE_DASH);
          ObjectSet(BZ, OBJPROP_COLOR, Blue);
          
          ObjectCreate(BZW, OBJ_HLINE, 0, CurTime(), open_price+(straddle_width+channel)*Point);
          ObjectSet(BZW, OBJPROP_STYLE, STYLE_DASH);
          ObjectSet(BZW, OBJPROP_COLOR, Blue);
          
          
          ObjectCreate(SZ, OBJ_HLINE, 0, CurTime(), open_price-straddle_width*Point);
          ObjectSet(SZ, OBJPROP_STYLE, STYLE_DASH);
          ObjectSet(SZ, OBJPROP_COLOR, Red);
          
          ObjectCreate(SZW, OBJ_HLINE, 0, CurTime(), open_price-(straddle_width+channel)*Point);
          ObjectSet(SZW, OBJPROP_STYLE, STYLE_DASH);
          ObjectSet(SZW, OBJPROP_COLOR, Red);
          
          
      
       
      }
      
      else
      {
         ObjectMove(session_name,0,CurTime(),open_price+4*Point);
         ObjectMove(OP, 0, CurTime(), open_price);
         ObjectMove(BZ, 0, CurTime(),open_price+straddle_width*Point);
         ObjectMove(BZW, 0, CurTime(),open_price+(straddle_width+channel)*Point); 
         ObjectMove(SZ, 0, CurTime(),open_price-straddle_width*Point);
         ObjectMove(SZW, 0, CurTime(),open_price-(straddle_width+channel)*Point);
      
      }

   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments