refactor for xTestEa all Workspace and Cleanup Providers Market Conditions ...

This commit is contained in:
2024-03-25 03:13:16 +03:30
parent f7061cde0f
commit fa4c3098a9
6 changed files with 2695 additions and 7047 deletions
@@ -2,7 +2,7 @@
//
// SaherElm IT Center MQL5 Expert Advisor
// ----------------------------------------
// Name: XBTUS5
// Name: XTEST
// Description: this is an expert controller
// advisors which provides a mechanism for use them ...
//
@@ -17,7 +17,7 @@
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XBTUS5 EA"
#property description "SaherElm XTEST EA"
#property strict
//
@@ -28,9 +28,9 @@ input group "Commons";
//
// XCTIMER inputs ...
input bool xBTUS5ShowCandleTimer = true; // Show Condle Remaining Time
input color xBTUS5CandleTimerColot = clrYellow; // Candle Timer Color
input ENUM_BASE_CORNER xBTUS5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
input bool xTESTShowCandleTimer = true; // Show Condle Remaining Time
input color xTESTCandleTimerColot = clrYellow; // Candle Timer Color
input ENUM_BASE_CORNER xTESTCandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
//
// END Inputs ...
@@ -57,8 +57,8 @@ input ENUM_BASE_CORNER xBTUS5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to
#include "../Libraries/x-saherelm.draw.lib.mq5"
//
// XBTUS5 Signal Provider ...
#include "../Providers/x-saherelm.xbtus5.provider.lib.mq5"
// XTEST Signal Provider ...
#include "../Providers/x-saherelm.xtest.provider.lib.mq5"
//
// END Including Providers ...
@@ -67,13 +67,13 @@ input ENUM_BASE_CORNER xBTUS5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to
//
// START Global Definitions: Variables, Properties and etc ...
//
bool isXBTUS5NewHour;
bool isXBTUS5NewDay;
bool isXBTUS5NewWeek;
bool isXBTUS5NewMonth;
bool isXTESTNewHour;
bool isXTESTNewDay;
bool isXTESTNewWeek;
bool isXTESTNewMonth;
//
int xBTUS5CTimerHandler = INVALID_HANDLE;
int xTESTCTimerHandler = INVALID_HANDLE;
//
// END Global Definitions: Variables, Properties and etc ...
//
@@ -87,7 +87,7 @@ int xBTUS5CTimerHandler = INVALID_HANDLE;
int OnInit()
{
//
logTag = "XBTUS5EA";
logTag = "XTESTEA";
drawPrefix = logTag;
alertPrefix = logTag;
@@ -107,17 +107,17 @@ int OnInit()
}
//
// Initialize XBTUS5 Provider ...
if (!XBTUS5InitSignalProviderLibrary())
// Initialize XTEST Provider ...
if (!XTESTInitSignalProviderLibrary())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// Init XCTimer ...
if (xBTUS5ShowCandleTimer)
if (xTESTShowCandleTimer)
{
if (!XBTUS5CTimerInit())
if (!XTESTCTimerInit())
{
return INIT_FAILED;
}
@@ -148,15 +148,15 @@ void OnDeinit(const int reason)
// Here we can handle De Initialization Reasons ...
//
// De Initialize XBTUS5 Provider ...
XBTUS5DeinitSignalProviderLibrary(reason);
// De Initialize XTEST Provider ...
XTESTDeinitSignalProviderLibrary(reason);
//
// De Init XDraw Library ...
// OnDeinitDrawLibrary();
//
IndicatorRelease(xBTUS5CTimerHandler);
IndicatorRelease(xTESTCTimerHandler);
}
//
@@ -166,15 +166,15 @@ void OnTick()
//
// Handle Monthly Alert ...
bool isFirstMonth = xMonth == -1;
isXBTUS5NewMonth = IsNewMonth();
isXTESTNewMonth = IsNewMonth();
bool canMonthlyAlert =
isXBTUS5NewMonth &&
xBTUS5EnableAlerts &&
xBTUS5EnableMonthlyAlerts;
isXTESTNewMonth &&
xTESTEnableAlerts &&
xTESTEnableMonthlyAlerts;
bool canMonthlyReport =
!isFirstMonth &&
canMonthlyAlert &&
xBTUS5EnableMonthlyReports;
xTESTEnableMonthlyReports;
if (canMonthlyAlert)
{
//
@@ -185,7 +185,7 @@ void OnTick()
if (canMonthlyReport)
{
//
string report = xBTUS5Reporter.GenerateReportString(XREPORT_MONTHLY);
string report = xTESTReporter.GenerateReportString(XREPORT_MONTHLY);
//
message = "Last Month Report:\n" + report;
@@ -193,7 +193,7 @@ void OnTick()
//
// Reset Report ...
xBTUS5Reporter.Reset(XREPORT_MONTHLY);
xTESTReporter.Reset(XREPORT_MONTHLY);
//
SendAlert(message);
@@ -202,15 +202,15 @@ void OnTick()
//
// Handle Weekly Alert ...
bool isFirstWeek = xDayOfWeek == -1;
isXBTUS5NewWeek = IsNewWeek();
isXTESTNewWeek = IsNewWeek();
bool canWeeklyAlert =
isXBTUS5NewWeek &&
xBTUS5EnableAlerts &&
xBTUS5EnableWeeklyAlerts;
isXTESTNewWeek &&
xTESTEnableAlerts &&
xTESTEnableWeeklyAlerts;
bool canWeeklyReport =
!isFirstWeek &&
canWeeklyAlert &&
xBTUS5EnableWeeklyReports;
xTESTEnableWeeklyReports;
if (canWeeklyAlert)
{
//
@@ -221,7 +221,7 @@ void OnTick()
if (canWeeklyReport)
{
//
string report = xBTUS5Reporter.GenerateReportString(XREPORT_WEEKLY);
string report = xTESTReporter.GenerateReportString(XREPORT_WEEKLY);
//
message = "Last Week Report:\n" + report;
@@ -229,7 +229,7 @@ void OnTick()
//
// Reset Report ...
xBTUS5Reporter.Reset(XREPORT_WEEKLY);
xTESTReporter.Reset(XREPORT_WEEKLY);
//
SendAlert(message);
@@ -238,15 +238,15 @@ void OnTick()
//
// Handle Daily Alert ...
bool isFirstDay = xDay == -1;
isXBTUS5NewDay = IsNewDay();
isXTESTNewDay = IsNewDay();
bool canDailyAlert =
isXBTUS5NewDay &&
xBTUS5EnableAlerts &&
xBTUS5EnableDailyAlerts;
isXTESTNewDay &&
xTESTEnableAlerts &&
xTESTEnableDailyAlerts;
bool canDailyReport =
!isFirstDay &&
canDailyAlert &&
xBTUS5EnableDailyReports;
xTESTEnableDailyReports;
if (canDailyAlert)
{
//
@@ -257,7 +257,7 @@ void OnTick()
if (canDailyReport)
{
//
string report = xBTUS5Reporter.GenerateReportString(XREPORT_DAILY);
string report = xTESTReporter.GenerateReportString(XREPORT_DAILY);
//
message = "Last Week Report:\n" + report;
@@ -265,7 +265,7 @@ void OnTick()
//
// Reset Report ...
xBTUS5Reporter.Reset(XREPORT_DAILY);
xTESTReporter.Reset(XREPORT_DAILY);
//
SendAlert(message);
@@ -274,11 +274,11 @@ void OnTick()
//
// Handle Hourly Alert ...
bool isFirstHour = xHour == -1;
isXBTUS5NewHour = IsNewHour();
isXTESTNewHour = IsNewHour();
bool canHourlyAlert =
isXBTUS5NewHour &&
xBTUS5EnableAlerts &&
xBTUS5EnableHourlyAlerts;
isXTESTNewHour &&
xTESTEnableAlerts &&
xTESTEnableHourlyAlerts;
if (canHourlyAlert)
{
//
@@ -290,33 +290,33 @@ void OnTick()
//
// Prevent Going Forward if user Disable it ...
if (xBTUS5EnableProvider)
if (xTESTEnableProvider)
{
//
// Handle Processing on XBTUS5 Signal Provider ...
XBTUS5SignalProviderDoControlState();
// Handle Processing on XTEST Signal Provider ...
XTESTSignalProviderDoControlState();
}
//
// Check Can Ignore Tick or not ..
bool canIgnoreTick = xBTUS5IsTestMode
bool canIgnoreTick = xTESTIsTestMode
? !IsNewCandle()
: !IsNewCandle() && xBTUS5WaitUntilNextCandle;
: !IsNewCandle() && xTESTWaitUntilNextCandle;
if (canIgnoreTick)
{
return;
}
//
xBTUS5WaitUntilNextCandle = false;
xTESTWaitUntilNextCandle = false;
//
// Prevent Going Forward if user Disable it ...
if (xBTUS5EnableProvider)
if (xTESTEnableProvider)
{
//
// Handle Processing on XBTUS5 Signal Provider ...
XBTUS5SignalProviderHandleTick();
// Handle Processing on XTEST Signal Provider ...
XTESTSignalProviderHandleTick();
}
}
@@ -327,11 +327,11 @@ void OnTrade()
//
// Prevent Going Forward if user Disable it ...
if (xBTUS5EnableProvider)
if (xTESTEnableProvider)
{
//
// Handle Processing Trades on XBTUS5 Signal Provider ...
XBTUS5SignalProviderHandleTrade();
// Handle Processing Trades on XTEST Signal Provider ...
XTESTSignalProviderHandleTrade();
}
}
@@ -354,8 +354,8 @@ bool ValidateInputs()
// Validate Args ...
//
// Validate XBTUS5 Provider Inputs ...
result = XBTUS5ValidateInputs();
// Validate XTEST Provider Inputs ...
result = XTESTValidateInputs();
if (!result)
{
return false;
@@ -370,23 +370,23 @@ bool ValidateInputs()
return result;
}
bool XBTUS5CTimerInit()
bool XTESTCTimerInit()
{
//
bool result = true;
//
xBTUS5CTimerHandler = iCustom(
xTESTCTimerHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xctimer.indicator",
//
// Inputs ...
xBTUS5CandleTimerColot,
xBTUS5CandleTimerCorner);
xTESTCandleTimerColot,
xTESTCandleTimerCorner);
//
if (xBTUS5CTimerHandler == INVALID_HANDLE)
if (xTESTCTimerHandler == INVALID_HANDLE)
{
result = false;
}