_BZ_everyhour
Download scriptThis script is designed as a visual trading tool for the MetaTrader platform, primarily used to identify specific price zones based on the opening price of a new hourly session. Its main purpose is to highlight potential "Buy" and "Sell" areas on your chart automatically, helping traders visualize where key price levels are established at the start of each hour.
Core Logic and Functionality
1. Session Awareness The tool focuses on the hourly timeframe. It constantly monitors the market to identify the "Open Price"—the exact price at which a new 1-hour candle begins. This acts as the anchor point for all other calculations.
2. Dynamic Zone Calculation Instead of just marking a single price, the script calculates four distinct boundary levels relative to that opening price. It uses two customizable settings—Straddle Width and Channel—to determine how far above and below the opening price these zones should appear:
- Upper Buy Zones: The script identifies two levels above the opening price. One represents a primary "Buy Zone," and the second (calculated using the channel offset) marks a wider boundary for that zone.
- Lower Sell Zones: Similarly, the script identifies two levels below the opening price. These mark the "Sell Zone" and its corresponding wider boundary.
3. Visual Representation The script translates these mathematical calculations into physical markers on your trading chart:
- It utilizes specific symbols (WingDings) to distinguish between different types of zones.
- It applies a color-coding system (Blue for Buy-related markers and Red for Sell-related markers) to provide immediate visual clarity.
- These markers appear as arrows or distinct icons, allowing you to see at a glance where the current hour's trading boundaries are situated.
Summary for the Trader
Essentially, this tool automates the "math" of identifying supply and demand zones based on hourly opens. By providing these visual boundaries automatically, it allows you to see exactly where the market is positioned relative to the opening price, helping you identify potential areas of interest without having to manually calculate price points every time a new hour begins.
//+------------------------------------------------------------------+
//| 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
#property indicator_buffers 5
#property indicator_color1 Blue
#property indicator_color2 Blue
#property indicator_color3 White
#property indicator_color4 Red
#property indicator_color5 Red
//---- input parameters
extern int myWingDingL = 228 ;
extern int myWingDingO = 224 ;
extern int myWingDingS = 230 ;
extern string session_name = "Hour open";
extern int straddle_width=3;
extern int channel=1;
double lgt[];
double lgb[];
double opn[];
double sht[];
double shb[];
double open_price;
double rates_h1[2][6];
string OP, BZ, BZW, SZ, SZW;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0, lgt);
SetIndexBuffer(1, lgb);
SetIndexBuffer(2, opn);
SetIndexBuffer(3, sht);
SetIndexBuffer(4, shb);
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,myWingDingL);
SetIndexBuffer(0,lgt);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,myWingDingO);
SetIndexBuffer(1,lgb);
SetIndexEmptyValue(1,0.0);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,myWingDingO);
SetIndexBuffer(2,opn);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,myWingDingO);
SetIndexBuffer(3,sht);
SetIndexEmptyValue(3,0.0);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,myWingDingS);
SetIndexBuffer(4,shb);
SetIndexEmptyValue(4,0.0);
//----
//---- 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()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
/*
//----
int i, dayi, 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--;
int limit = Bars - counted_bars;
//----
for(i = limit - 1; i >= 0; i--)
{
opn[i] = iOpen(NULL,PERIOD_H1,0);
lgt[i] = opn[i]+straddle_width*Point ;
lgb[i] = opn[i]+(straddle_width+channel)*Point ;
sht[i] = opn[i]-straddle_width*Point ;
shb[i] = opn[i]-(straddle_width+channel)*Point ;
}
*/
opn[0] = iOpen(NULL,PERIOD_H1,0);
lgt[0] = opn[0]+(straddle_width+channel)*Point ;
lgb[0] = opn[0]+straddle_width*Point ;
sht[0] = opn[0]-straddle_width*Point ;
shb[0] = opn[0]-(straddle_width+channel)*Point ;
//----
return(0);
}
//+------------------------------------------------------------------+
Comments