Files
MQL5Data/Classes/x-saherelm.x121.setup.cycle.class.mq5
T
2024-06-11 09:42:31 +03:30

342 lines
6.7 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// ----------------------------------------------
// Name: XSCX121SetupCycle
// Description: provides implementation of X121
// Setup on Specified Market Cycle ...
//
//
// 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
//
// Imports ...
//
#include "../Classes/x-saherelm.x121.setup.class.mq5"
//
// Definitions ...
//
// Inputs ...
struct X121SetupCycleInputs
{
//
// Props ...
//
XMarketCycle cycle; // Market Cycle
//
X121SetupInputs inputs; // Inputs
//
XSCX121Setup *setup; // Setup
//
// Constructor ...
void X121SetupCycleInputs()
{
}
//
// Initialization ...
bool Init(
X121SetupInputs &_inputs, // Configurations
ENUM_TIMEFRAMES _hostPeriod, // Host Period
ENUM_X_MARKET_CYCLES _cycle, // Init Cycle
ENUM_X_PERIOD_METHOD _method, // Period Selection Method
ENUM_TIMEFRAMES _period, // Provided Period
string _prefix = "" // Prefix
)
{
//
bool result = false;
//
// Validate Inputs ...
result =
//
IsValid(_inputs.symbol)
//
;
if (!result)
{
return result;
}
//
// Init Cycle ...
result = cycle.Init(
inputs.symbol,
_hostPeriod,
_cycle,
_method,
_period,
_prefix //
);
if (!result)
{
return result;
}
//
cycle.Update(0);
//
_inputs.period = cycle.period;
//
result = _inputs.IsValid();
if (!result)
{
return result;
}
//
this.inputs = _inputs;
//
setup = new XSCX121Setup();
result = setup.Init(
inputs //
);
//
return result;
}
//
// Tools ...
//
string GetSymbol()
{
return inputs.symbol;
}
//
ENUM_TIMEFRAMES GetPeriod()
{
return inputs.period;
}
//
bool GetConsitions(
X121SetupConditions &conditions, //
int barIndex = 0, //
int loopback = 5 //
)
{
//
bool result = false;
//
result = cycle.Update(
barIndex //
);
//
result = setup.GetConditions(
conditions,
barIndex,
loopback //
);
//
return result;
}
};
//
// Class ...
class XSCX121SetupCycles : public XSCBaseAlert
{
//
// Public ...
public:
//
// Props ...
//
// Constructor(s) ...
void XSCX121SetupCycles() {}
//
// Deconstructor ...
void ~XSCX121SetupCycles() {}
//
// Initialized ...
bool Init(
X121SetupInputs &_inputs, // Configurations
string _symbol, // Trading Symbol
ENUM_TIMEFRAMES _hostPeriod, // Host Period
ENUM_X_PERIOD_METHOD _sMethod = X_PERIOD_AUTO, // Short Period Selection Method
ENUM_TIMEFRAMES _sPeriod = NULL, // Short Provided Period
ENUM_X_PERIOD_METHOD _mMethod = X_PERIOD_AUTO, // Medium Period Selection Method
ENUM_TIMEFRAMES _mPeriod = NULL, // Medium Provided Period
ENUM_X_PERIOD_METHOD _lMethod = X_PERIOD_AUTO, // Long Period Selection Method
ENUM_TIMEFRAMES _lPeriod = NULL, // Long Provided Period
ENUM_X_PERIOD_METHOD _hMethod = X_PERIOD_AUTO, // Hind Period Selection Method
ENUM_TIMEFRAMES _hPeriod = NULL // Hind Provided Period
)
{
//
bool result = false;
//
// Check Validation of Symbol and Period ...
result =
//
IsValid(_symbol) &&
IsValid(_hostPeriod)
//
;
if (!result)
{
return result;
}
//
// Initialize Market Cycles ...
//
// Current ...
_inputs.symbol = _symbol;
result = cCycle.Init(
_inputs,
_hostPeriod,
X_MARKET_CYCLE_SHORT,
X_PERIOD_MANUALLY,
_hostPeriod,
"CURR" //
);
if (!result)
{
return result;
}
//
// Short ...
result = sCycle.Init(
_inputs,
_hostPeriod,
X_MARKET_CYCLE_SHORT,
_sMethod,
_sPeriod //
);
if (!result)
{
return result;
}
//
// Medium ...
result = mCycle.Init(
_inputs,
_hostPeriod,
X_MARKET_CYCLE_MEDIUM,
_mMethod,
_mPeriod //
);
if (!result)
{
return result;
}
//
// Long ...
result = lCycle.Init(
_inputs,
_hostPeriod,
X_MARKET_CYCLE_LONG,
_lMethod,
_lPeriod //
);
if (!result)
{
return result;
}
//
// Hind ...
result = hCycle.Init(
_inputs,
_hostPeriod,
X_MARKET_CYCLE_HIND,
_hMethod,
_hPeriod //
);
if (!result)
{
return result;
}
//
_inputs.period = cCycle.GetPeriod();
//
this.inputs = _inputs;
result = inputs.IsValid();
//
return result;
}
//
// Getter(s) / Setter(s) ...
//
X121SetupInputs GetInputs()
{
return this.inputs;
}
//
bool SetInputs(
X121SetupInputs &_inputs // Cycles Configurations
)
{
//
bool result = Init(
_inputs,
_inputs.symbol,
_inputs.period //
);
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
//
X121SetupInputs inputs; // Cycles Configurations
//
X121SetupCycleInputs cCycle; // Current (Host) Cycle
X121SetupCycleInputs sCycle; // Short Cycle
X121SetupCycleInputs mCycle; // Medium Cycle
X121SetupCycleInputs lCycle; // Long Cycle
X121SetupCycleInputs hCycle; // Hind Cycle
}