AlertingSystem

Author: Copyright 2020, Forex Jarvis. forexjarvis@gmail.com
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites
AlertingSystem
//+------------------------------------------------------------------+
//|                                               AlertingSystem.mq4 |
//|                                    Copyright 2020, Forex Jarvis. |
//|                                            forexjarvis@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Forex Jarvis. forexjarvis@gmail.com"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

input double   HigherPrice;
input double   LowerPrice;

string slineid1 = "lineid1";
string slineid2 = "lineid2";

int counter = 0;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if (counter==0) {
   
      ObjectCreate(NULL, slineid1,OBJ_HLINE,0,0,HigherPrice);  //Create Hline of the vlineid1 with price HigherPrice
      ObjectCreate(NULL, slineid2,OBJ_HLINE,0,0,LowerPrice);   //Create Hline of the vlineid1 with price LowerPrice
      
      ObjectSetInteger(NULL,slineid1,OBJPROP_COLOR,C'38,166,154');   //color the vline of the vlineid
      ObjectSetInteger(NULL,slineid2,OBJPROP_COLOR,C'239,83,80');   //color the vline of the vlineid
      
      ObjectSetInteger(NULL, slineid1,OBJPROP_SELECTABLE,true);
      ObjectSetInteger(NULL, slineid2,OBJPROP_SELECTABLE,true);
      
      counter++;
   }
   
   double val1 = ObjectGetDouble(NULL,slineid1,OBJPROP_PRICE);
   double val2 = ObjectGetDouble(NULL,slineid2,OBJPROP_PRICE);
   
   ObjectSetDouble(NULL,slineid1,OBJPROP_PRICE,val1);
   ObjectSetDouble(NULL,slineid2,OBJPROP_PRICE,val2);

	if (SymbolInfoDouble(_Symbol,SYMBOL_BID) >= ObjectGetDouble(NULL,slineid1,OBJPROP_PRICE) && ObjectGetDouble(NULL,slineid1,OBJPROP_PRICE)>0.0) {
		PlaySound("alert.wav");
	}

	if (SymbolInfoDouble(_Symbol,SYMBOL_ASK) <= ObjectGetDouble(NULL,slineid2,OBJPROP_PRICE) && ObjectGetDouble(NULL,slineid2,OBJPROP_PRICE)>0.0) {
		PlaySound("alert.wav");
	}
	
   
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---