48 lines
2 KiB
MQL5
48 lines
2 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| IAnalyser.mqh |
| |||
//| Copyright 2025, MetaQuotes Ltd. |
| |||
//| https://www.mql5.com |
| |||
//+------------------------------------------------------------------+
| |||
#property copyright "Copyright 2025, MetaQuotes Ltd."
| |||
#property link "https://www.mql5.com"
| |||
#property version "1.00"
| |||
| |||
#include "../Events/EventBus/EventBus.mqh"
| |||
#include "../Events/Events/AnalysisEvents.mqh"
| |||
#include "../Market/TimeFrameDataSeries.mqh"
| |||
#include <JSON.mqh>
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
class AbstractAnalyser
| |||
{
| |||
protected:
| |||
EventBus* eventBus;
| |||
| |||
virtual bool SaveState(string symbol, ENUM_TIMEFRAMES tf, JSON::Object* obj) { return false; }
| |||
virtual bool LoadState(string symbol, ENUM_TIMEFRAMES tf, const JSON::Object* obj) { return false; }
| |||
virtual bool CanSkipHistory(string symbol, ENUM_TIMEFRAMES tf) { return false; }
| |||
| |||
bool IsValidValue(double value) { return value != 0.0 && value != EMPTY_VALUE;}
| |||
| |||
bool IsSwingHigh(int index, Indicator* series)
| |||
{
| |||
return IsValidValue(series.Value(0, index));
| |||
}
| |||
| |||
bool IsSwingLow(int index, Indicator* series)
| |||
{
| |||
return IsValidValue(series.Value(1, index));
| |||
}
| |||
| |||
public:
| |||
virtual ~AbstractAnalyser() { }
| |||
virtual void Init(EventBus* bus) {eventBus = bus; }
| |||
AbstractAnalyser() : eventBus(NULL) {}
| |||
| |||
virtual void ProcessBar(TimeFrameDataSeries* series, int barIndex) = 0;
| |||
virtual void Reset(string symbol, ENUM_TIMEFRAMES tf) { Print("Reset ", EnumToString(tf));}
| |||
| |||
virtual string GetAnalyserName() = 0;
| |||
};
| |||
//+------------------------------------------------------------------+
|