add new template projects for future works and also add related npm scripts ...
This commit is contained in:
@@ -0,0 +1,347 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Expert Advisor
|
||||
// ----------------------------------------
|
||||
// Name: XAUUSD
|
||||
// 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 XGPUS5 EA"
|
||||
#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"
|
||||
|
||||
//
|
||||
// XGPUS5 Signal Provider ...
|
||||
#include "../Providers/x-saherelm.xgpus5.provider.lib.mq5"
|
||||
|
||||
//
|
||||
// END Including Providers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
bool isXGPUS5NewHour;
|
||||
bool isXGPUS5NewDay;
|
||||
bool isXGPUS5NewWeek;
|
||||
bool isXGPUS5NewMonth;
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
logTag = "XGPUS5EA";
|
||||
drawPrefix = logTag;
|
||||
alertPrefix = logTag;
|
||||
|
||||
//
|
||||
// Apply default Chart Style for EA ...
|
||||
ApplyChartStyle();
|
||||
|
||||
//
|
||||
// Reset Timings ...
|
||||
ResetTiming();
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize XGPUS5 Provider ...
|
||||
if (!XGPUS5InitSignalProviderLibrary())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 XGPUS5 Provider ...
|
||||
XGPUS5DeinitSignalProviderLibrary(reason);
|
||||
|
||||
//
|
||||
// De Init XDraw Library ...
|
||||
// OnDeinitDrawLibrary();
|
||||
}
|
||||
|
||||
//
|
||||
// On Tick Handler ...
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
// Handle Monthly Alert ...
|
||||
bool isFirstMonth = xMonth == -1;
|
||||
isXGPUS5NewMonth = IsNewMonth();
|
||||
bool canMonthlyAlert =
|
||||
isXGPUS5NewMonth &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableMonthlyAlerts;
|
||||
bool canMonthlyReport =
|
||||
!isFirstMonth &&
|
||||
canMonthlyAlert &&
|
||||
xGPUS5EnableMonthlyReports;
|
||||
if (canMonthlyAlert)
|
||||
{
|
||||
//
|
||||
string message = "New Month ...";
|
||||
|
||||
//
|
||||
// Prepare Monthly Report ...
|
||||
if (canMonthlyReport)
|
||||
{
|
||||
//
|
||||
string report = xGPUS5Reporter.GenerateReportString(XREPORT_MONTHLY);
|
||||
|
||||
//
|
||||
message = "Last Month Report:\n" + report;
|
||||
}
|
||||
|
||||
//
|
||||
// Reset Report ...
|
||||
xGPUS5Reporter.Reset(XREPORT_MONTHLY);
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Weekly Alert ...
|
||||
bool isFirstWeek = xDayOfWeek == -1;
|
||||
isXGPUS5NewWeek = IsNewWeek();
|
||||
bool canWeeklyAlert =
|
||||
isXGPUS5NewWeek &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableWeeklyAlerts;
|
||||
bool canWeeklyReport =
|
||||
!isFirstWeek &&
|
||||
canWeeklyAlert &&
|
||||
xGPUS5EnableWeeklyReports;
|
||||
if (canWeeklyAlert)
|
||||
{
|
||||
//
|
||||
string message = "New Week ...";
|
||||
|
||||
//
|
||||
// Prepare Weekly Report ...
|
||||
if (canWeeklyReport)
|
||||
{
|
||||
//
|
||||
string report = xGPUS5Reporter.GenerateReportString(XREPORT_WEEKLY);
|
||||
|
||||
//
|
||||
message = "Last Week Report:\n" + report;
|
||||
}
|
||||
|
||||
//
|
||||
// Reset Report ...
|
||||
xGPUS5Reporter.Reset(XREPORT_WEEKLY);
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Daily Alert ...
|
||||
bool isFirstDay = xDay == -1;
|
||||
isXGPUS5NewDay = IsNewDay();
|
||||
bool canDailyAlert =
|
||||
isXGPUS5NewDay &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableDailyAlerts;
|
||||
bool canDailyReport =
|
||||
!isFirstDay &&
|
||||
canDailyAlert &&
|
||||
xGPUS5EnableDailyReports;
|
||||
if (canDailyAlert)
|
||||
{
|
||||
//
|
||||
string message = "New Day ...";
|
||||
|
||||
//
|
||||
// Prepare Daily Report ...
|
||||
if (canDailyReport)
|
||||
{
|
||||
//
|
||||
string report = xGPUS5Reporter.GenerateReportString(XREPORT_DAILY);
|
||||
|
||||
//
|
||||
message = "Last Week Report:\n" + report;
|
||||
}
|
||||
|
||||
//
|
||||
// Reset Report ...
|
||||
xGPUS5Reporter.Reset(XREPORT_DAILY);
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Hourly Alert ...
|
||||
bool isFirstHour = xHour == -1;
|
||||
isXGPUS5NewHour = IsNewHour();
|
||||
bool canHourlyAlert =
|
||||
isXGPUS5NewHour &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableHourlyAlerts;
|
||||
if (canHourlyAlert)
|
||||
{
|
||||
//
|
||||
string message = "New Hour ...";
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xGPUS5EnableProvider)
|
||||
{
|
||||
//
|
||||
// Handle Processing on XGPUS5 Signal Provider ...
|
||||
XGPUS5SignalProviderDoControlState();
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsNewCandle())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xGPUS5EnableProvider)
|
||||
{
|
||||
//
|
||||
// Handle Processing on XGPUS5 Signal Provider ...
|
||||
XGPUS5SignalProviderHandleTick();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Trade Events ...
|
||||
void OnTrade()
|
||||
{
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xGPUS5EnableProvider)
|
||||
{
|
||||
//
|
||||
// Handle Processing Trades on XGPUS5 Signal Provider ...
|
||||
XGPUS5SignalProviderHandleTrade();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// END Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
|
||||
//
|
||||
// Validate XGPUS5 Provider Inputs ...
|
||||
result = XGPUS5ValidateInputs();
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Logging State ...
|
||||
string message = "Validation of (" + logTag + ") Inputs " + (result ? "Succeeded" : "Failed") + " ...";
|
||||
LogMessage(message);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
Reference in New Issue
Block a user