//+------------------------------------------------------------------+ //| TrendlineCrossAlert.mq5 | //| Copyright 2018, Strx | //| https://www.mql5.com/en/users/strx | //+------------------------------------------------------------------+ #define EAName "TrendlineCrossAlert" #define EAVersion "1.01" #property copyright "Copyright 2018, Strx" #property link "https://www.mql5.com/en/users/strx" #property version EAVersion #property description "Horizontal and Trendlines cross detection on any pair/timeframe" #property description "good for scalping on small timeframes (M1 to M15) and trend following on bigger ones." #property description "It send notifications when price crosses trendlines and horizontal lines" #property description "of specified color and when it happens, it change its color to CrossedColor input parameter" #property description "to be sure not to send multiple notifications for same line" #include #include #include #include //--- External inputs sinput color MonitoringColor = clrYellow; //MonitoringColor, EA only monitors this lines color sinput color CrossedColor = clrGreen; //CrossedColor, EA changes crossed lines color to this value sinput bool EnableAlerts = true; sinput bool EnableNotifications=false; sinput bool EnableEmails=false; //+------------------------------------------------------------------+ //| Trendlines and Horizontal lines crossing notification expert //+------------------------------------------------------------------+ class CTrendlineCrossAlertExpert { protected: CSymbolInfo m_symbol; // symbol info object //--- Logic vars CArrayString m_objectNames; public: CTrendlineCrossAlertExpert(void); ~CTrendlineCrossAlertExpert(void); bool Init(void); void Deinit(void); bool Processing(void); protected: //--- Inline functions string FormatPrice(double price){ return StringFormat("%."+(string)m_symbol.Digits()+"f",price); }; bool IsNewBar(){ return iVolume(NULL,0,0)==1; }; //--- Logic functions int FindActiveObjects(); bool ActiveObject(string objName); bool PriceCrossed(string objName); void NotifyCrossing(string objName); }; //--- global expert CTrendlineCrossAlertExpert ExtExpert; //+------------------------------------------------------------------+ //| Constructor | //+------------------------------------------------------------------+ CTrendlineCrossAlertExpert::CTrendlineCrossAlertExpert(void){} //+------------------------------------------------------------------+ //| Destructor | //+------------------------------------------------------------------+ CTrendlineCrossAlertExpert::~CTrendlineCrossAlertExpert(void){} //+------------------------------------------------------------------+ //| Initialization and checking for input parameters | //+------------------------------------------------------------------+ bool CTrendlineCrossAlertExpert::Init(void) { //--- initialize common information m_symbol.Name(Symbol()); // symbol return(true); } //+------------------------------------------------------------------+ //| main function returns true if any position processed | //+------------------------------------------------------------------+ bool CTrendlineCrossAlertExpert::Processing(void) { bool rv=false; int i; string objName; if(m_symbol.RefreshRates()) { if(FindActiveObjects()) { for(i=0; iobjPrice) || (openPrice>=objPrice && curPrice