HLine Alert_001

Author: raff1410@o2.pl
HLine Alert_001

This script is designed as a visual and auditory monitoring tool for traders using the MetaTrader platform. Its primary purpose is to track a specific price level on a trading chart and provide an immediate notification when the market price reaches that designated area.

How the Logic Works

1. Visual Representation The script automatically places a horizontal line on your trading chart. You can customize the appearance of this line—such as its color, style (e.g., solid or dashed), and its specific name—through the settings menu. This allows you to clearly identify key price zones, such as support levels, resistance levels, or specific targets.

2. Dynamic Positioning The tool identifies your current market price and draws the horizontal line at that position. This serves as a constant visual reference point on your screen while the market is moving.

3. Proximity Detection (The Alert System) The core functionality of this script lies in its "proximity monitoring." Rather than only alerting you when the price touches the line exactly, it uses a customizable "Pip Range."

The logic works as follows:

  • It constantly calculates the distance between the current live market price and the position of your horizontal line.
  • If the market price moves within a specific number of pips (which you can define in the settings) of that line, the script triggers an action.
  • Once the price enters this defined "alert zone," the script plays a specific sound file.

Summary of User Experience

For a trader, this means you don't have to stare at the screen constantly waiting for the price to hit a specific number. You can set your horizontal line at your desired price level and define how close you want to be notified. The moment the market gets "close enough" to that price, the script will play an audio alert, allowing you to react quickly to the movement without missing the entry or exit point.

Miscellaneous
It plays sound alerts
6 Views
0 Downloads
0 Favorites
HLine Alert_001
//+------------------------------------------------------------------+
//|                                                  HLine Alert.mq4 |
//+------------------------------------------------------------------+
#property copyright "raff1410@o2.pl"

#property indicator_chart_window
extern string LineName="MyLine1";
extern color LineColor=AliceBlue; 
extern int LineStyle=STYLE_SOLID;
extern int AlertPipRange=5;
extern string AlertWav="alert.wav";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();

      ObjectCreate(LineName, OBJ_HLINE, 0, 0, Bid);
      ObjectSet(LineName, OBJPROP_STYLE, LineStyle);
      ObjectSet(LineName, OBJPROP_COLOR, LineColor);
        
      double val =  ObjectGet( LineName, OBJPROP_PRICE1);
      if (Bid-AlertPipRange*Point <= val && Bid+AlertPipRange*Point >= val) PlaySound(AlertWav);

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

Comments