Price Alert(Alex)[1]
Download scriptThis tool is designed to act as a visual and audible price monitor within the MetaTrader platform. Its primary purpose is to notify you instantly when the current market price moves into a specific "zone of interest" that you have manually defined on your chart.
How it Works
Visual Setup When you first load this script, it automatically places a horizontal line on your trading chart at the current closing price. You can customize the color of this line (for example, to Gold) through the settings menu, making it easy to see at a glance where your target level is located.
The Monitoring Logic The script constantly analyzes the relationship between three specific points:
- The position of your custom horizontal line.
- The "High" and "Low" price points of the previous completed candle.
- The current "High" and "Low" price points of the live, moving candle.
Essentially, it calculates a dynamic price range based on the most recent market activity. It looks to see if your chosen horizontal line falls within the boundaries created by these recent price movements.
Notifications If the price action triggers a match—meaning your horizontal line is caught within that active price range—the script performs two actions (depending on your preferences):
- Visual Alerts: A pop-up notification will appear on your screen, displaying the name of the currency pair, the timeframe, and the exact price level.
- Audio Signals: The tool can play a specific sound file (like an alarm) to grab your attention immediately if you are away from the monitor.
Key Features for the User
- Customizable Alerts: You can toggle the pop-up alerts and the sound effects on or off independently.
- Dynamic Interaction: Because it compares your line against the "High" and "Low" of current candles, it is designed to react to active price fluctuations rather than just static numbers.
- Automatic Cleanup: The script is designed to be tidy; it removes the horizontal line from your chart automatically once the indicator is turned off or removed, keeping your workspace clean.
//+------------------------------------------------------------------+
//| PRICE_Alert.mq4 |
//| Copyright © 2008, AlexGomel |
//| mailto:alexgomel@tut.by |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, AlexGomel"
#property link "mailto:alexgomel@tut.by"
//----
#property indicator_chart_window
#property indicator_buffers 0
//---- input parameters
extern string NamePrice="Price_1";
extern string SoundFileName="alarm.wav";
extern bool ActiveSignal=true;
extern bool ActiveAlert=true;
extern color LineColor=Gold;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
if (ObjectFind(NamePrice)==-1)
{
ObjectCreate(NamePrice,OBJ_HLINE,0,0,Close[0]);
ObjectSet(NamePrice,OBJPROP_COLOR,LineColor);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete(NamePrice);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
if (ObjectFind(NamePrice)==-1) return(0);
double _price=ObjectGet(NamePrice,OBJPROP_PRICE1);
double _min=MathMin(High[1],Low[0]);
double _max=MathMax(Low[1],High[0]);
//----
if (ActiveSignal && _price>=_min && _price<=_max)
{
if (ActiveAlert) Alert (Symbol()," ",Period()," Öåíà äîñòèãëà ", NormalizeDouble(_price,Digits), " !"); // Ïðåäóïðåæäåíèå íà ýêðàí
if(SoundFileName!="" )
PlaySound( SoundFileName ); // Çâóêîâîé ñèãíàë
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments