prepare EU5 Workspace ...

This commit is contained in:
2024-01-31 09:40:40 -08:00
parent 7a61225897
commit eabb5d6827
18 changed files with 36528 additions and 17746 deletions
+9 -9
View File
@@ -254,14 +254,14 @@ struct XMarketConditions
// //
// //
class XCPriver : public XCBase class XCProvider : public XCBase
{ {
// //
// Public ... // Public ...
public: public:
// //
// Constructor ... // Constructor ...
XCPriver( XCProvider(
// //
// Common Requirements ... // Common Requirements ...
string xSymbol, // Which Symbol is Used string xSymbol, // Which Symbol is Used
@@ -285,9 +285,9 @@ public:
bool xSIAllowShortSignals, // Allow Short Signals bool xSIAllowShortSignals, // Allow Short Signals
// //
// XTSFI ... // XTSFI ...
bool XTSFIEnableSignaller, // Enable Signaller bool xTSFIEnableSignaller, // Enable Signaller
bool XTSFIAllowLongSignals, // Allow Long Signals bool xTSFIAllowLongSignals, // Allow Long Signals
bool XTSFIAllowShortSignals, // Allow Short Signals bool xTSFIAllowShortSignals, // Allow Short Signals
// //
// XOBDLH ... // XOBDLH ...
bool xOBDLHEnableSignaller, // Enable Signaller bool xOBDLHEnableSignaller, // Enable Signaller
@@ -331,9 +331,9 @@ public:
// //
// XTSFI ... // XTSFI ...
mXTSFIEnableSignaller = XTSFIEnableSignaller; mXTSFIEnableSignaller = xTSFIEnableSignaller;
mXTSFIAllowLongSignals = XTSFIAllowLongSignals; mXTSFIAllowLongSignals = xTSFIAllowLongSignals;
mXTSFIAllowShortSignals = XTSFIAllowShortSignals; mXTSFIAllowShortSignals = xTSFIAllowShortSignals;
// //
// XOBDLH ... // XOBDLH ...
@@ -362,7 +362,7 @@ public:
// //
// Deconstructor ... // Deconstructor ...
~XCPriver() {} ~XCProvider() {}
// //
// START Common Functions ... // START Common Functions ...
@@ -17,7 +17,7 @@
#property copyright "Copyright 2023, SaherElm IT Center" #property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir" #property link "https://saherelm.ir"
#property version "1.00" #property version "1.00"
#property description "SaherElm XAU5 EA" #property description "SaherElm XEU5 EA"
#property strict #property strict
// //
@@ -51,8 +51,8 @@ input group "Commons";
#include "../Libraries/x-saherelm.draw.lib.mq5" #include "../Libraries/x-saherelm.draw.lib.mq5"
// //
// XAU5 Signal Provider ... // XEU5 Signal Provider ...
#include "../Providers/x-saherelm.xau5.provider.lib.mq5" #include "../Providers/x-saherelm.xeu5.provider.lib.mq5"
// //
// END Including Providers ... // END Including Providers ...
@@ -61,10 +61,10 @@ input group "Commons";
// //
// START Global Definitions: Variables, Properties and etc ... // START Global Definitions: Variables, Properties and etc ...
// //
bool isXAU5NewHour; bool isXEU5NewHour;
bool isXAU5NewDay; bool isXEU5NewDay;
bool isXAU5NewWeek; bool isXEU5NewWeek;
bool isXAU5NewMonth; bool isXEU5NewMonth;
// //
// END Global Definitions: Variables, Properties and etc ... // END Global Definitions: Variables, Properties and etc ...
// //
@@ -78,7 +78,7 @@ bool isXAU5NewMonth;
int OnInit() int OnInit()
{ {
// //
logTag = "XAU5EA"; logTag = "XEU5EA";
drawPrefix = logTag; drawPrefix = logTag;
alertPrefix = logTag; alertPrefix = logTag;
@@ -98,8 +98,8 @@ int OnInit()
} }
// //
// Initialize XAU5 Provider ... // Initialize XEU5 Provider ...
if (!XAU5InitSignalProviderLibrary()) if (!XEU5InitSignalProviderLibrary())
{ {
return INIT_PARAMETERS_INCORRECT; return INIT_PARAMETERS_INCORRECT;
} }
@@ -129,8 +129,8 @@ void OnDeinit(const int reason)
// Here we can handle De Initialization Reasons ... // Here we can handle De Initialization Reasons ...
// //
// De Initialize XAU5 Provider ... // De Initialize XEU5 Provider ...
XAU5DeinitSignalProviderLibrary(reason); XEU5DeinitSignalProviderLibrary(reason);
// //
// De Init XDraw Library ... // De Init XDraw Library ...
@@ -144,15 +144,15 @@ void OnTick()
// //
// Handle Monthly Alert ... // Handle Monthly Alert ...
bool isFirstMonth = xMonth == -1; bool isFirstMonth = xMonth == -1;
isXAU5NewMonth = IsNewMonth(); isXEU5NewMonth = IsNewMonth();
bool canMonthlyAlert = bool canMonthlyAlert =
isXAU5NewMonth && isXEU5NewMonth &&
xAU5EnableAlerts && xEU5EnableAlerts &&
xAU5EnableMonthlyAlerts; xEU5EnableMonthlyAlerts;
bool canMonthlyReport = bool canMonthlyReport =
!isFirstMonth && !isFirstMonth &&
canMonthlyAlert && canMonthlyAlert &&
xAU5EnableMonthlyReports; xEU5EnableMonthlyReports;
if (canMonthlyAlert) if (canMonthlyAlert)
{ {
// //
@@ -163,7 +163,7 @@ void OnTick()
if (canMonthlyReport) if (canMonthlyReport)
{ {
// //
string report = xAU5Reporter.GenerateReportString(XREPORT_MONTHLY); string report = xEU5Reporter.GenerateReportString(XREPORT_MONTHLY);
// //
message = "Last Month Report:\n" + report; message = "Last Month Report:\n" + report;
@@ -171,7 +171,7 @@ void OnTick()
// //
// Reset Report ... // Reset Report ...
xAU5Reporter.Reset(XREPORT_MONTHLY); xEU5Reporter.Reset(XREPORT_MONTHLY);
// //
SendAlert(message); SendAlert(message);
@@ -180,15 +180,15 @@ void OnTick()
// //
// Handle Weekly Alert ... // Handle Weekly Alert ...
bool isFirstWeek = xDayOfWeek == -1; bool isFirstWeek = xDayOfWeek == -1;
isXAU5NewWeek = IsNewWeek(); isXEU5NewWeek = IsNewWeek();
bool canWeeklyAlert = bool canWeeklyAlert =
isXAU5NewWeek && isXEU5NewWeek &&
xAU5EnableAlerts && xEU5EnableAlerts &&
xAU5EnableWeeklyAlerts; xEU5EnableWeeklyAlerts;
bool canWeeklyReport = bool canWeeklyReport =
!isFirstWeek && !isFirstWeek &&
canWeeklyAlert && canWeeklyAlert &&
xAU5EnableWeeklyReports; xEU5EnableWeeklyReports;
if (canWeeklyAlert) if (canWeeklyAlert)
{ {
// //
@@ -199,7 +199,7 @@ void OnTick()
if (canWeeklyReport) if (canWeeklyReport)
{ {
// //
string report = xAU5Reporter.GenerateReportString(XREPORT_WEEKLY); string report = xEU5Reporter.GenerateReportString(XREPORT_WEEKLY);
// //
message = "Last Week Report:\n" + report; message = "Last Week Report:\n" + report;
@@ -207,7 +207,7 @@ void OnTick()
// //
// Reset Report ... // Reset Report ...
xAU5Reporter.Reset(XREPORT_WEEKLY); xEU5Reporter.Reset(XREPORT_WEEKLY);
// //
SendAlert(message); SendAlert(message);
@@ -216,15 +216,15 @@ void OnTick()
// //
// Handle Daily Alert ... // Handle Daily Alert ...
bool isFirstDay = xDay == -1; bool isFirstDay = xDay == -1;
isXAU5NewDay = IsNewDay(); isXEU5NewDay = IsNewDay();
bool canDailyAlert = bool canDailyAlert =
isXAU5NewDay && isXEU5NewDay &&
xAU5EnableAlerts && xEU5EnableAlerts &&
xAU5EnableDailyAlerts; xEU5EnableDailyAlerts;
bool canDailyReport = bool canDailyReport =
!isFirstDay && !isFirstDay &&
canDailyAlert && canDailyAlert &&
xAU5EnableDailyReports; xEU5EnableDailyReports;
if (canDailyAlert) if (canDailyAlert)
{ {
// //
@@ -235,7 +235,7 @@ void OnTick()
if (canDailyReport) if (canDailyReport)
{ {
// //
string report = xAU5Reporter.GenerateReportString(XREPORT_DAILY); string report = xEU5Reporter.GenerateReportString(XREPORT_DAILY);
// //
message = "Last Week Report:\n" + report; message = "Last Week Report:\n" + report;
@@ -243,7 +243,7 @@ void OnTick()
// //
// Reset Report ... // Reset Report ...
xAU5Reporter.Reset(XREPORT_DAILY); xEU5Reporter.Reset(XREPORT_DAILY);
// //
SendAlert(message); SendAlert(message);
@@ -252,11 +252,11 @@ void OnTick()
// //
// Handle Hourly Alert ... // Handle Hourly Alert ...
bool isFirstHour = xHour == -1; bool isFirstHour = xHour == -1;
isXAU5NewHour = IsNewHour(); isXEU5NewHour = IsNewHour();
bool canHourlyAlert = bool canHourlyAlert =
isXAU5NewHour && isXEU5NewHour &&
xAU5EnableAlerts && xEU5EnableAlerts &&
xAU5EnableHourlyAlerts; xEU5EnableHourlyAlerts;
if (canHourlyAlert) if (canHourlyAlert)
{ {
// //
@@ -269,11 +269,11 @@ void OnTick()
// //
// Prevent Going Forward if user Disable it ... // Prevent Going Forward if user Disable it ...
if (xAU5EnableProvider) if (xEU5EnableProvider)
{ {
// //
// Handle Processing on XAU5 Signal Provider ... // Handle Processing on XEU5 Signal Provider ...
XAU5SignalProviderDoControlState(); XEU5SignalProviderDoControlState();
} }
// //
@@ -284,11 +284,11 @@ void OnTick()
// //
// Prevent Going Forward if user Disable it ... // Prevent Going Forward if user Disable it ...
if (xAU5EnableProvider) if (xEU5EnableProvider)
{ {
// //
// Handle Processing on XAU5 Signal Provider ... // Handle Processing on XEU5 Signal Provider ...
XAU5SignalProviderHandleTick(); XEU5SignalProviderHandleTick();
} }
} }
@@ -299,11 +299,11 @@ void OnTrade()
// //
// Prevent Going Forward if user Disable it ... // Prevent Going Forward if user Disable it ...
if (xAU5EnableProvider) if (xEU5EnableProvider)
{ {
// //
// Handle Processing Trades on XAU5 Signal Provider ... // Handle Processing Trades on XEU5 Signal Provider ...
XAU5SignalProviderHandleTrade(); XEU5SignalProviderHandleTrade();
} }
} }
@@ -326,8 +326,8 @@ bool ValidateInputs()
// Validate Args ... // Validate Args ...
// //
// Validate XAU5 Provider Inputs ... // Validate XEU5 Provider Inputs ...
result = XAU5ValidateInputs(); result = XEU5ValidateInputs();
if (!result) if (!result)
{ {
return false; return false;
@@ -1,62 +0,0 @@
//+------------------------------------------------------------------+
//| CandleTimeStationary|
//| |
//| |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property strict
//---- input parameters
input color Clock_Color = clrDimGray;
input ENUM_BASE_CORNER Corner = CORNER_RIGHT_UPPER;
string objname="Spread&Bar";
double s1[];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
ObjectCreate(0, objname, OBJ_LABEL,0, 0, 0);
ObjectSetInteger(0, objname, OBJPROP_CORNER, Corner);
ObjectSetInteger(0, objname, OBJPROP_XDISTANCE, 10);
ObjectSetInteger(0, objname, OBJPROP_YDISTANCE, 2);
ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER;
switch (Corner)
{
case CORNER_LEFT_UPPER: Anchor=ANCHOR_LEFT_UPPER; break;
case CORNER_RIGHT_UPPER: Anchor=ANCHOR_RIGHT_UPPER; break;
case CORNER_LEFT_LOWER: Anchor=ANCHOR_LEFT_LOWER; break;
case CORNER_RIGHT_LOWER: Anchor=ANCHOR_RIGHT_LOWER; break;
}
ObjectSetInteger(0, objname, OBJPROP_ANCHOR, Anchor);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason) { ObjectDelete(0, objname); }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spreads[])
{
ArraySetAsSeries(time, true);
int m=int(time[0]+PeriodSeconds()-TimeCurrent());
int s=m%60;
m=(m-s)/60;
long spread=SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
string _sp="",_m="",_s="";
if (spread<10) _sp="..";
else if (spread<100) _sp=".";
if (m<10) _m="0";
if (s<10) _s="0";
ObjectSetString(0, objname, OBJPROP_TEXT, "Spread: " +IntegerToString(spread)+_sp+" Next Bar in "+_m+IntegerToString(m)+":"+_s+IntegerToString(s));
ObjectSetInteger(0, objname, OBJPROP_FONTSIZE, 10);
ObjectSetInteger(0, objname, OBJPROP_COLOR, Clock_Color);
ObjectSetString(0, objname, OBJPROP_FONT, "Courier");
return(rates_total);
}
File diff suppressed because it is too large Load Diff
@@ -1,280 +0,0 @@
///////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XAU5 Signal Provider Library Inputs
// -----------------------------------------------------------
//
// 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
//
// Include Logger ...
#include "../Libraries/x-saherelm.log.lib.mq5"
//
// Include Classes ...
#include "../Classes/x-saherelm.class.lib.mq5"
//
input group "XAU5 Provider";
//
// Commonly Used Configurations ...
input group "XAU5 Common";
//
// Provider ...
input bool xAU5EnableProvider = true; // Enable Provider
input int xAU5NumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
//
// Alerts ...
input bool xAU5EnableAlerts = true; // Enable Events Alert
input bool xAU5EnableHourlyAlerts = false; // Send Alert on each new Hour
input bool xAU5EnableDailyAlerts = false; // Send Alert on each new Day
input bool xAU5EnableWeeklyAlerts = false; // Send Alert on each new Week
input bool xAU5EnableMonthlyAlerts = true; // Send Alert on each new Month
//
// Reports ...
input bool xAU5EnableDailyReports = false; // Send Report on each new Day
input bool xAU5EnableWeeklyReports = false; // Send Report on each new Week
input bool xAU5EnableMonthlyReports = true; // Send Report on each new Month
//
// Trader and Expert Specific Configurations ...
input group "XAU5 Trader";
input int xAU5MagicNumber = 16940561; // Trader MagicNumber
input int xAU5Slippage = 10; // Trader Slippage
//
// Trades Management Configurations ...
input group "XAU5 Trade Management";
input bool xAU5AllowLongTrades = true; // Allow Long Trades
input bool xAU5AllowShortTrades = true; // Allow Short Trades
//
// Risk Management Configurations ...
input group "XAU5 Risk Management";
//
input bool xAU5UseVirtualTPSl = false; // Use Virtual TP SL
//
// Trade Count ...
input int xAU5MaxAllowedTrades = 10; // Max Allowed Trades at Same Time
input ENUM_X_CROSS_SIGNAL_METHOD xAU5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
//
// Max Allowed Trade Age ...
input int xAU5MaxAllowedTradeAge = 2000; // Detect Long Time Trades
input ENUM_X_GUARD_ACTIONS xAU5OldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
//
// Trade Volume Specific Configurations ...
input double xAU5StaticVolumeFactor = 0.0002; // Static Volume baesd on Balance
input ENUM_STATIC_VOLUME_METHODS xAU5StaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
input double xAU5VolumeMultiplier = 0; // Volume Increase Multiplier
input double xAU5ApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
input double xAU5MaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance
input double xAU5IncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
//
// Trade Profits ...
input double xAU5MinRewardInPips = 150; // Minimum Reward Per Trade in Pips
input double xAU5RiskFreeStepInPips = 60; // Make Trades Risk Free Steps in Pips
input double xAU5RiskFreeRate = 0.6; // Volume Multiplier for Risk Free Trades
//
// Guard Riskable Money and Profits ...
input double xAU5CriticalDrawDownFactor = 0.43; // Critical Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xAU5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Critical Drawdown
input double xAU5MaxAllowedDrawDownFactor = 0.45; // Max Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xAU5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_10; // Specify Guard Action on Max Allowed Drawdown
input int xAU5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
//
// Account Conditions for Trading ...
input double xAU5BalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
input double xAU5FreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
//
// Validate Inputs before Initialization ...
bool XAU5ValidateInputs()
{
//
bool result = false;
//
// Implement Other Verifications ...
//
// Check Trading Availability ...
bool isTradeAvailable = xAU5AllowLongTrades || xAU5AllowShortTrades;
if (!isTradeAvailable)
{
LogMessage("XAU5 => Warning: Trading disabled ...");
}
//
// Chekc Number of reading items per tick ...
result = xAU5NumberOfItemsPerTick >= 5;
if (!result)
{
//
LogMessage("XAU5 invalid Number of items Reading Per Tick ...");
//
return result;
}
//
// Check Max Allowed Trades Count ...
result = isTradeAvailable && xAU5MaxAllowedTrades >= 1;
if (!result)
{
//
LogMessage("XAU5 Number of Trades not valid ...");
//
return result;
}
//
// Check Free Margin ...
result =
isTradeAvailable &&
xAU5FreeMarginFactorForOpenTrades > 0 &&
xAU5FreeMarginFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XAU5 Invalid Free Margin ...");
//
return result;
}
//
// Check min Balance for Open Trades ...
result =
isTradeAvailable &&
xAU5BalanceFactorForOpenTrades > 0 &&
xAU5BalanceFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XAU5 Invalid Min Balance for Open Trades ...");
//
return result;
}
//
// Check Min Reward Per Trade ...
result = xAU5MinRewardInPips > 0;
if (!result)
{
//
LogMessage("XAU5 Invalid Min Reward Per Trade ...");
//
return result;
}
//
// Check Trades Volume ...
result = xAU5StaticVolumeFactor > 0;
if (!result)
{
//
LogMessage("XAU5 Invalid Static Volume ...");
//
return result;
}
//
// Check Volume Multiplier ...
result = xAU5VolumeMultiplier >= 0;
if (!result)
{
//
LogMessage("XAU5 Invalid Volume Multiplier ...");
//
return result;
}
//
result =
xAU5CriticalDrawDownFactor == 0 || (xAU5CriticalDrawDownFactor > 0 &&
xAU5CriticalDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XAU5 Invalid Critical DrawDown Factor ...");
//
return result;
}
//
result =
xAU5MaxAllowedDrawDownFactor == 0 || (xAU5MaxAllowedDrawDownFactor > 0 &&
xAU5MaxAllowedDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XAU5 Invalid Max Allowed DrawDown Factor ...");
//
return result;
}
//
// Check Guard Actions ...
//
result =
xAU5CriticalDrawDownFactor > 0 &&
xAU5CriticalDrawDownFactor < 1 &&
xAU5MaxAllowedDrawDownFactor > 0 &&
xAU5MaxAllowedDrawDownFactor < 1;
if (!result)
{
//
LogMessage("XAU5 For Critical Drawdown, you have to Specify Max Drawdown also ...");
//
return result;
}
//
result = xAU5CriticalDrawDownFactor > 0 && xAU5CriticalDrawDownFactor < xAU5MaxAllowedDrawDownFactor;
if (!result)
{
//
LogMessage("XAU5 Critical Drawdown must Smaller than Max Drawdown ...");
//
return result;
}
//
if (xAU5CriticalDrawDownFactor > 0 && xAU5CriticalGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XAU5 IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ...");
}
//
if (xAU5MaxAllowedDrawDownFactor > 0 && xAU5MaxAllowedGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XAU5 IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ...");
}
//
result = true;
//
return result;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,280 @@
///////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XEU5 Signal Provider Library Inputs
// -----------------------------------------------------------
//
// 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
//
// Include Logger ...
#include "../Libraries/x-saherelm.log.lib.mq5"
//
// Include Classes ...
#include "../Classes/x-saherelm.class.lib.mq5"
//
input group "XEU5 Provider";
//
// Commonly Used Configurations ...
input group "XEU5 Common";
//
// Provider ...
input bool xEU5EnableProvider = true; // Enable Provider
input int xEU5NumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
//
// Alerts ...
input bool xEU5EnableAlerts = true; // Enable Events Alert
input bool xEU5EnableHourlyAlerts = false; // Send Alert on each new Hour
input bool xEU5EnableDailyAlerts = false; // Send Alert on each new Day
input bool xEU5EnableWeeklyAlerts = false; // Send Alert on each new Week
input bool xEU5EnableMonthlyAlerts = true; // Send Alert on each new Month
//
// Reports ...
input bool xEU5EnableDailyReports = false; // Send Report on each new Day
input bool xEU5EnableWeeklyReports = false; // Send Report on each new Week
input bool xEU5EnableMonthlyReports = true; // Send Report on each new Month
//
// Trader and Expert Specific Configurations ...
input group "XEU5 Trader";
input int xEU5MagicNumber = 16940560; // Trader MagicNumber
input int xEU5Slippage = 10; // Trader Slippage
//
// Trades Management Configurations ...
input group "XEU5 Trade Management";
input bool xEU5AllowLongTrades = true; // Allow Long Trades
input bool xEU5AllowShortTrades = true; // Allow Short Trades
//
// Risk Management Configurations ...
input group "XEU5 Risk Management";
//
input bool xEU5UseVirtualTPSl = false; // Use Virtual TP SL
//
// Trade Count ...
input int xEU5MaxAllowedTrades = 10; // Max Allowed Trades at Same Time
input ENUM_X_CROSS_SIGNAL_METHOD xEU5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
//
// Max Allowed Trade Age ...
input int xEU5MaxAllowedTradeAge = 1500; // Detect Long Time Trades
input ENUM_X_GUARD_ACTIONS xEU5OldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
//
// Trade Volume Specific Configurations ...
input double xEU5StaticVolumeFactor = 0.0002; // Static Volume baesd on Balance
input ENUM_STATIC_VOLUME_METHODS xEU5StaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
input double xEU5VolumeMultiplier = 0; // Volume Increase Multiplier
input double xEU5ApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
input double xEU5MaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance
input double xEU5IncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
//
// Trade Profits ...
input double xEU5MinRewardInPips = 15; // Minimum Reward Per Trade in Pips
input double xEU5RiskFreeStepInPips = 6; // Make Trades Risk Free Steps in Pips
input double xEU5RiskFreeRate = 0.6; // Volume Multiplier for Risk Free Trades
//
// Guard Riskable Money and Profits ...
input double xEU5CriticalDrawDownFactor = 0.40; // Critical Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xEU5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Critical Drawdown
input double xEU5MaxAllowedDrawDownFactor = 0.45; // Max Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xEU5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_10; // Specify Guard Action on Max Allowed Drawdown
input int xEU5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
//
// Account Conditions for Trading ...
input double xEU5BalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
input double xEU5FreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
//
// Validate Inputs before Initialization ...
bool XEU5ValidateInputs()
{
//
bool result = false;
//
// Implement Other Verifications ...
//
// Check Trading Availability ...
bool isTradeAvailable = xEU5AllowLongTrades || xEU5AllowShortTrades;
if (!isTradeAvailable)
{
LogMessage("XEU5 => Warning: Trading disabled ...");
}
//
// Chekc Number of reading items per tick ...
result = xEU5NumberOfItemsPerTick >= 5;
if (!result)
{
//
LogMessage("XEU5 invalid Number of items Reading Per Tick ...");
//
return result;
}
//
// Check Max Allowed Trades Count ...
result = isTradeAvailable && xEU5MaxAllowedTrades >= 1;
if (!result)
{
//
LogMessage("XEU5 Number of Trades not valid ...");
//
return result;
}
//
// Check Free Margin ...
result =
isTradeAvailable &&
xEU5FreeMarginFactorForOpenTrades > 0 &&
xEU5FreeMarginFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XEU5 Invalid Free Margin ...");
//
return result;
}
//
// Check min Balance for Open Trades ...
result =
isTradeAvailable &&
xEU5BalanceFactorForOpenTrades > 0 &&
xEU5BalanceFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XEU5 Invalid Min Balance for Open Trades ...");
//
return result;
}
//
// Check Min Reward Per Trade ...
result = xEU5MinRewardInPips > 0;
if (!result)
{
//
LogMessage("XEU5 Invalid Min Reward Per Trade ...");
//
return result;
}
//
// Check Trades Volume ...
result = xEU5StaticVolumeFactor > 0;
if (!result)
{
//
LogMessage("XEU5 Invalid Static Volume ...");
//
return result;
}
//
// Check Volume Multiplier ...
result = xEU5VolumeMultiplier >= 0;
if (!result)
{
//
LogMessage("XEU5 Invalid Volume Multiplier ...");
//
return result;
}
//
result =
xEU5CriticalDrawDownFactor == 0 || (xEU5CriticalDrawDownFactor > 0 &&
xEU5CriticalDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XEU5 Invalid Critical DrawDown Factor ...");
//
return result;
}
//
result =
xEU5MaxAllowedDrawDownFactor == 0 || (xEU5MaxAllowedDrawDownFactor > 0 &&
xEU5MaxAllowedDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XEU5 Invalid Max Allowed DrawDown Factor ...");
//
return result;
}
//
// Check Guard Actions ...
//
result =
xEU5CriticalDrawDownFactor > 0 &&
xEU5CriticalDrawDownFactor < 1 &&
xEU5MaxAllowedDrawDownFactor > 0 &&
xEU5MaxAllowedDrawDownFactor < 1;
if (!result)
{
//
LogMessage("XEU5 For Critical Drawdown, you have to Specify Max Drawdown also ...");
//
return result;
}
//
result = xEU5CriticalDrawDownFactor > 0 && xEU5CriticalDrawDownFactor < xEU5MaxAllowedDrawDownFactor;
if (!result)
{
//
LogMessage("XEU5 Critical Drawdown must Smaller than Max Drawdown ...");
//
return result;
}
//
if (xEU5CriticalDrawDownFactor > 0 && xEU5CriticalGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XEU5 IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ...");
}
//
if (xEU5MaxAllowedDrawDownFactor > 0 && xEU5MaxAllowedGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XEU5 IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ...");
}
//
result = true;
//
return result;
}
+9 -9
View File
@@ -254,14 +254,14 @@ struct XMarketConditions
// //
// //
class XCPriver : public XCBase class XCProvider : public XCBase
{ {
// //
// Public ... // Public ...
public: public:
// //
// Constructor ... // Constructor ...
XCPriver( XCProvider(
// //
// Common Requirements ... // Common Requirements ...
string xSymbol, // Which Symbol is Used string xSymbol, // Which Symbol is Used
@@ -285,9 +285,9 @@ public:
bool xSIAllowShortSignals, // Allow Short Signals bool xSIAllowShortSignals, // Allow Short Signals
// //
// XTSFI ... // XTSFI ...
bool XTSFIEnableSignaller, // Enable Signaller bool xTSFIEnableSignaller, // Enable Signaller
bool XTSFIAllowLongSignals, // Allow Long Signals bool xTSFIAllowLongSignals, // Allow Long Signals
bool XTSFIAllowShortSignals, // Allow Short Signals bool xTSFIAllowShortSignals, // Allow Short Signals
// //
// XOBDLH ... // XOBDLH ...
bool xOBDLHEnableSignaller, // Enable Signaller bool xOBDLHEnableSignaller, // Enable Signaller
@@ -331,9 +331,9 @@ public:
// //
// XTSFI ... // XTSFI ...
mXTSFIEnableSignaller = XTSFIEnableSignaller; mXTSFIEnableSignaller = xTSFIEnableSignaller;
mXTSFIAllowLongSignals = XTSFIAllowLongSignals; mXTSFIAllowLongSignals = xTSFIAllowLongSignals;
mXTSFIAllowShortSignals = XTSFIAllowShortSignals; mXTSFIAllowShortSignals = xTSFIAllowShortSignals;
// //
// XOBDLH ... // XOBDLH ...
@@ -362,7 +362,7 @@ public:
// //
// Deconstructor ... // Deconstructor ...
~XCPriver() {} ~XCProvider() {}
// //
// START Common Functions ... // START Common Functions ...
@@ -17,7 +17,7 @@
#property copyright "Copyright 2023, SaherElm IT Center" #property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir" #property link "https://saherelm.ir"
#property version "1.00" #property version "1.00"
#property description "SaherElm XAU5 EA" #property description "SaherElm XEU5 EA"
#property strict #property strict
// //
@@ -51,8 +51,8 @@ input group "Commons";
#include "../Libraries/x-saherelm.draw.lib.mq5" #include "../Libraries/x-saherelm.draw.lib.mq5"
// //
// XAU5 Signal Provider ... // XEU5 Signal Provider ...
#include "../Providers/x-saherelm.xau5.provider.lib.mq5" #include "../Providers/x-saherelm.xeu5.provider.lib.mq5"
// //
// END Including Providers ... // END Including Providers ...
@@ -61,10 +61,10 @@ input group "Commons";
// //
// START Global Definitions: Variables, Properties and etc ... // START Global Definitions: Variables, Properties and etc ...
// //
bool isXAU5NewHour; bool isXEU5NewHour;
bool isXAU5NewDay; bool isXEU5NewDay;
bool isXAU5NewWeek; bool isXEU5NewWeek;
bool isXAU5NewMonth; bool isXEU5NewMonth;
// //
// END Global Definitions: Variables, Properties and etc ... // END Global Definitions: Variables, Properties and etc ...
// //
@@ -78,7 +78,7 @@ bool isXAU5NewMonth;
int OnInit() int OnInit()
{ {
// //
logTag = "XAU5EA"; logTag = "XEU5EA";
drawPrefix = logTag; drawPrefix = logTag;
alertPrefix = logTag; alertPrefix = logTag;
@@ -98,8 +98,8 @@ int OnInit()
} }
// //
// Initialize XAU5 Provider ... // Initialize XEU5 Provider ...
if (!XAU5InitSignalProviderLibrary()) if (!XEU5InitSignalProviderLibrary())
{ {
return INIT_PARAMETERS_INCORRECT; return INIT_PARAMETERS_INCORRECT;
} }
@@ -129,8 +129,8 @@ void OnDeinit(const int reason)
// Here we can handle De Initialization Reasons ... // Here we can handle De Initialization Reasons ...
// //
// De Initialize XAU5 Provider ... // De Initialize XEU5 Provider ...
XAU5DeinitSignalProviderLibrary(reason); XEU5DeinitSignalProviderLibrary(reason);
// //
// De Init XDraw Library ... // De Init XDraw Library ...
@@ -144,15 +144,15 @@ void OnTick()
// //
// Handle Monthly Alert ... // Handle Monthly Alert ...
bool isFirstMonth = xMonth == -1; bool isFirstMonth = xMonth == -1;
isXAU5NewMonth = IsNewMonth(); isXEU5NewMonth = IsNewMonth();
bool canMonthlyAlert = bool canMonthlyAlert =
isXAU5NewMonth && isXEU5NewMonth &&
xAU5EnableAlerts && xEU5EnableAlerts &&
xAU5EnableMonthlyAlerts; xEU5EnableMonthlyAlerts;
bool canMonthlyReport = bool canMonthlyReport =
!isFirstMonth && !isFirstMonth &&
canMonthlyAlert && canMonthlyAlert &&
xAU5EnableMonthlyReports; xEU5EnableMonthlyReports;
if (canMonthlyAlert) if (canMonthlyAlert)
{ {
// //
@@ -163,7 +163,7 @@ void OnTick()
if (canMonthlyReport) if (canMonthlyReport)
{ {
// //
string report = xAU5Reporter.GenerateReportString(XREPORT_MONTHLY); string report = xEU5Reporter.GenerateReportString(XREPORT_MONTHLY);
// //
message = "Last Month Report:\n" + report; message = "Last Month Report:\n" + report;
@@ -171,7 +171,7 @@ void OnTick()
// //
// Reset Report ... // Reset Report ...
xAU5Reporter.Reset(XREPORT_MONTHLY); xEU5Reporter.Reset(XREPORT_MONTHLY);
// //
SendAlert(message); SendAlert(message);
@@ -180,15 +180,15 @@ void OnTick()
// //
// Handle Weekly Alert ... // Handle Weekly Alert ...
bool isFirstWeek = xDayOfWeek == -1; bool isFirstWeek = xDayOfWeek == -1;
isXAU5NewWeek = IsNewWeek(); isXEU5NewWeek = IsNewWeek();
bool canWeeklyAlert = bool canWeeklyAlert =
isXAU5NewWeek && isXEU5NewWeek &&
xAU5EnableAlerts && xEU5EnableAlerts &&
xAU5EnableWeeklyAlerts; xEU5EnableWeeklyAlerts;
bool canWeeklyReport = bool canWeeklyReport =
!isFirstWeek && !isFirstWeek &&
canWeeklyAlert && canWeeklyAlert &&
xAU5EnableWeeklyReports; xEU5EnableWeeklyReports;
if (canWeeklyAlert) if (canWeeklyAlert)
{ {
// //
@@ -199,7 +199,7 @@ void OnTick()
if (canWeeklyReport) if (canWeeklyReport)
{ {
// //
string report = xAU5Reporter.GenerateReportString(XREPORT_WEEKLY); string report = xEU5Reporter.GenerateReportString(XREPORT_WEEKLY);
// //
message = "Last Week Report:\n" + report; message = "Last Week Report:\n" + report;
@@ -207,7 +207,7 @@ void OnTick()
// //
// Reset Report ... // Reset Report ...
xAU5Reporter.Reset(XREPORT_WEEKLY); xEU5Reporter.Reset(XREPORT_WEEKLY);
// //
SendAlert(message); SendAlert(message);
@@ -216,15 +216,15 @@ void OnTick()
// //
// Handle Daily Alert ... // Handle Daily Alert ...
bool isFirstDay = xDay == -1; bool isFirstDay = xDay == -1;
isXAU5NewDay = IsNewDay(); isXEU5NewDay = IsNewDay();
bool canDailyAlert = bool canDailyAlert =
isXAU5NewDay && isXEU5NewDay &&
xAU5EnableAlerts && xEU5EnableAlerts &&
xAU5EnableDailyAlerts; xEU5EnableDailyAlerts;
bool canDailyReport = bool canDailyReport =
!isFirstDay && !isFirstDay &&
canDailyAlert && canDailyAlert &&
xAU5EnableDailyReports; xEU5EnableDailyReports;
if (canDailyAlert) if (canDailyAlert)
{ {
// //
@@ -235,7 +235,7 @@ void OnTick()
if (canDailyReport) if (canDailyReport)
{ {
// //
string report = xAU5Reporter.GenerateReportString(XREPORT_DAILY); string report = xEU5Reporter.GenerateReportString(XREPORT_DAILY);
// //
message = "Last Week Report:\n" + report; message = "Last Week Report:\n" + report;
@@ -243,7 +243,7 @@ void OnTick()
// //
// Reset Report ... // Reset Report ...
xAU5Reporter.Reset(XREPORT_DAILY); xEU5Reporter.Reset(XREPORT_DAILY);
// //
SendAlert(message); SendAlert(message);
@@ -252,11 +252,11 @@ void OnTick()
// //
// Handle Hourly Alert ... // Handle Hourly Alert ...
bool isFirstHour = xHour == -1; bool isFirstHour = xHour == -1;
isXAU5NewHour = IsNewHour(); isXEU5NewHour = IsNewHour();
bool canHourlyAlert = bool canHourlyAlert =
isXAU5NewHour && isXEU5NewHour &&
xAU5EnableAlerts && xEU5EnableAlerts &&
xAU5EnableHourlyAlerts; xEU5EnableHourlyAlerts;
if (canHourlyAlert) if (canHourlyAlert)
{ {
// //
@@ -269,11 +269,11 @@ void OnTick()
// //
// Prevent Going Forward if user Disable it ... // Prevent Going Forward if user Disable it ...
if (xAU5EnableProvider) if (xEU5EnableProvider)
{ {
// //
// Handle Processing on XAU5 Signal Provider ... // Handle Processing on XEU5 Signal Provider ...
XAU5SignalProviderDoControlState(); XEU5SignalProviderDoControlState();
} }
// //
@@ -284,11 +284,11 @@ void OnTick()
// //
// Prevent Going Forward if user Disable it ... // Prevent Going Forward if user Disable it ...
if (xAU5EnableProvider) if (xEU5EnableProvider)
{ {
// //
// Handle Processing on XAU5 Signal Provider ... // Handle Processing on XEU5 Signal Provider ...
XAU5SignalProviderHandleTick(); XEU5SignalProviderHandleTick();
} }
} }
@@ -299,11 +299,11 @@ void OnTrade()
// //
// Prevent Going Forward if user Disable it ... // Prevent Going Forward if user Disable it ...
if (xAU5EnableProvider) if (xEU5EnableProvider)
{ {
// //
// Handle Processing Trades on XAU5 Signal Provider ... // Handle Processing Trades on XEU5 Signal Provider ...
XAU5SignalProviderHandleTrade(); XEU5SignalProviderHandleTrade();
} }
} }
@@ -326,8 +326,8 @@ bool ValidateInputs()
// Validate Args ... // Validate Args ...
// //
// Validate XAU5 Provider Inputs ... // Validate XEU5 Provider Inputs ...
result = XAU5ValidateInputs(); result = XEU5ValidateInputs();
if (!result) if (!result)
{ {
return false; return false;
-62
View File
@@ -1,62 +0,0 @@
//+------------------------------------------------------------------+
//| CandleTimeStationary|
//| |
//| |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property strict
//---- input parameters
input color Clock_Color = clrDimGray;
input ENUM_BASE_CORNER Corner = CORNER_RIGHT_UPPER;
string objname="Spread&Bar";
double s1[];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
ObjectCreate(0, objname, OBJ_LABEL,0, 0, 0);
ObjectSetInteger(0, objname, OBJPROP_CORNER, Corner);
ObjectSetInteger(0, objname, OBJPROP_XDISTANCE, 10);
ObjectSetInteger(0, objname, OBJPROP_YDISTANCE, 2);
ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER;
switch (Corner)
{
case CORNER_LEFT_UPPER: Anchor=ANCHOR_LEFT_UPPER; break;
case CORNER_RIGHT_UPPER: Anchor=ANCHOR_RIGHT_UPPER; break;
case CORNER_LEFT_LOWER: Anchor=ANCHOR_LEFT_LOWER; break;
case CORNER_RIGHT_LOWER: Anchor=ANCHOR_RIGHT_LOWER; break;
}
ObjectSetInteger(0, objname, OBJPROP_ANCHOR, Anchor);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason) { ObjectDelete(0, objname); }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spreads[])
{
ArraySetAsSeries(time, true);
int m=int(time[0]+PeriodSeconds()-TimeCurrent());
int s=m%60;
m=(m-s)/60;
long spread=SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
string _sp="",_m="",_s="";
if (spread<10) _sp="..";
else if (spread<100) _sp=".";
if (m<10) _m="0";
if (s<10) _s="0";
ObjectSetString(0, objname, OBJPROP_TEXT, "Spread: " +IntegerToString(spread)+_sp+" Next Bar in "+_m+IntegerToString(m)+":"+_s+IntegerToString(s));
ObjectSetInteger(0, objname, OBJPROP_FONTSIZE, 10);
ObjectSetInteger(0, objname, OBJPROP_COLOR, Clock_Color);
ObjectSetString(0, objname, OBJPROP_FONT, "Courier");
return(rates_total);
}
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
@@ -1,280 +0,0 @@
///////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XAU5 Signal Provider Library Inputs
// -----------------------------------------------------------
//
// 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
//
// Include Logger ...
#include "../Libraries/x-saherelm.log.lib.mq5"
//
// Include Classes ...
#include "../Classes/x-saherelm.class.lib.mq5"
//
input group "XAU5 Provider";
//
// Commonly Used Configurations ...
input group "XAU5 Common";
//
// Provider ...
input bool xAU5EnableProvider = true; // Enable Provider
input int xAU5NumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
//
// Alerts ...
input bool xAU5EnableAlerts = true; // Enable Events Alert
input bool xAU5EnableHourlyAlerts = false; // Send Alert on each new Hour
input bool xAU5EnableDailyAlerts = false; // Send Alert on each new Day
input bool xAU5EnableWeeklyAlerts = false; // Send Alert on each new Week
input bool xAU5EnableMonthlyAlerts = true; // Send Alert on each new Month
//
// Reports ...
input bool xAU5EnableDailyReports = false; // Send Report on each new Day
input bool xAU5EnableWeeklyReports = false; // Send Report on each new Week
input bool xAU5EnableMonthlyReports = true; // Send Report on each new Month
//
// Trader and Expert Specific Configurations ...
input group "XAU5 Trader";
input int xAU5MagicNumber = 16940561; // Trader MagicNumber
input int xAU5Slippage = 10; // Trader Slippage
//
// Trades Management Configurations ...
input group "XAU5 Trade Management";
input bool xAU5AllowLongTrades = true; // Allow Long Trades
input bool xAU5AllowShortTrades = true; // Allow Short Trades
//
// Risk Management Configurations ...
input group "XAU5 Risk Management";
//
input bool xAU5UseVirtualTPSl = false; // Use Virtual TP SL
//
// Trade Count ...
input int xAU5MaxAllowedTrades = 10; // Max Allowed Trades at Same Time
input ENUM_X_CROSS_SIGNAL_METHOD xAU5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
//
// Max Allowed Trade Age ...
input int xAU5MaxAllowedTradeAge = 2000; // Detect Long Time Trades
input ENUM_X_GUARD_ACTIONS xAU5OldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
//
// Trade Volume Specific Configurations ...
input double xAU5StaticVolumeFactor = 0.0002; // Static Volume baesd on Balance
input ENUM_STATIC_VOLUME_METHODS xAU5StaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
input double xAU5VolumeMultiplier = 0; // Volume Increase Multiplier
input double xAU5ApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
input double xAU5MaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance
input double xAU5IncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
//
// Trade Profits ...
input double xAU5MinRewardInPips = 150; // Minimum Reward Per Trade in Pips
input double xAU5RiskFreeStepInPips = 60; // Make Trades Risk Free Steps in Pips
input double xAU5RiskFreeRate = 0.6; // Volume Multiplier for Risk Free Trades
//
// Guard Riskable Money and Profits ...
input double xAU5CriticalDrawDownFactor = 0.43; // Critical Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xAU5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Critical Drawdown
input double xAU5MaxAllowedDrawDownFactor = 0.45; // Max Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xAU5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_10; // Specify Guard Action on Max Allowed Drawdown
input int xAU5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
//
// Account Conditions for Trading ...
input double xAU5BalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
input double xAU5FreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
//
// Validate Inputs before Initialization ...
bool XAU5ValidateInputs()
{
//
bool result = false;
//
// Implement Other Verifications ...
//
// Check Trading Availability ...
bool isTradeAvailable = xAU5AllowLongTrades || xAU5AllowShortTrades;
if (!isTradeAvailable)
{
LogMessage("XAU5 => Warning: Trading disabled ...");
}
//
// Chekc Number of reading items per tick ...
result = xAU5NumberOfItemsPerTick >= 5;
if (!result)
{
//
LogMessage("XAU5 invalid Number of items Reading Per Tick ...");
//
return result;
}
//
// Check Max Allowed Trades Count ...
result = isTradeAvailable && xAU5MaxAllowedTrades >= 1;
if (!result)
{
//
LogMessage("XAU5 Number of Trades not valid ...");
//
return result;
}
//
// Check Free Margin ...
result =
isTradeAvailable &&
xAU5FreeMarginFactorForOpenTrades > 0 &&
xAU5FreeMarginFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XAU5 Invalid Free Margin ...");
//
return result;
}
//
// Check min Balance for Open Trades ...
result =
isTradeAvailable &&
xAU5BalanceFactorForOpenTrades > 0 &&
xAU5BalanceFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XAU5 Invalid Min Balance for Open Trades ...");
//
return result;
}
//
// Check Min Reward Per Trade ...
result = xAU5MinRewardInPips > 0;
if (!result)
{
//
LogMessage("XAU5 Invalid Min Reward Per Trade ...");
//
return result;
}
//
// Check Trades Volume ...
result = xAU5StaticVolumeFactor > 0;
if (!result)
{
//
LogMessage("XAU5 Invalid Static Volume ...");
//
return result;
}
//
// Check Volume Multiplier ...
result = xAU5VolumeMultiplier >= 0;
if (!result)
{
//
LogMessage("XAU5 Invalid Volume Multiplier ...");
//
return result;
}
//
result =
xAU5CriticalDrawDownFactor == 0 || (xAU5CriticalDrawDownFactor > 0 &&
xAU5CriticalDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XAU5 Invalid Critical DrawDown Factor ...");
//
return result;
}
//
result =
xAU5MaxAllowedDrawDownFactor == 0 || (xAU5MaxAllowedDrawDownFactor > 0 &&
xAU5MaxAllowedDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XAU5 Invalid Max Allowed DrawDown Factor ...");
//
return result;
}
//
// Check Guard Actions ...
//
result =
xAU5CriticalDrawDownFactor > 0 &&
xAU5CriticalDrawDownFactor < 1 &&
xAU5MaxAllowedDrawDownFactor > 0 &&
xAU5MaxAllowedDrawDownFactor < 1;
if (!result)
{
//
LogMessage("XAU5 For Critical Drawdown, you have to Specify Max Drawdown also ...");
//
return result;
}
//
result = xAU5CriticalDrawDownFactor > 0 && xAU5CriticalDrawDownFactor < xAU5MaxAllowedDrawDownFactor;
if (!result)
{
//
LogMessage("XAU5 Critical Drawdown must Smaller than Max Drawdown ...");
//
return result;
}
//
if (xAU5CriticalDrawDownFactor > 0 && xAU5CriticalGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XAU5 IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ...");
}
//
if (xAU5MaxAllowedDrawDownFactor > 0 && xAU5MaxAllowedGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XAU5 IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ...");
}
//
result = true;
//
return result;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,280 @@
///////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XEU5 Signal Provider Library Inputs
// -----------------------------------------------------------
//
// 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
//
// Include Logger ...
#include "../Libraries/x-saherelm.log.lib.mq5"
//
// Include Classes ...
#include "../Classes/x-saherelm.class.lib.mq5"
//
input group "XEU5 Provider";
//
// Commonly Used Configurations ...
input group "XEU5 Common";
//
// Provider ...
input bool xEU5EnableProvider = true; // Enable Provider
input int xEU5NumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
//
// Alerts ...
input bool xEU5EnableAlerts = true; // Enable Events Alert
input bool xEU5EnableHourlyAlerts = false; // Send Alert on each new Hour
input bool xEU5EnableDailyAlerts = false; // Send Alert on each new Day
input bool xEU5EnableWeeklyAlerts = false; // Send Alert on each new Week
input bool xEU5EnableMonthlyAlerts = true; // Send Alert on each new Month
//
// Reports ...
input bool xEU5EnableDailyReports = false; // Send Report on each new Day
input bool xEU5EnableWeeklyReports = false; // Send Report on each new Week
input bool xEU5EnableMonthlyReports = true; // Send Report on each new Month
//
// Trader and Expert Specific Configurations ...
input group "XEU5 Trader";
input int xEU5MagicNumber = 16940560; // Trader MagicNumber
input int xEU5Slippage = 10; // Trader Slippage
//
// Trades Management Configurations ...
input group "XEU5 Trade Management";
input bool xEU5AllowLongTrades = true; // Allow Long Trades
input bool xEU5AllowShortTrades = true; // Allow Short Trades
//
// Risk Management Configurations ...
input group "XEU5 Risk Management";
//
input bool xEU5UseVirtualTPSl = false; // Use Virtual TP SL
//
// Trade Count ...
input int xEU5MaxAllowedTrades = 10; // Max Allowed Trades at Same Time
input ENUM_X_CROSS_SIGNAL_METHOD xEU5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
//
// Max Allowed Trade Age ...
input int xEU5MaxAllowedTradeAge = 1500; // Detect Long Time Trades
input ENUM_X_GUARD_ACTIONS xEU5OldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
//
// Trade Volume Specific Configurations ...
input double xEU5StaticVolumeFactor = 0.0002; // Static Volume baesd on Balance
input ENUM_STATIC_VOLUME_METHODS xEU5StaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
input double xEU5VolumeMultiplier = 0; // Volume Increase Multiplier
input double xEU5ApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
input double xEU5MaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance
input double xEU5IncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
//
// Trade Profits ...
input double xEU5MinRewardInPips = 15; // Minimum Reward Per Trade in Pips
input double xEU5RiskFreeStepInPips = 6; // Make Trades Risk Free Steps in Pips
input double xEU5RiskFreeRate = 0.6; // Volume Multiplier for Risk Free Trades
//
// Guard Riskable Money and Profits ...
input double xEU5CriticalDrawDownFactor = 0.40; // Critical Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xEU5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Critical Drawdown
input double xEU5MaxAllowedDrawDownFactor = 0.45; // Max Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xEU5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_10; // Specify Guard Action on Max Allowed Drawdown
input int xEU5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
//
// Account Conditions for Trading ...
input double xEU5BalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
input double xEU5FreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
//
// Validate Inputs before Initialization ...
bool XEU5ValidateInputs()
{
//
bool result = false;
//
// Implement Other Verifications ...
//
// Check Trading Availability ...
bool isTradeAvailable = xEU5AllowLongTrades || xEU5AllowShortTrades;
if (!isTradeAvailable)
{
LogMessage("XEU5 => Warning: Trading disabled ...");
}
//
// Chekc Number of reading items per tick ...
result = xEU5NumberOfItemsPerTick >= 5;
if (!result)
{
//
LogMessage("XEU5 invalid Number of items Reading Per Tick ...");
//
return result;
}
//
// Check Max Allowed Trades Count ...
result = isTradeAvailable && xEU5MaxAllowedTrades >= 1;
if (!result)
{
//
LogMessage("XEU5 Number of Trades not valid ...");
//
return result;
}
//
// Check Free Margin ...
result =
isTradeAvailable &&
xEU5FreeMarginFactorForOpenTrades > 0 &&
xEU5FreeMarginFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XEU5 Invalid Free Margin ...");
//
return result;
}
//
// Check min Balance for Open Trades ...
result =
isTradeAvailable &&
xEU5BalanceFactorForOpenTrades > 0 &&
xEU5BalanceFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XEU5 Invalid Min Balance for Open Trades ...");
//
return result;
}
//
// Check Min Reward Per Trade ...
result = xEU5MinRewardInPips > 0;
if (!result)
{
//
LogMessage("XEU5 Invalid Min Reward Per Trade ...");
//
return result;
}
//
// Check Trades Volume ...
result = xEU5StaticVolumeFactor > 0;
if (!result)
{
//
LogMessage("XEU5 Invalid Static Volume ...");
//
return result;
}
//
// Check Volume Multiplier ...
result = xEU5VolumeMultiplier >= 0;
if (!result)
{
//
LogMessage("XEU5 Invalid Volume Multiplier ...");
//
return result;
}
//
result =
xEU5CriticalDrawDownFactor == 0 || (xEU5CriticalDrawDownFactor > 0 &&
xEU5CriticalDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XEU5 Invalid Critical DrawDown Factor ...");
//
return result;
}
//
result =
xEU5MaxAllowedDrawDownFactor == 0 || (xEU5MaxAllowedDrawDownFactor > 0 &&
xEU5MaxAllowedDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XEU5 Invalid Max Allowed DrawDown Factor ...");
//
return result;
}
//
// Check Guard Actions ...
//
result =
xEU5CriticalDrawDownFactor > 0 &&
xEU5CriticalDrawDownFactor < 1 &&
xEU5MaxAllowedDrawDownFactor > 0 &&
xEU5MaxAllowedDrawDownFactor < 1;
if (!result)
{
//
LogMessage("XEU5 For Critical Drawdown, you have to Specify Max Drawdown also ...");
//
return result;
}
//
result = xEU5CriticalDrawDownFactor > 0 && xEU5CriticalDrawDownFactor < xEU5MaxAllowedDrawDownFactor;
if (!result)
{
//
LogMessage("XEU5 Critical Drawdown must Smaller than Max Drawdown ...");
//
return result;
}
//
if (xEU5CriticalDrawDownFactor > 0 && xEU5CriticalGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XEU5 IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ...");
}
//
if (xEU5MaxAllowedDrawDownFactor > 0 && xEU5MaxAllowedGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XEU5 IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ...");
}
//
result = true;
//
return result;
}