282 lines
6.2 KiB
Plaintext
282 lines
6.2 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class
|
|
// -------------------------------------------------
|
|
// Name: XCXOM1EAExpret ...
|
|
// Description: XCXOM1EA Expert Class ...
|
|
//
|
|
//
|
|
// 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 XCXOM1EA Expert Class"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
#include "../../Classes/x-saherelm.base.class.mq5"
|
|
#include "../../Classes/x-saherelm.x-alert.class.mq5"
|
|
#include "../../Classes/x-saherelm.x-volume.class.mq5"
|
|
#include "../Classes/xom1ea.signaller.class.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// Implementation ...
|
|
class XCXOM1EAExpert : public XCBase
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Common ...
|
|
long eaMagicNumber; // Magic Number
|
|
int eaSlippage; // Slippgae
|
|
string eaLogSuffix; // Log Suffix
|
|
|
|
//
|
|
// Volume ...
|
|
ENUM_X_VOLUME_SELECT_TYPE eaVolumeSelect; // Volume Applying Type
|
|
double eaStaticVoluem; // Static Volume
|
|
double eaDynamicVolumeStepBalance; // Step of Balance for Increase Volume
|
|
double eaDynamicVolumeStepVolume; // Step of Volume Increasing
|
|
double eaConstantRiskBalance; // Constant Risk Balance per Trade
|
|
double eaConstantPercent; // Constant Percent of Balance Per Trade
|
|
double eaConstantBalance; // Constant Balance for Calculations
|
|
|
|
//
|
|
// Alert ...
|
|
bool eaEnableAlerts; // Enable Alerts
|
|
bool eaSaveAlerts; // Save Alerts
|
|
bool eaLogAlerts; // Log Alerts
|
|
bool eaMailAlerts; // Mail Alerts
|
|
bool eaPushAlerts; // Push Alerts
|
|
bool eaTerminalAlerts; // Terminal Alerts
|
|
|
|
//
|
|
// Requirements ...
|
|
|
|
//
|
|
XCAlert *eaAlert; // EA Scope Alert Handler ...
|
|
XCVolume *eaVolume; // EA Scope Voluem Handler ...
|
|
|
|
//
|
|
// Validators ...
|
|
|
|
/**
|
|
* Validate Inputs ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool ValidateInputs()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// TODO: Handle this ...
|
|
result = true;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Expert Advisor Event Handlers ...
|
|
|
|
/**
|
|
* Handle Initialization of Expert ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool HandleOnInit()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Inputs ...
|
|
result = ValidateInputs();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Initialize Alert Handler ...
|
|
eaAlert = new XCAlert();
|
|
eaAlert.SetPrefix(eaLogSuffix);
|
|
eaAlert.SetLogAlerts(eaLogAlerts);
|
|
eaAlert.SetMailAlerts(eaMailAlerts);
|
|
eaAlert.SetPushAlerts(eaPushAlerts);
|
|
eaAlert.SetSaveAlerts(eaSaveAlerts);
|
|
eaAlert.SetEnableAlerts(eaEnableAlerts);
|
|
eaAlert.SetTerminalAlerts(eaTerminalAlerts);
|
|
|
|
//
|
|
// Initialize Volume Manager ...
|
|
// eaVolume = new XCVolume();
|
|
// result = eaVolume.Init(
|
|
// eaVolumeSelect,
|
|
// eaStaticVoluem,
|
|
// eaDynamicVolumeStepBalance,
|
|
// eaDynamicVolumeStepVolume,
|
|
// eaConstantRiskBalance,
|
|
// eaConstantPercent,
|
|
// eaConstantBalance //
|
|
// );
|
|
// if (!result)
|
|
// {
|
|
// return result;
|
|
// }
|
|
|
|
//
|
|
// Here we Apply Symbols,Periods and Configs ...
|
|
|
|
//
|
|
// Configure Indicator ...
|
|
XOM1Inputs iDZoneOMInputs;
|
|
iDZoneOMInputs.Default();
|
|
iDZoneOMInputs.showFiboZone = false;
|
|
|
|
//
|
|
iDZoneOMInputs.upperMode = MODE_OPEN
|
|
|
|
//
|
|
// Configure Signaller ...
|
|
XOM1SignallerConfig iDZoneSignallerConfig;
|
|
iDZoneSignallerConfig.processAllTicks = false;
|
|
|
|
//
|
|
// Make Instance Signaller Class ...
|
|
XCXOM1SignallerBase *iDZoneSignaller = NULL;
|
|
iDZoneSignaller = new XCXOM1SignallerBase(
|
|
"XDZN",
|
|
"EURUSDb",
|
|
PERIOD_M5,
|
|
iDZoneOMInputs,
|
|
iDZoneSignallerConfig);
|
|
if (iDZoneSignaller != NULL)
|
|
{
|
|
//
|
|
// Register Signaller ...
|
|
Add(
|
|
iDZoneSignaller,
|
|
signallers //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
iDZoneOMInputs.Clean();
|
|
iDZoneSignallerConfig.Clean();
|
|
ZeroMemory(iDZoneSignaller);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Handle De Initialization of Expert ...
|
|
*/
|
|
void HandleOnDeInit()
|
|
{
|
|
//
|
|
|
|
//
|
|
delete eaVolume;
|
|
ZeroMemory(eaVolume);
|
|
|
|
//
|
|
string message = "DeInitialized Successfully ...";
|
|
eaAlert.SendAlert(message);
|
|
|
|
//
|
|
delete eaAlert;
|
|
ZeroMemory(eaAlert);
|
|
}
|
|
|
|
/**
|
|
* Handle Tick ...
|
|
*/
|
|
void HandleOnTick()
|
|
{
|
|
//
|
|
int count = ArraySize(signallers);
|
|
bool has = IsValidSize(count);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Loop through Signallers ...
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
// Calling Process Ticks on Signaller ...
|
|
signallers[i].ProcessTick(0);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handle Trade ...
|
|
*/
|
|
void HandleOnTrade()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Handle Timer ...
|
|
*/
|
|
void HandleOnTimer()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Handle Chart Event ...
|
|
*
|
|
* @param id: int, Event id ...
|
|
* @param lparam: long, Event Long Parameter ...
|
|
* @param dparam: double, Event Double Parameter ...
|
|
* @param sparam: string, Event String Parameter ...
|
|
*/
|
|
void HandleOnChartEvent(
|
|
const int id,
|
|
const long &lparam,
|
|
const double &dparam,
|
|
const string &sparam //
|
|
)
|
|
{
|
|
}
|
|
|
|
//
|
|
// Trade Event Handlers ...
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
XCXOM1SignallerBase *signallers[]; // All Registered Signallers ...
|
|
};
|
|
|
|
//
|