cm line alert

Download script
Author: Copyright 2021, cmillion@narod.ru

This script is designed to automate the monitoring of price levels on a trading chart. Its primary purpose is to watch for specific horizontal lines or trend lines that you have drawn on your screen and notify you instantly when the market price touches or crosses them.

Core Functionality

The script constantly scans your active trading chart for two specific types of visual objects: Horizontal Lines and Trend Lines. It ignores all other types of drawings to ensure it only reacts to the specific tools you use for price levels.

How it Works

  1. Continuous Monitoring: Every time the market price moves (every "tick"), the script runs a check on all the objects currently visible on your chart.
  2. Identification: It looks for lines that have a defined price level. It specifically avoids any objects that might be hidden or categorized as internal system elements (starting with a "#" symbol).
  3. Collision Detection: The script compares the live "Bid" and "Ask" prices against the price level of each line it finds. If the market price moves into the range of a line—meaning the price is currently "touching" or "crossing" that specific mark—the logic is triggered.
  4. Automated Actions: Once a collision is detected, the script performs three simultaneous actions:
    • Visual Alert: It triggers a pop-up alert window on your trading platform.
    • Mobile Notification: It sends a push notification to your mobile device (if configured).
    • Email: It sends an automated email to your registered account.
  5. Cleanup: To prevent the script from sending multiple alerts for the same line repeatedly, it automatically deletes the specific line from the chart as soon as the first price collision occurs.

User Experience

On your trading screen, you will see a text comment in the corner that tracks the status of the lines. If there are no active lines being monitored, it will display a message indicating "no lines." If there are active lines, it will show the count of lines currently being watched. This provides a real-time status of how many price levels the script is currently "guarding."

Miscellaneous
It issuies visual alerts to the screenIt sends emails
5 Views
1 Downloads
0 Favorites
cm line alert
ÿþ//+------------------------------------------------------------------+

//|                                                cm line alert.mq5 |

//|                                Copyright 2021, cmillion@narod.ru |

//|                                          https://www.cmillion.ru |

//+------------------------------------------------------------------+

#property copyright "Copyright 2021, cmillion@narod.ru"

#property link      "https://www.cmillion.ru"

#property version   "1.00"

//+------------------------------------------------------------------+

/*!>25B=8: >B?@02;O5B A>>1I5=85 ?@8 4>AB865=88 :064>9 ;8=88 =0 3@0D8:5. 

5@5A5G5=85 ;8=88 8 F5=K AG8B05BAO, 5A;8 Ask 2KH5 8;8 @025= ;8=88 8 Bid =865 8;8 @025= ;8=88.

# :064>9 ;8=88 <>6=> 7040BL ;N1>5 8<O 8 >=> 1C45B :0: @07 8 >B>1@060BLAO 2 A>>1I5=88.

>A;5 >B?@02:8 A>>1I5=8O ;8=8O C40;O5BAO.

 8AC5B5 3>@87>=B0;L=CN ;8=8N, 405B5 59 8<O, =0?@8<5@ "EURUSD 1.23545 50%" 8 :0: B>;L:> F5=0 55 F5?;O5B, B0: >B?@02;O5BAO A>>1I5=85 =0 ?>GBC. 

>6=> @8A>20BL ;N1>5 G8A;> ;8=89.

//+------------------------------------------------------------------+*/

void OnTick()

{

   double price;

   string name;

   //+------------------------------------------------------------------+

   //|                                                                  |

   //+------------------------------------------------------------------+

   #ifdef __MQL5__

   double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);

   double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);

   #endif

   int n=0;

   for(int i=ObjectsTotal(#ifdef __MQL5__ 0#endif)-1; i>=0; i--)

   {

      name=ObjectName(0,i);

      if (StringFind(name,"#",0)!=-1) continue;

      if (ObjectGetInteger(0,name,OBJPROP_TYPE)!=OBJ_HLINE && ObjectGetInteger(0,name,OBJPROP_TYPE)!=OBJ_TREND) continue; 

      price=0;

      if (!ObjectGetDouble(0,name,OBJPROP_PRICE,0,price)) continue;

      if (price==0) continue;

      n++;

      if (Ask>=price && Bid<=price)

      {

         alert(name);

         ObjectDelete(0,name);

      }

   }

   if (n==0) Comment(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian"?"#AB0=>28B5 =0 M:@0= ;N1CN 3>@87>=B0;L=CN ;8=8N":"Set horizontal line on the screen");

   else Comment(n," line ");

}

//+------------------------------------------------------------------+

void alert(string txt)

{

   Alert(txt);

   SendNotification(txt);

   SendMail("cm line alert",txt);

}

//+------------------------------------------------------------------+

Comments