193 lines
3.6 KiB
Plaintext
193 lines
3.6 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Expert Advisor
|
|
// ----------------------------------------
|
|
// Name: XEA
|
|
// Description: this is an expert controller
|
|
// advisors which provides a mechanism for use them ...
|
|
//
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://saherelm.ir"
|
|
#property version "1.00"
|
|
#property description "SaherElm XEA"
|
|
#property strict
|
|
|
|
//
|
|
// START Inputs ...
|
|
//
|
|
|
|
input group "Commons";
|
|
|
|
//
|
|
// END Inputs ...
|
|
//
|
|
|
|
//
|
|
// START Including Providers ...
|
|
//
|
|
|
|
//
|
|
// Logger Library ...
|
|
#include "..\Libraries\x-saherelm.log.lib.mq5";
|
|
|
|
//
|
|
// Common Library ...
|
|
#include "..\Libraries\x-saherelm.common.lib.mq5";
|
|
|
|
//
|
|
// Alert Library ...
|
|
#include "..\Libraries\x-saherelm.alert.lib.mq5";
|
|
|
|
//
|
|
// Draw Library ...
|
|
#include "..\Libraries\x-saherelm.draw.lib.mq5";
|
|
|
|
//
|
|
// XEU5 Signal Provider ...
|
|
#include "..\Libraries\x-saherelm.xeu5.provider.lib.mq5";
|
|
|
|
//
|
|
// END Including Providers ...
|
|
//
|
|
|
|
//
|
|
// START Global Definitions: Variables, Properties and etc ...
|
|
//
|
|
|
|
//
|
|
// END Global Definitions: Variables, Properties and etc ...
|
|
//
|
|
|
|
//
|
|
// START Event Handlers ...
|
|
//
|
|
|
|
//
|
|
// Initialization ...
|
|
int OnInit()
|
|
{
|
|
//
|
|
logTag = "XEA";
|
|
drawPrefix = logTag;
|
|
alertPrefix = logTag;
|
|
|
|
//
|
|
// Validate Inputs ...
|
|
if (!ValidateInputs())
|
|
{
|
|
return INIT_PARAMETERS_INCORRECT;
|
|
}
|
|
|
|
//
|
|
// Initialize XEU5 Provider ...
|
|
if (!XEU5InitSignalProviderLibrary())
|
|
{
|
|
return INIT_PARAMETERS_INCORRECT;
|
|
}
|
|
|
|
//
|
|
// Apply default Chart Style for EA ...
|
|
ApplyChartStyle();
|
|
|
|
//
|
|
// Init Succeed ...
|
|
return INIT_SUCCEEDED;
|
|
}
|
|
|
|
//
|
|
// DeInitialization ...
|
|
void OnDeinit(const int reason)
|
|
{
|
|
//
|
|
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
|
// REASON_REMOVE 1 Program removed from a chart
|
|
// REASON_RECOMPILE 2 Program recompiled
|
|
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
|
|
// REASON_CHARTCLOSE 4 Chart closed
|
|
// REASON_PARAMETERS 5 Inputs changed by a user
|
|
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
|
|
// REASON_TEMPLATE 7 Another chart template applied
|
|
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
|
// REASON_CLOSE 9 Terminal closed
|
|
|
|
//
|
|
// Here we can handle De Initialization Reasons ...
|
|
|
|
//
|
|
// De Initialize XEU5 Provider ...
|
|
XEU5DeinitSignalProviderLibrary(reason);
|
|
|
|
//
|
|
// De Init XDraw Library ...
|
|
// OnDeinitDrawLibrary();
|
|
}
|
|
|
|
//
|
|
// On Tick Handler ...
|
|
void OnTick()
|
|
{
|
|
//
|
|
// Prevent Going Forward if user Disable it ...
|
|
if (!xEU5EnableProvider)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
if (!IsNewCandle())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Handle Processing on XEU5 Signal Provider ...
|
|
XEU5SignalProviderHandleTick();
|
|
}
|
|
|
|
//
|
|
// END Event Handlers ...
|
|
//
|
|
|
|
//
|
|
// START Functions ...
|
|
//
|
|
|
|
//
|
|
// Validate Input Args for Initialization ...
|
|
bool ValidateInputs()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
|
|
//
|
|
// Validate XEU5 Provider Inputs ...
|
|
result = XEU5ValidateInputs();
|
|
if (!result)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//
|
|
// Logging State ...
|
|
string message = "Validation of (" + "XEA" + ") Inputs " + (result ? "Succeeded" : "Failed") + " ...";
|
|
LogMessage(message);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// END Functions ...
|
|
//
|