Files
xMQL5/MQLTestWorkspace/BKPS/14030308/Classes/x-saherelm.xprovider.class.mq5
T
2024-05-28 08:03:47 +03:30

268 lines
4.9 KiB
Plaintext

///////////////////////////////////////////////////////
//
// 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 ...
string symbol; // Symbol
ENUM_TIMEFRAMES period; // Period
datetime time; // Time
//
XOHCL bars[]; // Number of Bars ...
//
// Buffers ...
//
// Conditions ...
//
// Generate Score ...
virtual void GenerateScore(
double &bullishScore, // Bullish Score
double &bearishScore, // Bearish Score
double multiplier = 1 // Score Multiplier
);
//
// Generate Summary ...
virtual string GenerateSummary(
const bool onlySummary = false, // Only Generate Conditions Summary
double multiplier = 1, // Score Multiplier
const string separator = "\n", // Separator
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
double staticVolume // Static Volume for Positions
)
{
//
// Initialize Cycle ...
mCycle.Init(
symbol,
period,
X_MARKET_CYCLE_SHORT,
X_PERIOD_MANUALLY,
period,
"HOST Period"
//
);
//
mStaticVolume = staticVolume;
}
//
// Deconstructor ...
~XSCBaseProvider()
{
DeInit();
}
//
// Properties Gettr(s) / Setter(s) ...
//
// Inheritance ...
//
// Init all Requirements ...
virtual bool Init(XSCBaseProviderInpts &inputs);
//
// Get Inputs ...
virtual void GetInputs(XSCBaseProviderInpts &inputs);
//
// Set Inputs and Reinitial ...
virtual bool setInputs(XSCBaseProviderInpts &inputs);
//
// DeInit all Requirements ...
virtual void DeInit();
//
virtual void 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;
}
//
double GetStaticVolume()
{
return mStaticVolume;
}
//
// Count Bars ...
int CountBars()
{
//
return mCycle
.CountBars();
}
//
// Check New Bar ...
bool IsNewBar()
{
//
return mCycle
.IsNewBar();
}
//
// Protected ...
protected:
//
// Props ...
//
double mStaticVolume; // Static Volume for Positions
//
XMarketCycle mCycle;
//
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 ...