This tool is designed to monitor your trading charts and provide immediate notifications whenever the current market price enters a specific zone defined by a "box" or rectangle you have drawn on the screen.
How it works
The script continuously scans all the visual elements on your chart looking for rectangular shapes that start with a specific prefix (by default, an exclamation mark "!"). Once it identifies these boxes, it analyzes their boundaries—specifically their time range (from left to right) and their price range (from top to bottom).
Key Functionalities
- Real-Time Monitoring: The script constantly checks the current "live" price against the boundaries of every valid box on your chart.
- Automatic Alerts: If the current price moves into the area covered by one of these boxes, the script triggers an audible sound notification.
- Visual Notifications: Depending on your settings, it can also trigger a pop-up alert on your screen. These alerts will display the name or description you have assigned to that specific box, making it easy to identify which zone has been triggered.
- Smart Filtering: The logic is designed to ensure you aren't bombarded with constant notifications; it tracks which box was last triggered so that it only alerts you once per entry into a zone, resetting the alert once the price moves out of the specified area.
How to use it effectively
To utilize this tool, you simply need to draw rectangles on your chart to represent your "areas of interest" (such as supply/demand zones or support/resistance levels). By naming these boxes starting with the designated prefix, the script will automatically recognize them as active monitoring zones and notify you the moment the market price interacts with them.
#property copyright "Àëåðò ïðè âõîäå â áîêñ. ©+"
#property link "afx000@gmail.com"
#property indicator_chart_window
extern string BoxPrefix = "!";
extern string SoundFileName = "alert2.wav";
extern bool ShowAlert = false;
string lastAlert = "";
int start()
{
bool alert = false;
// èùåì âñå áîêñû
for (int i = 0; i < ObjectsTotal(); i++)
{
string name = ObjectName(i);
if (StringFind(name, BoxPrefix) == 0)
{
if (ObjectType(name) == OBJ_RECTANGLE)
{
datetime time1 = ObjectGet(name, OBJPROP_TIME1);
datetime time2 = ObjectGet(name, OBJPROP_TIME2);
double price1 = ObjectGet(name, OBJPROP_PRICE1);
double price2 = ObjectGet(name, OBJPROP_PRICE2);
datetime t1 = MathMin(time1, time2);
datetime t2 = MathMax(time1, time2);
double p1 = MathMin(price1, price2);
double p2 = MathMax(price1, price2);
if ((Close[0] >= p1) && (Close[0] <= p2) && (Time[0] >= t1) && (Time[0] <= t2))
{
alert = true;
break;
}
}
}
}
// àëåðò è çâóê
if (alert)
{
PlaySound(SoundFileName);
if (ShowAlert && (lastAlert != name))
{
string desc = ObjectDescription(name);
if (desc == "")
desc = name;
Alert(Symbol() + ": " + desc);
}
lastAlert = name;
}
else
lastAlert = "";
return(0);
}
int init()
{
return(0);
}
int deinit() { return(0); }
Comments