XALIF!
Download scriptThis tool is designed to automatically identify and highlight key price extremes—specifically the highest highs and lowest lows—during two distinct periods of the trading day. By tracking these specific price points, it helps traders visualize significant volatility boundaries without having to manually monitor every price movement.
How the Logic Works
The script operates based on a time-segmented approach, focusing on two separate windows of activity:
1. Automated Daily Reset At the start of each new day, the tool automatically clears any previous markings from the chart. This ensures that your workspace remains clean and that you are only looking at the price action relevant to the current trading session.
2. Dual-Session Tracking The logic is divided into two specific time blocks (which can be customized by the user). The script monitors the "Bid" price during these windows to capture the following:
- First Session: During this initial period, the tool identifies the highest price reached and the lowest price hit. It places a gold-colored horizontal line at the peak and another at the floor. If the price breaks above the current high or below the current low, the lines automatically "drag" to follow the new extreme.
- Second Session: Once the second time block begins, the tool starts a separate tracking process. It identifies the highs and lows for this specific period, marking them with coral-colored horizontal lines.
3. Real-Time Updates The script works dynamically in real-time. Rather than drawing hundreds of lines, it constantly compares the live market price against the existing extremes for the active session. If a new "all-time high" or "all-time low" is hit within the designated hours, the tool instantly updates the line position to reflect that new boundary.
Summary of Purpose
Essentially, this script acts as an automated "boundary tracker." It filters out market noise by focusing only on the most significant price levels reached during your preferred trading hours, providing a clear visual map of the session's range and volatility.
//+------------------------------------------------------------------+
//| maloma 4 XALIF.mq4 |
//+------------------------------------------------------------------+
#property copyright "© Maloma"
#property indicator_chart_window
//---- input parameters
extern int StartHour1st=5;
extern int EndHour1st=9;
extern int StartHour2nd=12;
extern int EndHour2nd=15;
bool NewDay=true;
double UpPrice1st=0;
double DnPrice1st=0;
double UpPrice2nd=0;
double DnPrice2nd=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffers mapping
//---- drawing settings
//----
//---- name for DataWindow
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
ObjectDelete("UpLINE1st");
ObjectDelete("DnLINE1st");
ObjectDelete("UpLINE2nd");
ObjectDelete("DnLINE2nd");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void DelOldLines()
{
if (ObjectFind("UpLINE1st")!=-1)
{
ObjectDelete("UpLINE1st");
}
if (ObjectFind("DnLINE1st")!=-1)
{
ObjectDelete("DnLINE1st");
}
if (ObjectFind("UpLINE2nd")!=-1)
{
ObjectDelete("UpLINE2nd");
}
if (ObjectFind("DnLINE2nd")!=-1)
{
ObjectDelete("DnLINE2nd");
}
DnPrice1st=0;
UpPrice1st=0;
DnPrice2nd=0;
UpPrice2nd=0;
return(0);
}
int start()
{
if (Hour()==0 && NewDay)
{
DelOldLines();
NewDay=false;
}
if (Hour()<StartHour1st) {return(0);}
if (UpPrice1st==0) UpPrice1st=Bid;
if (DnPrice1st==0) DnPrice1st=Bid;
if (Hour()<EndHour1st)
{
if (Bid>UpPrice1st)
{
UpPrice1st=Bid;
ObjectDelete("UpLINE1st");
ObjectCreate("UpLINE1st",OBJ_HLINE,0,0,UpPrice1st);
ObjectSet("UpLINE1st",OBJPROP_COLOR,Gold);
ObjectSet("UpLINE1st",OBJPROP_WIDTH,2);
}
if (Bid<DnPrice1st)
{
DnPrice1st=Bid;
ObjectDelete("DnLINE1st");
ObjectCreate("DnLINE1st",OBJ_HLINE,0,0,DnPrice1st);
ObjectSet("DnLINE1st",OBJPROP_COLOR,Gold);
ObjectSet("DnLINE1st",OBJPROP_WIDTH,2);
}
}
//--------------------------------------------------------
if (Hour()<StartHour2nd) {return(0);}
if (UpPrice2nd==0) UpPrice2nd=Bid;
if (DnPrice2nd==0) DnPrice2nd=Bid;
if (Hour()<EndHour2nd)
{
if (Bid>UpPrice2nd)
{
UpPrice2nd=Bid;
ObjectDelete("UpLINE2nd");
ObjectCreate("UpLINE2nd",OBJ_HLINE,0,0,UpPrice2nd);
ObjectSet("UpLINE2nd",OBJPROP_COLOR,Coral);
ObjectSet("UpLINE2nd",OBJPROP_WIDTH,2);
}
if (Bid<DnPrice2nd)
{
DnPrice2nd=Bid;
ObjectDelete("DnLINE2nd");
ObjectCreate("DnLINE2nd",OBJ_HLINE,0,0,DnPrice2nd);
ObjectSet("DnLINE2nd",OBJPROP_COLOR,Coral);
ObjectSet("DnLINE2nd",OBJPROP_WIDTH,2);
}
}
return(0);
if (Hour()>=EndHour2nd) {NewDay=true;}
}
//+------------------------------------------------------------------+
Comments