refactor some typos on helper classes and implement base classes for providers and start x5 provider ...
This commit is contained in:
@@ -0,0 +1,264 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCBaseProvider
|
||||
// Description: provides all Base Provider
|
||||
// requirements ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Includes ...
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
#include "../Libraries/x-saherelm.xtrade.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Base Provider Inputs ...
|
||||
class XSCBaseProviderInpts : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Validate Input ...
|
||||
virtual bool IsValid();
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
virtual void Clean();
|
||||
|
||||
//
|
||||
// Default ...
|
||||
virtual void Default();
|
||||
|
||||
//
|
||||
// Max ...
|
||||
virtual int Max();
|
||||
};
|
||||
|
||||
//
|
||||
// Base Market Conditions Class ...
|
||||
class XSCBaseProviderMarketConditions : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
XOHCL bars[]; // Number of Bars ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
// Generate Score ...
|
||||
virtual void GenerateScore(
|
||||
double &bullishScore, // Bullish Score
|
||||
double &bearishScore, // Bearish Score
|
||||
const double multiplier = 1 // Score Multiplier
|
||||
);
|
||||
|
||||
//
|
||||
// Generate Summary ...
|
||||
virtual string GenerateSummary(
|
||||
const double multiplier = 1, // Score Multiplier
|
||||
const bool ignoreFalseConditions = true // Ignore False Conditions
|
||||
);
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
|
||||
//
|
||||
// Base Provider Class ...
|
||||
class XSCBaseProvider : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XSCBaseProvider(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period // Trading Period
|
||||
)
|
||||
{
|
||||
//
|
||||
// Initialize Cycle ...
|
||||
mCycle.Init(
|
||||
symbol,
|
||||
period,
|
||||
X_MARKET_CYCLE_UNKNOWN,
|
||||
X_PERIOD_NOTHING,
|
||||
period,
|
||||
"HOST Period"
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCBaseProvider()
|
||||
{
|
||||
DeInit();
|
||||
}
|
||||
|
||||
//
|
||||
// Properties Gettr(s) / Setter(s) ...
|
||||
|
||||
//
|
||||
// Inheritance ...
|
||||
|
||||
//
|
||||
// Init all Requirements ...
|
||||
virtual bool Init(XSCBaseProviderInpts &inputs)
|
||||
{
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Inputs ...
|
||||
virtual void GetInputs(XSCBaseProviderInpts &inputs)
|
||||
{
|
||||
inputs = mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Inputs and Reinitial ...
|
||||
virtual bool setInputs(XSCBaseProviderInpts &inputs)
|
||||
{
|
||||
return Init(inputs);
|
||||
}
|
||||
|
||||
//
|
||||
// DeInit all Requirements ...
|
||||
virtual void DeInit();
|
||||
|
||||
//
|
||||
virtual bool GetMarketConditions(
|
||||
XSCBaseProviderMarketConditions &conditions, // Market Conditions Result
|
||||
int barIndex = 0 // Specified Bar Index
|
||||
);
|
||||
|
||||
//
|
||||
// Check Market For Signal ...
|
||||
virtual bool HasSignal(
|
||||
int barIndex,
|
||||
XSignal &signal, // Hold's Signal if Exists ...
|
||||
XSCBaseProviderMarketConditions &conditions // Hold's Market Conditions ...
|
||||
);
|
||||
|
||||
//
|
||||
// Functions ...
|
||||
|
||||
//
|
||||
string GetSymbol()
|
||||
{
|
||||
return mCycle.symbol;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_TIMEFRAMES GetPeriod()
|
||||
{
|
||||
return mCycle.hostPeriod;
|
||||
}
|
||||
|
||||
//
|
||||
// Count Bars ...
|
||||
int CountBars()
|
||||
{
|
||||
//
|
||||
return mCycle
|
||||
.CountBars();
|
||||
}
|
||||
|
||||
//
|
||||
// Check New Bar ...
|
||||
bool IsNewBar()
|
||||
{
|
||||
//
|
||||
return mCycle
|
||||
.IsNewBar();
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
XMarketCycle mCycle;
|
||||
XSCBaseProviderInpts mInputs;
|
||||
|
||||
//
|
||||
bool mWaitsUntilNewBar;
|
||||
|
||||
//
|
||||
// Can Ignore Process ...
|
||||
bool CanIgnoreProcess()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsRunningOnTestMode()
|
||||
? !IsNewBar()
|
||||
: !IsNewBar() && mWaitsUntilNewBar
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Toggle Waititng Until New Candle ...
|
||||
void ToggleWaitingUntilNewBar()
|
||||
{
|
||||
mWaitsUntilNewBar = !mWaitsUntilNewBar;
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Reference in New Issue
Block a user