//+------------------------------------------------------------------+ //| SignalEB.mqh | //+------------------------------------------------------------------+ #property copyright "AnimateDread" #property version "1.0" #property description "Engulfing Bar Signal" //+------------------------------------------------------------------+ //| include files | //+------------------------------------------------------------------+ #include "..\Expert\ExpertSignalCustom.mqh" // wizard description start //+------------------------------------------------------------------+ //| Description of the class | //| Title=Signal of candle pattern 'Engulfing Bar' | //| Type=SignalAdvanced | //| Name=Engulfing Bar Pattern | //| ShortName=EB | //| Class=CSignalEB | //| Page= | //+------------------------------------------------------------------+ // wizard description end //+------------------------------------------------------------------+ //| CSignalEB class. | //| Purpose: Class of trading signal Engulfing Bar Pattern | //| It is derived from the CExpertSignalCustom class. | //+------------------------------------------------------------------+ class CSignalEB : public CExpertSignalCustom { protected: //--- Pattern weights int m_pattern_0; public: CSignalEB(); ~CSignalEB(); //--- methods of adjusting "weights" of market models void Pattern_0(int value) { m_pattern_0 = value; } virtual void ApplyPatternWeight(int patternNumber, int weight); virtual int LongCondition(void); virtual int ShortCondition(void); protected: //--- Method to calculate dynamic threshold double CalculateAverageCandleSize(); }; //+------------------------------------------------------------------+ //| Constructor. | //+------------------------------------------------------------------+ CSignalEB::CSignalEB() : m_pattern_0(10) { m_id = "EB"; m_pattern_count = 1; } //+------------------------------------------------------------------+ //| Destructor | //+------------------------------------------------------------------+ CSignalEB::~CSignalEB(void) { } //+------------------------------------------------------------------+ //| "Voting" that price will grow. | //+------------------------------------------------------------------+ int CSignalEB::LongCondition(void) { int result = 0; int idx = StartIndex(); int prevIdx = idx + 1; if(High(idx) > High(prevIdx) && Low(idx) < Low(prevIdx) && Open(idx) <= Close(prevIdx) && Close(idx) >= Open(prevIdx)) { if(IS_PATTERN_USAGE(0)) { result = m_pattern_0; m_active_pattern = "Pattern_0"; } } if(result != 0) { m_active_direction = "Buy"; } //--- return the result return (result); } //+------------------------------------------------------------------+ //| "Voting" that price will fall. | //+------------------------------------------------------------------+ int CSignalEB::ShortCondition(void) { int result = 0; int idx = StartIndex(); int prevIdx = idx + 1; if(Low(idx) < Low(prevIdx) && High(idx) > High(prevIdx) && Close(idx) <= Open(prevIdx) && Open(idx) >= Close(prevIdx)) { if(IS_PATTERN_USAGE(0)) { result = m_pattern_0; m_active_pattern = "Pattern_0"; } } if(result != 0) { m_active_direction = "Sell"; } //--- return the result return (result); } //+------------------------------------------------------------------+ //| Set the specified pattern's weight to the specified value | //+------------------------------------------------------------------+ void CSignalEB::ApplyPatternWeight(int patternNumber, int weight) { switch(patternNumber) { default: break; case 0: Pattern_0(weight); break; } } //+------------------------------------------------------------------+