remove and cleanup backups ...
This commit is contained in:
@@ -1,214 +0,0 @@
|
||||
|
||||
//
|
||||
// a Base Class by Support Alert ...
|
||||
class XCBaseAlert : public XCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XCBaseAlert()
|
||||
{
|
||||
//
|
||||
// Instance Alert ...
|
||||
mAlert = new XCAlert();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructors ...
|
||||
void ~XCBaseAlert()
|
||||
{
|
||||
//
|
||||
delete mAlert;
|
||||
|
||||
//
|
||||
ZeroMemory(mAlert);
|
||||
}
|
||||
|
||||
//
|
||||
// Alert Handler Functions ...
|
||||
|
||||
//
|
||||
// Alert Functions Getter(s) / Setters(s) ...
|
||||
|
||||
//
|
||||
string GetAlertPrefix()
|
||||
{
|
||||
return mAlert.GetPrefix();
|
||||
}
|
||||
|
||||
//
|
||||
void SetAlertPrefix(string value)
|
||||
{
|
||||
mAlert.SetPrefix(value);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetAlertLogAlerts()
|
||||
{
|
||||
return mAlert.GetLogAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetAlertLogAlerts(bool value)
|
||||
{
|
||||
mAlert.SetLogAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetAlertEnableAlerts()
|
||||
{
|
||||
return mAlert.GetEnableAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetAlertEnableAlerts(bool value)
|
||||
{
|
||||
mAlert.SetEnableAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetAlertPushAlerts()
|
||||
{
|
||||
return mAlert.GetPushAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetAlertPushAlerts(bool value)
|
||||
{
|
||||
mAlert.SetPushAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetAlertMailAlerts()
|
||||
{
|
||||
return mAlert.GetMailAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetAlertMailAlerts(bool value)
|
||||
{
|
||||
mAlert.SetMailAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetAlertTerminalAlerts()
|
||||
{
|
||||
return mAlert.GetTerminalAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetAlertTerminalAlerts(bool value)
|
||||
{
|
||||
mAlert.SetTerminalAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
// Alert Actions ...
|
||||
|
||||
//
|
||||
// Logging an Alert ...
|
||||
void LogAlert(string message)
|
||||
{
|
||||
mAlert.LogAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Terminal Alert ...
|
||||
void TerminalAlert(string message)
|
||||
{
|
||||
mAlert.TerminalAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Mail Alert ...
|
||||
void MailAlert(string message)
|
||||
{
|
||||
mAlert.MailAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Send Push Notification ...
|
||||
void PushAlert(string message)
|
||||
{
|
||||
mAlert.PushAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Send an Alert by Handling all Different Specified
|
||||
// type's of Alert's if they are Enabled ...
|
||||
void SendAlert(string message)
|
||||
{
|
||||
mAlert.SendAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Logs ...
|
||||
|
||||
//
|
||||
// Log a Message ...
|
||||
void Log(string message)
|
||||
{
|
||||
mAlert.Log(message);
|
||||
}
|
||||
void Log(string tag, string message)
|
||||
{
|
||||
mAlert.Log(tag, message);
|
||||
}
|
||||
void LogEmpty()
|
||||
{
|
||||
mAlert.LogEmpty();
|
||||
}
|
||||
|
||||
//
|
||||
// Log Specific Array ...
|
||||
template <typename T>
|
||||
void LogArray(
|
||||
T &array[], // Array to Log
|
||||
string label = NULL // Array Label
|
||||
)
|
||||
{
|
||||
mAlert.LogArray(array, label);
|
||||
}
|
||||
|
||||
//
|
||||
// Error ...
|
||||
|
||||
//
|
||||
// Log an Error ...
|
||||
void LogError(
|
||||
int error = -1 // Specific Error, if it's equal to -1, use Last Error ...
|
||||
)
|
||||
{
|
||||
mAlert.LogError(error);
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Specified Error Code Description ...
|
||||
string GetErrorDescription(int err_code)
|
||||
{
|
||||
return mAlert.GetErrorDescription(err_code);
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Specified Error Code Description ...
|
||||
string GetTradeServerReturnCodeDescription(int return_code)
|
||||
{
|
||||
return mAlert.GetTradeServerReturnCodeDescription(return_code);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Alert ...
|
||||
XCAlert *mAlert;
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,967 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XCBaseExpert
|
||||
// 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-alert.class.mq5"
|
||||
#include "../Classes/x-saherelm.x-trade.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
string XCBaseExpertToken = "XCBaseEA";
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
// Implementations ...
|
||||
class XCBaseExpert : public XCBaseAlert
|
||||
{
|
||||
//
|
||||
public:
|
||||
//
|
||||
|
||||
//
|
||||
XCTrade *mTrader; // Trader of Expert Adviser ...
|
||||
|
||||
//
|
||||
// Constructur(s) ...
|
||||
void XCBaseExpert()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XCBaseExpert()
|
||||
{
|
||||
//
|
||||
delete mTrader;
|
||||
|
||||
//
|
||||
ZeroMemory(mTrader);
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
//
|
||||
// Common ...
|
||||
|
||||
/**
|
||||
* Get Magic Number ...
|
||||
*
|
||||
* @return ( long )
|
||||
*/
|
||||
long MagicNumber()
|
||||
{
|
||||
return mMagicNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Magic Number ...
|
||||
*
|
||||
* @param value: Long ...
|
||||
*/
|
||||
void MagicNumber(long value)
|
||||
{
|
||||
//
|
||||
mMagicNumber = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Slippage ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int Slippage()
|
||||
{
|
||||
return mSlippage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Slippage ...
|
||||
*
|
||||
* @param value: Integer ...
|
||||
*/
|
||||
void Slippage(int value)
|
||||
{
|
||||
//
|
||||
mSlippage = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Tag Prefix ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string TagPrefix()
|
||||
{
|
||||
return mTagPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Tag Prefix ...
|
||||
*
|
||||
* @param value: String ...
|
||||
*/
|
||||
void TagPrefix(string value)
|
||||
{
|
||||
//
|
||||
mTagPrefix = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
//
|
||||
// Symbol ...
|
||||
|
||||
/**
|
||||
* Get Period ...
|
||||
*
|
||||
* @return ( ENUM_TIMEFRAMES )
|
||||
*/
|
||||
ENUM_TIMEFRAMES GetPeriod()
|
||||
{
|
||||
return mPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Period ...
|
||||
*
|
||||
* @param value: ENUM_TIMEFRAMES member ...
|
||||
*/
|
||||
void SetPeriod(ENUM_TIMEFRAMES value)
|
||||
{
|
||||
//
|
||||
mPeriod = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Symbol ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetSymbol()
|
||||
{
|
||||
return mSymbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Symbol ...
|
||||
*
|
||||
* @param value: String ...
|
||||
*/
|
||||
void SetSymbol(string value)
|
||||
{
|
||||
//
|
||||
mSymbol = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Multi Symbol is Enable or Not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool MultiSymbol()
|
||||
{
|
||||
return mMultiSymbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Multi Symbol is Enable or Not ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void MultiSymbol(bool value)
|
||||
{
|
||||
//
|
||||
mMultiSymbol = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Multi Provided Symbols ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string Symbols()
|
||||
{
|
||||
return mSymbols;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Multi Provided Symbols ...
|
||||
*
|
||||
* @param value: String ...
|
||||
*/
|
||||
void Symbols(string value)
|
||||
{
|
||||
//
|
||||
mSymbols = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
|
||||
/**
|
||||
* Get Force Disable Signalling ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Disabled()
|
||||
{
|
||||
return mDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Force Disable Signalling ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void Disabled(bool value)
|
||||
{
|
||||
//
|
||||
mDisabled = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Allow Long Signals ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool AllowLong()
|
||||
{
|
||||
return mAllowLong;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Allow Long Signals ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void AllowLong(bool value)
|
||||
{
|
||||
//
|
||||
mAllowLong = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Allow Short Signalling ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool AllowShort()
|
||||
{
|
||||
return mAllowShort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Allow Short Signalling ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void AllowShort(bool value)
|
||||
{
|
||||
//
|
||||
mAllowShort = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
//
|
||||
// Reports ...
|
||||
|
||||
/**
|
||||
* Get Report New Month State ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool ReportNewMonths()
|
||||
{
|
||||
return mReportNewMonths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Report New Month State ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void ReportNewMonths(bool value)
|
||||
{
|
||||
//
|
||||
mReportNewMonths = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Report New Weeks State ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool ReportNewWeeks()
|
||||
{
|
||||
return mReportNewWeeks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Report New Weeks State ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void ReportNewWeeks(bool value)
|
||||
{
|
||||
//
|
||||
mReportNewWeeks = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Report New Days State ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool ReportNewDays()
|
||||
{
|
||||
return mReportNewDays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Report New Days State ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void ReportNewDays(bool value)
|
||||
{
|
||||
//
|
||||
mReportNewDays = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Report New Hours State ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool ReportNewHours()
|
||||
{
|
||||
return mReportNewHours;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Report New Hours State ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void ReportNewHours(bool value)
|
||||
{
|
||||
//
|
||||
mReportNewHours = value;
|
||||
ReConfigure();
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Handle Expert OnInit Event ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HandleOnInit()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
string message = "";
|
||||
|
||||
//
|
||||
// Validate Input ...
|
||||
result = ValidateInputs();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
message = "Invalid Inputs ....";
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Initial All Requirements ...
|
||||
result = InitEA();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial All GUI Requirements ...
|
||||
result = InitGUI();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
message = "Initialized Successfully ...";
|
||||
SendAlert(message);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Expert OnDeInit Event ...
|
||||
*/
|
||||
void HandleOnDeInit()
|
||||
{
|
||||
//
|
||||
// Destroy all GUI Requirements ...
|
||||
DestroyGUI();
|
||||
|
||||
//
|
||||
// Alert De Initialization Succeeded ...
|
||||
string msg = "De Initialized Successfully ...";
|
||||
Alert(msg);
|
||||
|
||||
//
|
||||
// Destroy all EA Requirements ...
|
||||
DestroyEA();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Expert OnTick Event ...
|
||||
*/
|
||||
void HandleOnTick()
|
||||
{
|
||||
//
|
||||
UpdateGUI();
|
||||
HandleReportTime();
|
||||
HandleStrategiesOnTick();
|
||||
HandleStrategiesGuard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Expert OnTrade Event ...
|
||||
*/
|
||||
void HandleOnTrade()
|
||||
{
|
||||
mTrader.HandleOnTrade();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Expert OnTimer Event ...
|
||||
*/
|
||||
void HandleOnTimer()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Expert OnChart Event ...
|
||||
*/
|
||||
void HandleOnChartEvent(
|
||||
const int id,
|
||||
const long &lparam,
|
||||
const double &dparam,
|
||||
const string &sparam //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Virtual Actions ...
|
||||
|
||||
/**
|
||||
* Apply Default Configurations ...
|
||||
*/
|
||||
virtual void DefaultConfigure()
|
||||
{
|
||||
//
|
||||
// Commons ...
|
||||
Slippage(10);
|
||||
TagPrefix("");
|
||||
MagicNumber(1694056);
|
||||
|
||||
//
|
||||
// Symbol ...
|
||||
SetSymbol(_Symbol);
|
||||
SetPeriod(_Period);
|
||||
MultiSymbol(false);
|
||||
Symbols("EURUSDb,GBPUSDb,USDJPYb,USDCHFb,DowJones30,XAUUSDb");
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
Disabled(false);
|
||||
AllowLong(true);
|
||||
AllowShort(true);
|
||||
|
||||
//
|
||||
string tag = GetTag();
|
||||
|
||||
//
|
||||
// Alert ...
|
||||
SetAlertPrefix(tag);
|
||||
SetAlertLogAlerts(true);
|
||||
SetAlertPushAlerts(true);
|
||||
SetAlertMailAlerts(false);
|
||||
SetAlertEnableAlerts(true);
|
||||
SetAlertTerminalAlerts(false);
|
||||
|
||||
//
|
||||
// Reports ...
|
||||
ReportNewDays(true);
|
||||
ReportNewWeeks(false);
|
||||
ReportNewHours(false);
|
||||
ReportNewMonths(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vaslidate Inputs ...
|
||||
*
|
||||
* @return ( virtual bool )
|
||||
*/
|
||||
virtual bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
string errMessage = "";
|
||||
|
||||
//
|
||||
bool isCommonValid = (
|
||||
//
|
||||
mSlippage > 0 &&
|
||||
mMagicNumber > 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 ...
|
||||
errMessage = " Errors: \n" + errMessage;
|
||||
SendAlert(errMessage);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initializers and DeInitializers ...
|
||||
|
||||
/**
|
||||
* Initial EA Requirements ...
|
||||
*
|
||||
* @return ( virtual bool )
|
||||
*/
|
||||
virtual bool InitEA()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Initialize Indicator Helpers ...
|
||||
|
||||
//
|
||||
// Create Trader Instance and Configure it ...
|
||||
mTrader = new XCTrade(
|
||||
mSlippage,
|
||||
mMagicNumber //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Initialized Requirements ...
|
||||
*/
|
||||
virtual void DestroyEA()
|
||||
{
|
||||
//
|
||||
delete mTrader;
|
||||
|
||||
//
|
||||
ZeroMemory(mTrader);
|
||||
}
|
||||
|
||||
/**
|
||||
* GUI Initialize if required ...
|
||||
*
|
||||
* @return ( virtual bool )
|
||||
*/
|
||||
virtual bool InitGUI()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update All GUI Contents ...
|
||||
*/
|
||||
virtual void UpdateGUI()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy all Initialized GUi Elements ...
|
||||
*/
|
||||
virtual void DestroyGUI()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
/**
|
||||
* Calls When a Position's SL Triggered ...
|
||||
*
|
||||
* @param deal: XDeal instance ...
|
||||
*/
|
||||
virtual void HandleOnStopLossTriggered(const XDeal &deal)
|
||||
{
|
||||
HandleReportBalance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls When a Position's TP Triggered ...
|
||||
*
|
||||
* @param deal: XDeal instance ...
|
||||
*/
|
||||
virtual void HandleOnTakeProfitTriggered(const XDeal &deal)
|
||||
{
|
||||
HandleReportBalance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Force Close a Position ...
|
||||
*
|
||||
* @param ticket: Position Ticket ...
|
||||
* @param position: XPosition ...
|
||||
* @param comment: Closing Comment ...
|
||||
*/
|
||||
virtual void HandleOnPositionForceClosed(
|
||||
const ulong ticket,
|
||||
const XPosition &position,
|
||||
const string comment //
|
||||
)
|
||||
{
|
||||
HandleReportBalance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Position Modified ...
|
||||
*
|
||||
* @param ticket: ULONG ...
|
||||
* @param profit: Double ...
|
||||
* @param comment: String ...
|
||||
*/
|
||||
virtual void HandleOnPositionModified(
|
||||
const ulong ticket,
|
||||
const double profit,
|
||||
const string comment //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Position Partially Closed ...
|
||||
*
|
||||
* @param ticket: ULONG ...
|
||||
* @param profit: Double ...
|
||||
* @param comment: String ...
|
||||
*/
|
||||
virtual void HandleOnPositionPartialClosed(
|
||||
const ulong ticket,
|
||||
const double profit,
|
||||
const string comment //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Deals Changed ...
|
||||
*
|
||||
* @param count: Integer, Number of Changes ...
|
||||
*/
|
||||
virtual void HandleOnDealsChanged(int count)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Orders Changed ...
|
||||
*
|
||||
* @param count: Integer, Number of Changes ...
|
||||
*/
|
||||
virtual void HandleOnOrdersChanged(int count)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Positions Changed ...
|
||||
*
|
||||
* @param count: Integer, Number of Changes ...
|
||||
*/
|
||||
virtual void HandleOnPositionsChanged(int count)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Do All Signalling Processing Here ...
|
||||
*/
|
||||
virtual void HandleStrategiesOnTick()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Strategies for Guards and then Apply Them ...
|
||||
*/
|
||||
virtual void HandleStrategiesGuard()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Time Handlers ...
|
||||
|
||||
virtual void HandleOnNewMonth()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void HandleOnNewWeek()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void HandleOnNewDay()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void HandleOnNewHour()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void ReConfigure()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Identifier Tag ...
|
||||
*
|
||||
* @return ( virtual string )
|
||||
*/
|
||||
virtual string GetTag()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
string tagPrefix = TagPrefix();
|
||||
if (IsValid(tagPrefix))
|
||||
{
|
||||
result = tagPrefix;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "";
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
XCBaseExpertToken + result;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
XTimeTracker mTimeTracker; // Time Tracker for Providing Reports ...
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Report Account Balance ...
|
||||
*/
|
||||
void HandleReportBalance()
|
||||
{
|
||||
//
|
||||
if (!IsRunningOnTestMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
string msg = "Balance: " + ToString(mTrader.mAccount.GetBalance());
|
||||
Log(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Reporting based on Inputs ...
|
||||
*/
|
||||
void HandleReportTime()
|
||||
{
|
||||
//
|
||||
// Monthly Report ....
|
||||
if (mTimeTracker.IsNewMonth())
|
||||
{
|
||||
//
|
||||
HandleOnNewMonth();
|
||||
|
||||
//
|
||||
if (mReportNewMonths)
|
||||
{
|
||||
//
|
||||
string msg = "New Month ...";
|
||||
|
||||
//
|
||||
SendAlert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Weekly Report ....
|
||||
if (mTimeTracker.IsNewWeek())
|
||||
{
|
||||
//
|
||||
HandleOnNewWeek();
|
||||
|
||||
//
|
||||
if (mReportNewWeeks)
|
||||
{
|
||||
//
|
||||
string msg = "New Week ...";
|
||||
|
||||
//
|
||||
SendAlert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Daily Report ....
|
||||
if (mTimeTracker.IsNewDay())
|
||||
{
|
||||
//
|
||||
HandleOnNewDay();
|
||||
|
||||
//
|
||||
if (mReportNewDays)
|
||||
{
|
||||
//
|
||||
string msg = "New Day ...";
|
||||
|
||||
//
|
||||
SendAlert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Hourly Report ....
|
||||
if (mTimeTracker.IsNewHour())
|
||||
{
|
||||
//
|
||||
HandleOnNewHour();
|
||||
|
||||
//
|
||||
if (mReportNewHours)
|
||||
{
|
||||
//
|
||||
string msg = "New Hour ...";
|
||||
|
||||
//
|
||||
SendAlert(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Common ...
|
||||
long mMagicNumber; // Magic Number ...
|
||||
int mSlippage; // Slippage ...
|
||||
string mTagPrefix; // Tag Prefix ...
|
||||
|
||||
//
|
||||
// Symbol ...
|
||||
ENUM_TIMEFRAMES mPeriod; // Period ...
|
||||
string mSymbol; // Symbol ...
|
||||
bool mMultiSymbol; // Multi Symbol is Enable or Not ...
|
||||
string mSymbols; // Multi Provided Symbols ...
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
bool mDisabled; // Force Disable Signalling ...
|
||||
bool mAllowLong; // Allow Long Signals ...
|
||||
bool mAllowShort; // Allow Short Signals ...
|
||||
|
||||
//
|
||||
// Reports ...
|
||||
bool mReportNewMonths; // Report New Month ...
|
||||
bool mReportNewWeeks; // Report New Weeks ...
|
||||
bool mReportNewDays; // Report New Days ...
|
||||
bool mReportNewHours; // Report New Hours ...
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,209 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Indicator
|
||||
// -------------------------------------------------
|
||||
// Name: XCXCATBEADataCollector ...
|
||||
// Description: Class for XCATBEA Data Collector ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm Class for XCATBEA Data Collector"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../../Classes/x-saherelm.base.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Implementation ...
|
||||
class XCXCATBEADataCollector : public XCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructors ...
|
||||
XCXCATBEADataCollector()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XCXCATBEADataCollector()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Properties ...
|
||||
|
||||
//
|
||||
string Path()
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
//
|
||||
void Path(string value)
|
||||
{
|
||||
//
|
||||
// Normalizing Collector Path ...
|
||||
if (IsValid(value))
|
||||
{
|
||||
mPath = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPath = "XCXCATBEADataCollector";
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
string GetFilePath(string fileName)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
mPath + "\\" + fileName + ".x121.log"
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int GetFileHandlerForWrite(string filePath)
|
||||
{
|
||||
//
|
||||
int result = INVALID_HANDLE;
|
||||
|
||||
//
|
||||
if (!IsValid(filePath))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = FileOpen(
|
||||
filePath,
|
||||
FILE_READ | FILE_WRITE | FILE_TXT //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Specified Content into Specified File Name ...
|
||||
*
|
||||
* @param fileName: string, file name ...
|
||||
* @param content: string, content ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Save(
|
||||
string fileName,
|
||||
string content //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid(content);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
int mHandler = GetFileHandlerForWrite(fileName);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
FileWrite(mHandler, content);
|
||||
FileFlush(mHandler);
|
||||
FileClose(mHandler);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append Specified Content into Specified File Name ...
|
||||
*
|
||||
* @param fileName: string, file name ...
|
||||
* @param content: string, content ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Append(
|
||||
string fileName,
|
||||
string content //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid(content);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
int mHandler = GetFileHandlerForWrite(fileName);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
FileSeek(mHandler, 0, SEEK_END);
|
||||
FileWrite(mHandler, content);
|
||||
FileFlush(mHandler);
|
||||
FileClose(mHandler);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mPath; // Base Collector Path ...
|
||||
};
|
||||
Binary file not shown.
Reference in New Issue
Block a user