Last Works ...
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#
|
#
|
||||||
Logs
|
Logs
|
||||||
|
Files
|
||||||
Images
|
Images
|
||||||
Include
|
Include
|
||||||
Scripts
|
Scripts
|
||||||
|
|||||||
@@ -0,0 +1,274 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Class Library
|
||||||
|
// --------------------------------------
|
||||||
|
// Name: XCPanel
|
||||||
|
// Description: provides all based classes for use ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// 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 <Controls/Dialog.mqh>
|
||||||
|
|
||||||
|
//
|
||||||
|
#include "../Classes/x-saherelm.base.class.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extentions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check a Qery Contains in a Content or not ...
|
||||||
|
*
|
||||||
|
* @param mQuery: String ...
|
||||||
|
* @param mContent: String ...
|
||||||
|
* @param ignoreCase: Boolean ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool XContains(
|
||||||
|
string mQuery, // Search String
|
||||||
|
string mContent, // Search Content
|
||||||
|
bool ignoreCase = true // Ignore Case
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return Contains(
|
||||||
|
mQuery,
|
||||||
|
mContent,
|
||||||
|
ignoreCase //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implementation ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// a Base App Dialog Class ...
|
||||||
|
class XCAppDialog : public CAppDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Action ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virual ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override Close Button Click Action ...
|
||||||
|
*/
|
||||||
|
void OnClickButtonClose()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool isClosed = ConfirmDialog("Close EA ?");
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isClosed)
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Configuration Actions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show or Hide Minimize Button ...
|
||||||
|
*
|
||||||
|
* @param show: boolean
|
||||||
|
*/
|
||||||
|
void MinimizeButton(bool show)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int controlIDX = ControlFind("MinMax");
|
||||||
|
if (!IsValidIndex(controlIDX))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
Control(controlIDX).Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Control(controlIDX).Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show or Hide Close Button ...
|
||||||
|
*
|
||||||
|
* @param show: boolean
|
||||||
|
*/
|
||||||
|
void CloseButton(bool show)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int controlIDX = ControlFind("Close");
|
||||||
|
if (!IsValidIndex(controlIDX))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
Control(controlIDX).Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Control(controlIDX).Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimize Functionality Implementation ...
|
||||||
|
*/
|
||||||
|
void Minimize()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
m_minimized = true;
|
||||||
|
Rebound(m_min_rect);
|
||||||
|
ClientAreaVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Background Color ...
|
||||||
|
*
|
||||||
|
* @param clr: Color ...
|
||||||
|
*/
|
||||||
|
void BackgroundColor(color clr)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int controlIDX = ControlFind("Client");
|
||||||
|
if (!IsValidIndex(controlIDX))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
CWnd *obj = Control(controlIDX);
|
||||||
|
CWndClient *wndclient = (CWndClient *)obj;
|
||||||
|
|
||||||
|
//
|
||||||
|
wndclient.ColorBackground(clr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
protected:
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find Specific Control in Dialog ...
|
||||||
|
*
|
||||||
|
* @param name: String to Search
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int ControlFind(string name)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid(name))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ControlsTotal();
|
||||||
|
if (!IsValidSize(count))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string iName = Control(i).Name();
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isContains = XContains(
|
||||||
|
name,
|
||||||
|
iName,
|
||||||
|
true // Ignore Case ...
|
||||||
|
);
|
||||||
|
if (isContains)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and Run Confirm Dialog ...
|
||||||
|
*
|
||||||
|
* @param message: message for Message Box ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool ConfirmDialog(string message = NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid(message)) {
|
||||||
|
message = "Confirm ?";
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int dialogResult = MessageBox(message, NULL, MB_YESNO);
|
||||||
|
|
||||||
|
//
|
||||||
|
// use 'switch' or 'if' as needed
|
||||||
|
switch (dialogResult)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Yes ...
|
||||||
|
case IDYES:
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
//
|
||||||
|
// No ...
|
||||||
|
case IDNO:
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
//
|
||||||
|
// Cancel ...
|
||||||
|
case IDCANCEL:
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
@@ -23,25 +23,12 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Imports ...
|
// Imports ...
|
||||||
|
#include "../Classes/x-saherelm.x-app-dialog.class.mq5"
|
||||||
#include "../Classes/x-saherelm.xalert.class.mq5"
|
#include "../Classes/x-saherelm.xalert.class.mq5"
|
||||||
#include "../Classes/x-saherelm.xtrade.class.mq5"
|
#include "../Classes/x-saherelm.xtrade.class.mq5"
|
||||||
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
||||||
#include "../Helpers/x-saherelm.xct.helper.mq5"
|
#include "../Helpers/x-saherelm.xct.helper.mq5"
|
||||||
|
|
||||||
//
|
|
||||||
// Undifine and Redfine Dialog Styles ...
|
|
||||||
|
|
||||||
// //
|
|
||||||
// #include <Controls/Defines.mqh>
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Here we can Do all Styling ...
|
|
||||||
// #undef CONTROLS_DIALOG_COLOR_CLIENT_BG
|
|
||||||
// #define CONTROLS_DIALOG_COLOR_CLIENT_BG clrMagenta
|
|
||||||
|
|
||||||
// //
|
|
||||||
// #include <Controls/Dialog.mqh>
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Inputs ...
|
// Inputs ...
|
||||||
|
|
||||||
@@ -83,7 +70,7 @@ XSCXCTHelper *eaCTHelper; // Bar Timer Indicator Helper class ...
|
|||||||
XSCXCCHelper *eaCCHelper; // Chart Styler Indicator Helper Class ...
|
XSCXCCHelper *eaCCHelper; // Chart Styler Indicator Helper Class ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// CAppDialog eaMainWindow; // EA Main Dialog ...
|
XCAppDialog eaMainWindow; // EA Main Dialog ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Event Handlers ...
|
// Event Handlers ...
|
||||||
@@ -204,7 +191,7 @@ void OnChartEvent(
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Apply Chart Event on Main Window ...
|
// Apply Chart Event on Main Window ...
|
||||||
// eaMainWindow.ChartEvent(id, lparam, dparam, sparam);
|
eaMainWindow.ChartEvent(id, lparam, dparam, sparam);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle OnClick Event ...
|
// Handle OnClick Event ...
|
||||||
@@ -429,29 +416,30 @@ bool InitGUI()
|
|||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
// //
|
//
|
||||||
// // Initialize Application Main Window ...
|
// Initialize Application Main Window ...
|
||||||
// result = eaMainWindow.Create(
|
result = eaMainWindow.Create(
|
||||||
// ChartID(),
|
ChartID(),
|
||||||
// ShortName, // Dialog Name ...
|
ShortName, // Dialog Name ...
|
||||||
// 0, // SubWindow ...
|
0, // SubWindow ...
|
||||||
// 10, // X1 ...
|
10, // X1 ...
|
||||||
// 35, // Y1 ...
|
35, // Y1 ...
|
||||||
// 300, // X2 ...
|
300, // X2 ...
|
||||||
// 200 // Y2 ...
|
200 // Y2 ...
|
||||||
// );
|
);
|
||||||
|
|
||||||
// //
|
//
|
||||||
// // Configuring Dialog ...
|
// Configuring Dialog ...
|
||||||
// eaMainWindow.Control(3).Hide(); // Hide Minimize Button ...
|
// eaMainWindow.MinimizeButton(false); // Hide Minimize Button ...
|
||||||
// eaMainWindow.Control(5).Hide(); // Hide Close Button ...
|
// eaMainWindow.CloseButton(false); // Hide Close Button ...
|
||||||
result = true;
|
eaMainWindow.BackgroundColor(clrBlack);
|
||||||
|
// result = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try To Run Main Window ...
|
// Try To Run Main Window ...
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
// eaMainWindow.Run();
|
eaMainWindow.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -473,7 +461,7 @@ void UpdateGUI()
|
|||||||
void DestroyGUI()
|
void DestroyGUI()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// eaMainWindow.Destroy();
|
eaMainWindow.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -0,0 +1,568 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center XTest MQL5 Expert Advisor
|
||||||
|
// -------------------------------------------------
|
||||||
|
// Name: X121SMCEA
|
||||||
|
// Description: an Exper Advisor which used Panels
|
||||||
|
//
|
||||||
|
// Maintainer:
|
||||||
|
// ------------
|
||||||
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////x
|
||||||
|
//
|
||||||
|
// Global Properties ...
|
||||||
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
|
#property link "https://saherelm.ir"
|
||||||
|
#property version "1.00"
|
||||||
|
#property description "SaherElm X121SMCEA"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
#define ShortName "X121SMCEA"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Imports ...
|
||||||
|
#include "../Classes/x-saherelm.xalert.class.mq5"
|
||||||
|
#include "../Classes/x-saherelm.xtrade.class.mq5"
|
||||||
|
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
||||||
|
#include "../Helpers/x-saherelm.xct.helper.mq5"
|
||||||
|
#include "../X121SMCEA/Classes/x-121.smc.ea.panel.class.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Common ...
|
||||||
|
input group "Common";
|
||||||
|
input long eaMagicNumber = 78692110; // Magic Number
|
||||||
|
input int eaSlippage = 10; // Slippgae
|
||||||
|
input string eaLogSuffix = ""; // Log Suffix
|
||||||
|
|
||||||
|
//
|
||||||
|
// Alert ...
|
||||||
|
// Here we Provider All Requirements for
|
||||||
|
// Configuring Alert Provider ...
|
||||||
|
input group "Alert";
|
||||||
|
input bool eAEnableAlerts = true; // Enable Alerts
|
||||||
|
input bool eALogAlerts = true; // Log Alerts
|
||||||
|
input bool eAMailAlerts = false; // Mail Alerts
|
||||||
|
input bool eAPushAlerts = false; // Push Alerts
|
||||||
|
input bool eATerminalAlerts = false; // Terminal Alerts
|
||||||
|
|
||||||
|
//
|
||||||
|
// Time Report ...
|
||||||
|
input group "Reports";
|
||||||
|
input bool eaReportNewMonths = false; // Report New Month
|
||||||
|
input bool eaReportNewWeeks = false; // Report New Weeks
|
||||||
|
input bool eaReportNewDays = false; // Report New Days
|
||||||
|
input bool eaReportNewHours = false; // Report New Hours
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define Local Variables ...
|
||||||
|
|
||||||
|
//
|
||||||
|
string eaLogTag; // EA Log Prefix ...
|
||||||
|
XSCAlert *eaAlert; // Alert Provider for Expert Adviser ...
|
||||||
|
XSCTrade *eaTrader; // Trader of Expert Adviser ...
|
||||||
|
XTimeTracker eaTimeTracker; // Time Tracker for Providing Reports ...
|
||||||
|
XSCXCTHelper *eaCTHelper; // Bar Timer Indicator Helper class ...
|
||||||
|
XSCXCCHelper *eaCCHelper; // Chart Styler Indicator Helper Class ...
|
||||||
|
X121CAppDialog eaMainWindow; // EA Main Dialog ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Event Handlers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialization ...
|
||||||
|
int OnInit()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Inputs and Required Parameters
|
||||||
|
// for EA to Works fine ...
|
||||||
|
if (!ValidateInputs())
|
||||||
|
{
|
||||||
|
return INIT_PARAMETERS_INCORRECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Timer ...
|
||||||
|
if (!InitTimer())
|
||||||
|
{
|
||||||
|
return INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize all Requirements ...
|
||||||
|
if (!InitEA())
|
||||||
|
{
|
||||||
|
return INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize all GUI Objects and Classes ...
|
||||||
|
if (!InitGUI())
|
||||||
|
{
|
||||||
|
return INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Alert Initialization ...
|
||||||
|
string msg = "Initialized Successfully ...";
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
|
||||||
|
//
|
||||||
|
// Destroy Timer ...
|
||||||
|
DestroyTimer();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Destroy all GUI Requirements ...
|
||||||
|
DestroyGUI();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Alert De Initialization Succeeded ...
|
||||||
|
string msg = "De Initialized Successfully ...";
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Destroy all EA Requirements ...
|
||||||
|
DestroyEA();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// On Tick Handler ...
|
||||||
|
void OnTick()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
UpdateGUI();
|
||||||
|
HandleReportTime();
|
||||||
|
UpdatePositionsState();
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Implemetn Tick Processors Algorithm ...
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle On Trade Event ...
|
||||||
|
void OnTrade()
|
||||||
|
{
|
||||||
|
eaTrader.HandleOnTrade();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// On Timer ...
|
||||||
|
void OnTimer()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// TODO: Implement Time Based Functionalities ...
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Chart Event Handler ...
|
||||||
|
void OnChartEvent(
|
||||||
|
const int id,
|
||||||
|
const long &lparam,
|
||||||
|
const double &dparam,
|
||||||
|
const string &sparam //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Apply Chart Event on Main Window ...
|
||||||
|
eaMainWindow.ChartEvent(id, lparam, dparam, sparam);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle OnClick Event ...
|
||||||
|
if (id == CHARTEVENT_OBJECT_CLICK)
|
||||||
|
{
|
||||||
|
HandleOnClickEvent(sparam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Custom Event Handlers ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle StopLoss Triggered Positions ...
|
||||||
|
*
|
||||||
|
* @param deal: XDeal ...
|
||||||
|
*/
|
||||||
|
void OnStopLossTriggered(const XDeal &deal)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
HandleReportBalance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Take Profit Triggered Positions ...
|
||||||
|
*
|
||||||
|
* @param deal: XDeal ...
|
||||||
|
*/
|
||||||
|
void OnTakeProfitTriggered(const XDeal &deal)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
HandleReportBalance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Force Close a Position ...
|
||||||
|
*
|
||||||
|
* @param ticket: Position Ticket ...
|
||||||
|
* @param position: XPosition ...
|
||||||
|
* @param comment: Closing Comment ...
|
||||||
|
*/
|
||||||
|
void OnPositionForceClosed(
|
||||||
|
const ulong ticket,
|
||||||
|
const XPosition &position,
|
||||||
|
const string comment //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
HandleReportBalance();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Custom Functions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate all Inputs of Expert Adviser ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool ValidateInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
string errMessage = "";
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isCommonValid = (
|
||||||
|
//
|
||||||
|
eaSlippage > 0 &&
|
||||||
|
eaMagicNumber > 0
|
||||||
|
//
|
||||||
|
);
|
||||||
|
if (!isCommonValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
errMessage += "common configurations error;" + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
// Common ...
|
||||||
|
isCommonValid &&
|
||||||
|
//
|
||||||
|
// Otere ...
|
||||||
|
true
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Since here Logger not Initiallized, we Use Raw Print Command ...
|
||||||
|
Print(ShortName + " Errors: \n", errMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Timer ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool InitTimer()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Initialize Timer if necessary ...
|
||||||
|
// result = EventSetTimer(1);
|
||||||
|
// result = EventSetMillisecondTimer(100);
|
||||||
|
result = true;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy Timer ...
|
||||||
|
*/
|
||||||
|
void DestroyTimer()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// TODO: Use This ...
|
||||||
|
// EventKillTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize all Requirements for Working Fine ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool InitEA()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Locally Apply Changes on Prefix ...
|
||||||
|
eaLogTag = ShortName + ">" + eaLogSuffix;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bar Timer ...
|
||||||
|
XCTInputs ctInputs;
|
||||||
|
ctInputs.Default(); // Default Configurations ...
|
||||||
|
eaCTHelper = new XSCXCTHelper();
|
||||||
|
result = eaCTHelper.Init(
|
||||||
|
_Symbol,
|
||||||
|
_Period,
|
||||||
|
ctInputs //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bar Styles ...
|
||||||
|
XCCInputs ccInputs;
|
||||||
|
ccInputs.Default(); // Default Configurations ...
|
||||||
|
eaCCHelper = new XSCXCCHelper();
|
||||||
|
result = eaCCHelper.Init(
|
||||||
|
_Symbol,
|
||||||
|
_Period,
|
||||||
|
ccInputs //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create Instance of Alert Class and Configure it ...
|
||||||
|
eaAlert = new XSCAlert();
|
||||||
|
eaAlert.SetPrefix(eaLogTag);
|
||||||
|
eaAlert.SetLogAlerts(eALogAlerts);
|
||||||
|
eaAlert.SetMailAlerts(eAMailAlerts);
|
||||||
|
eaAlert.SetPushAlerts(eAPushAlerts);
|
||||||
|
eaAlert.SetEnableAlerts(eAEnableAlerts);
|
||||||
|
eaAlert.SetTerminalAlerts(eATerminalAlerts);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create Trader Instance and Configure it ...
|
||||||
|
eaTrader = new XSCTrade(
|
||||||
|
eaSlippage,
|
||||||
|
eaMagicNumber //
|
||||||
|
);
|
||||||
|
eaTrader.AddOnStopLossEventHandler(OnStopLossTriggered);
|
||||||
|
eaTrader.AddOnTakeProfitEventHandler(OnTakeProfitTriggered);
|
||||||
|
eaTrader.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy all Initialized EA Requirements ...
|
||||||
|
*/
|
||||||
|
void DestroyEA()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
delete eaCTHelper;
|
||||||
|
delete eaCCHelper;
|
||||||
|
|
||||||
|
//
|
||||||
|
delete eaAlert;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize all GUI Requirements for EA ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool InitGUI()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Application Main Window ...
|
||||||
|
result = eaMainWindow.Create(
|
||||||
|
ChartID(),
|
||||||
|
ShortName, // Dialog Name ...
|
||||||
|
0, // SubWindow ...
|
||||||
|
10, // X1 ...
|
||||||
|
35, // Y1 ...
|
||||||
|
300, // X2 ...
|
||||||
|
200 // Y2 ...
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try To Run Main Window ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
eaMainWindow.Configure();
|
||||||
|
eaMainWindow.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update GUI based on Each Ticks ...
|
||||||
|
*/
|
||||||
|
void UpdateGUI()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// TODO: Implement this ...
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy all Initialized GUi Requirements ...
|
||||||
|
*/
|
||||||
|
void DestroyGUI()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
eaMainWindow.Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Others ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Positions States ...
|
||||||
|
*/
|
||||||
|
void UpdatePositionsState()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// TODO: Implement this ...
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle On Click Event for GUI Components ...
|
||||||
|
*
|
||||||
|
* @param name: Object Name ...
|
||||||
|
*/
|
||||||
|
void HandleOnClickEvent(string name)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (!IsValid(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isClicked = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Implement Chart Objects On Click ...
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isClicked)
|
||||||
|
{
|
||||||
|
UpdateGUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report Account Balance ...
|
||||||
|
*/
|
||||||
|
void HandleReportBalance()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (!IsRunningOnTestMode())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string msg = "Balance: " + ToString(eaTrader.mAccount.GetBalance());
|
||||||
|
eaAlert.Log(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time Reporting based on Inputs ...
|
||||||
|
*/
|
||||||
|
void HandleReportTime()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Monthly Report ....
|
||||||
|
if (eaReportNewMonths &&
|
||||||
|
eaTimeTracker.IsNewMonth())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Month ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Weekly Report ....
|
||||||
|
if (eaReportNewWeeks &&
|
||||||
|
eaTimeTracker.IsNewWeek())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Week ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Daily Report ....
|
||||||
|
if (eaReportNewDays &&
|
||||||
|
eaTimeTracker.IsNewDay())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Day ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Hourly Report ....
|
||||||
|
if (eaReportNewHours &&
|
||||||
|
eaTimeTracker.IsNewHour())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Hour ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,63 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Class Library
|
||||||
|
// --------------------------------------
|
||||||
|
// Name: XC121Panel
|
||||||
|
// Description: provides all based classes for use ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// 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.x-app-dialog.class.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implementation ...
|
||||||
|
|
||||||
|
//
|
||||||
|
class X121CAppDialog : public XCAppDialog
|
||||||
|
{
|
||||||
|
//
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Constructor(s) ...
|
||||||
|
void X121CAppDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deconstructor ...
|
||||||
|
void ~X121CAppDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void Configure()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Configure Dialog ...
|
||||||
|
BackgroundColor(clrBlack);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
protected:
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
Reference in New Issue
Block a user