apply some fix on XAU5 ...

This commit is contained in:
2024-02-24 08:23:11 +03:30
parent e5dd6854fb
commit f482e4097a
9 changed files with 5779 additions and 8704 deletions
+3 -3
View File
@@ -254,14 +254,14 @@ struct XMarketConditions
//
//
class XCPriver : public XCBase
class XCProvider : public XCBase
{
//
// Public ...
public:
//
// Constructor ...
XCPriver(
XCProvider(
//
// Common Requirements ...
string xSymbol, // Which Symbol is Used
@@ -362,7 +362,7 @@ public:
//
// Deconstructor ...
~XCPriver() {}
~XCProvider() {}
//
// START Common Functions ...
@@ -17,7 +17,7 @@
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XUSCHF5 EA"
#property description "SaherElm XAU5 EA"
#property strict
//
@@ -28,9 +28,9 @@ input group "Commons";
//
// XCTIMER inputs ...
input bool xUSCHF5ShowCandleTimer = true; // Show Condle Remaining Time
input color xUSCHF5CandleTimerColot = clrYellow; // Candle Timer Color
input ENUM_BASE_CORNER xUSCHF5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
input bool xAU5ShowCandleTimer = true; // Show Condle Remaining Time
input color xAU5CandleTimerColot = clrYellow; // Candle Timer Color
input ENUM_BASE_CORNER xAU5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
//
// END Inputs ...
@@ -57,8 +57,8 @@ input ENUM_BASE_CORNER xUSCHF5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where t
#include "../Libraries/x-saherelm.draw.lib.mq5"
//
// XUSCHF5 Signal Provider ...
#include "../Providers/x-saherelm.xuschf5.provider.lib.mq5"
// XAU5 Signal Provider ...
#include "../Providers/x-saherelm.xau5.provider.lib.mq5"
//
// END Including Providers ...
@@ -67,13 +67,13 @@ input ENUM_BASE_CORNER xUSCHF5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where t
//
// START Global Definitions: Variables, Properties and etc ...
//
bool isXUSCHF5NewHour;
bool isXUSCHF5NewDay;
bool isXUSCHF5NewWeek;
bool isXUSCHF5NewMonth;
bool isXAU5NewHour;
bool isXAU5NewDay;
bool isXAU5NewWeek;
bool isXAU5NewMonth;
//
int xUSCHF5CTimerHandler = INVALID_HANDLE;
int xAU5CTimerHandler = INVALID_HANDLE;
//
// END Global Definitions: Variables, Properties and etc ...
//
@@ -87,7 +87,7 @@ int xUSCHF5CTimerHandler = INVALID_HANDLE;
int OnInit()
{
//
logTag = "XUSCHF5EA";
logTag = "XAU5EA";
drawPrefix = logTag;
alertPrefix = logTag;
@@ -107,17 +107,17 @@ int OnInit()
}
//
// Initialize XUSCHF5 Provider ...
if (!XUSCHF5InitSignalProviderLibrary())
// Initialize XAU5 Provider ...
if (!XAU5InitSignalProviderLibrary())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// Init XCTimer ...
if (xUSCHF5ShowCandleTimer)
if (xAU5ShowCandleTimer)
{
if (!XUSCHF5CTimerInit())
if (!XAU5CTimerInit())
{
return INIT_FAILED;
}
@@ -148,15 +148,15 @@ void OnDeinit(const int reason)
// Here we can handle De Initialization Reasons ...
//
// De Initialize XUSCHF5 Provider ...
XUSCHF5DeinitSignalProviderLibrary(reason);
// De Initialize XAU5 Provider ...
XAU5DeinitSignalProviderLibrary(reason);
//
// De Init XDraw Library ...
// OnDeinitDrawLibrary();
//
IndicatorRelease(xUSCHF5CTimerHandler);
IndicatorRelease(xAU5CTimerHandler);
}
//
@@ -166,15 +166,15 @@ void OnTick()
//
// Handle Monthly Alert ...
bool isFirstMonth = xMonth == -1;
isXUSCHF5NewMonth = IsNewMonth();
isXAU5NewMonth = IsNewMonth();
bool canMonthlyAlert =
isXUSCHF5NewMonth &&
xUSCHF5EnableAlerts &&
xUSCHF5EnableMonthlyAlerts;
isXAU5NewMonth &&
xAU5EnableAlerts &&
xAU5EnableMonthlyAlerts;
bool canMonthlyReport =
!isFirstMonth &&
canMonthlyAlert &&
xUSCHF5EnableMonthlyReports;
xAU5EnableMonthlyReports;
if (canMonthlyAlert)
{
//
@@ -185,7 +185,7 @@ void OnTick()
if (canMonthlyReport)
{
//
string report = xUSCHF5Reporter.GenerateReportString(XREPORT_MONTHLY);
string report = xAU5Reporter.GenerateReportString(XREPORT_MONTHLY);
//
message = "Last Month Report:\n" + report;
@@ -193,7 +193,7 @@ void OnTick()
//
// Reset Report ...
xUSCHF5Reporter.Reset(XREPORT_MONTHLY);
xAU5Reporter.Reset(XREPORT_MONTHLY);
//
SendAlert(message);
@@ -202,15 +202,15 @@ void OnTick()
//
// Handle Weekly Alert ...
bool isFirstWeek = xDayOfWeek == -1;
isXUSCHF5NewWeek = IsNewWeek();
isXAU5NewWeek = IsNewWeek();
bool canWeeklyAlert =
isXUSCHF5NewWeek &&
xUSCHF5EnableAlerts &&
xUSCHF5EnableWeeklyAlerts;
isXAU5NewWeek &&
xAU5EnableAlerts &&
xAU5EnableWeeklyAlerts;
bool canWeeklyReport =
!isFirstWeek &&
canWeeklyAlert &&
xUSCHF5EnableWeeklyReports;
xAU5EnableWeeklyReports;
if (canWeeklyAlert)
{
//
@@ -221,7 +221,7 @@ void OnTick()
if (canWeeklyReport)
{
//
string report = xUSCHF5Reporter.GenerateReportString(XREPORT_WEEKLY);
string report = xAU5Reporter.GenerateReportString(XREPORT_WEEKLY);
//
message = "Last Week Report:\n" + report;
@@ -229,7 +229,7 @@ void OnTick()
//
// Reset Report ...
xUSCHF5Reporter.Reset(XREPORT_WEEKLY);
xAU5Reporter.Reset(XREPORT_WEEKLY);
//
SendAlert(message);
@@ -238,15 +238,15 @@ void OnTick()
//
// Handle Daily Alert ...
bool isFirstDay = xDay == -1;
isXUSCHF5NewDay = IsNewDay();
isXAU5NewDay = IsNewDay();
bool canDailyAlert =
isXUSCHF5NewDay &&
xUSCHF5EnableAlerts &&
xUSCHF5EnableDailyAlerts;
isXAU5NewDay &&
xAU5EnableAlerts &&
xAU5EnableDailyAlerts;
bool canDailyReport =
!isFirstDay &&
canDailyAlert &&
xUSCHF5EnableDailyReports;
xAU5EnableDailyReports;
if (canDailyAlert)
{
//
@@ -257,7 +257,7 @@ void OnTick()
if (canDailyReport)
{
//
string report = xUSCHF5Reporter.GenerateReportString(XREPORT_DAILY);
string report = xAU5Reporter.GenerateReportString(XREPORT_DAILY);
//
message = "Last Week Report:\n" + report;
@@ -265,7 +265,7 @@ void OnTick()
//
// Reset Report ...
xUSCHF5Reporter.Reset(XREPORT_DAILY);
xAU5Reporter.Reset(XREPORT_DAILY);
//
SendAlert(message);
@@ -274,11 +274,11 @@ void OnTick()
//
// Handle Hourly Alert ...
bool isFirstHour = xHour == -1;
isXUSCHF5NewHour = IsNewHour();
isXAU5NewHour = IsNewHour();
bool canHourlyAlert =
isXUSCHF5NewHour &&
xUSCHF5EnableAlerts &&
xUSCHF5EnableHourlyAlerts;
isXAU5NewHour &&
xAU5EnableAlerts &&
xAU5EnableHourlyAlerts;
if (canHourlyAlert)
{
//
@@ -290,33 +290,33 @@ void OnTick()
//
// Prevent Going Forward if user Disable it ...
if (xUSCHF5EnableProvider)
if (xAU5EnableProvider)
{
//
// Handle Processing on XUSCHF5 Signal Provider ...
XUSCHF5SignalProviderDoControlState();
// Handle Processing on XAU5 Signal Provider ...
XAU5SignalProviderDoControlState();
}
//
// Check Can Ignore Tick or not ..
bool canIgnoreTick = xUSCHF5IsTestMode
bool canIgnoreTick = xAU5IsTestMode
? !IsNewCandle()
: !IsNewCandle() && xUSCHF5WaitUntilNextCandle;
: !IsNewCandle() && xAU5WaitUntilNextCandle;
if (canIgnoreTick)
{
return;
}
//
xUSCHF5WaitUntilNextCandle = false;
xAU5WaitUntilNextCandle = false;
//
// Prevent Going Forward if user Disable it ...
if (xUSCHF5EnableProvider)
if (xAU5EnableProvider)
{
//
// Handle Processing on XUSCHF5 Signal Provider ...
XUSCHF5SignalProviderHandleTick();
// Handle Processing on XAU5 Signal Provider ...
XAU5SignalProviderHandleTick();
}
}
@@ -327,11 +327,11 @@ void OnTrade()
//
// Prevent Going Forward if user Disable it ...
if (xUSCHF5EnableProvider)
if (xAU5EnableProvider)
{
//
// Handle Processing Trades on XUSCHF5 Signal Provider ...
XUSCHF5SignalProviderHandleTrade();
// Handle Processing Trades on XAU5 Signal Provider ...
XAU5SignalProviderHandleTrade();
}
}
@@ -354,8 +354,8 @@ bool ValidateInputs()
// Validate Args ...
//
// Validate XUSCHF5 Provider Inputs ...
result = XUSCHF5ValidateInputs();
// Validate XAU5 Provider Inputs ...
result = XAU5ValidateInputs();
if (!result)
{
return false;
@@ -370,23 +370,23 @@ bool ValidateInputs()
return result;
}
bool XUSCHF5CTimerInit()
bool XAU5CTimerInit()
{
//
bool result = true;
//
xUSCHF5CTimerHandler = iCustom(
xAU5CTimerHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xctimer.indicator",
//
// Inputs ...
xUSCHF5CandleTimerColot,
xUSCHF5CandleTimerCorner);
xAU5CandleTimerColot,
xAU5CandleTimerCorner);
//
if (xUSCHF5CTimerHandler == INVALID_HANDLE)
if (xAU5CTimerHandler == INVALID_HANDLE)
{
result = false;
}
@@ -0,0 +1,283 @@
///////////////////////////////////////////////////////////////
//
// 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 = false; // 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 = false; // 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";
//
// 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 = 1500; // 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.0001; // 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 = 60; // Minimum Reward Per Trade in Pips
input double xAU5RiskFreeStepInPips = 0; // Make Trades Risk Free Steps in Pips
input double xAU5RiskFreeRate = 0; // Volume Multiplier for Risk Free Trades
//
// Guard Riskable Money and Profits ...
input double xAU5CriticalDrawDownFactor = 0.20; // Critical Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xAU5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // Specify Guard Action on Critical Drawdown
input double xAU5MaxAllowedDrawDownFactor = 0.25; // Max Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xAU5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // 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
//
// May be Used Later as Input Params ...
bool xAU5UseVirtualTPSl = false; // Use Virtual TP SL
bool xAU5EnableSignalAlerts = false; // Send Signal Alert
//
// 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;
}
@@ -1,283 +0,0 @@
///////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XUSCHF5 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 "XUSCHF5 Provider";
//
// Commonly Used Configurations ...
input group "XUSCHF5 Common";
//
// Provider ...
input bool xUSCHF5EnableProvider = true; // Enable Provider
input int xUSCHF5NumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
//
// Alerts ...
input bool xUSCHF5EnableAlerts = true; // Enable Events Alert
input bool xUSCHF5EnableHourlyAlerts = false; // Send Alert on each new Hour
input bool xUSCHF5EnableDailyAlerts = false; // Send Alert on each new Day
input bool xUSCHF5EnableWeeklyAlerts = false; // Send Alert on each new Week
input bool xUSCHF5EnableMonthlyAlerts = true; // Send Alert on each new Month
//
// Reports ...
input bool xUSCHF5EnableDailyReports = false; // Send Report on each new Day
input bool xUSCHF5EnableWeeklyReports = false; // Send Report on each new Week
input bool xUSCHF5EnableMonthlyReports = true; // Send Report on each new Month
//
// Trader and Expert Specific Configurations ...
input group "XUSCHF5 Trader";
input int xUSCHF5MagicNumber = 16940562; // Trader MagicNumber
input int xUSCHF5Slippage = 10; // Trader Slippage
//
// Trades Management Configurations ...
input group "XUSCHF5 Trade Management";
input bool xUSCHF5AllowLongTrades = true; // Allow Long Trades
input bool xUSCHF5AllowShortTrades = true; // Allow Short Trades
//
// Risk Management Configurations ...
input group "XUSCHF5 Risk Management";
//
// Trade Count ...
input int xUSCHF5MaxAllowedTrades = 10; // Max Allowed Trades at Same Time
input ENUM_X_CROSS_SIGNAL_METHOD xUSCHF5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
//
// Max Allowed Trade Age ...
input int xUSCHF5MaxAllowedTradeAge = 1500; // Detect Long Time Trades
input ENUM_X_GUARD_ACTIONS xUSCHF5OldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
//
// Trade Volume Specific Configurations ...
input double xUSCHF5StaticVolumeFactor = 0.0001; // Static Volume baesd on Balance
input ENUM_STATIC_VOLUME_METHODS xUSCHF5StaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
input double xUSCHF5VolumeMultiplier = 0; // Volume Increase Multiplier
input double xUSCHF5ApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
input double xUSCHF5MaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance
input double xUSCHF5IncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
//
// Trade Profits ...
input double xUSCHF5MinRewardInPips = 6; // Minimum Reward Per Trade in Pips
input double xUSCHF5RiskFreeStepInPips = 0; // Make Trades Risk Free Steps in Pips
input double xUSCHF5RiskFreeRate = 0; // Volume Multiplier for Risk Free Trades
//
// Guard Riskable Money and Profits ...
input double xUSCHF5CriticalDrawDownFactor = 0.15; // Critical Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xUSCHF5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Critical Drawdown
input double xUSCHF5MaxAllowedDrawDownFactor = 0.20; // Max Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xUSCHF5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_10; // Specify Guard Action on Max Allowed Drawdown
input int xUSCHF5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
//
// Account Conditions for Trading ...
input double xUSCHF5BalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
input double xUSCHF5FreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
//
// May be Used Later as Input Params ...
bool xUSCHF5UseVirtualTPSl = false; // Use Virtual TP SL
bool xUSCHF5EnableSignalAlerts = false; // Send Signal Alert
//
// Validate Inputs before Initialization ...
bool XUSCHF5ValidateInputs()
{
//
bool result = false;
//
// Implement Other Verifications ...
//
// Check Trading Availability ...
bool isTradeAvailable = xUSCHF5AllowLongTrades || xUSCHF5AllowShortTrades;
if (!isTradeAvailable)
{
LogMessage("XUSCHF5 => Warning: Trading disabled ...");
}
//
// Chekc Number of reading items per tick ...
result = xUSCHF5NumberOfItemsPerTick >= 5;
if (!result)
{
//
LogMessage("XUSCHF5 invalid Number of items Reading Per Tick ...");
//
return result;
}
//
// Check Max Allowed Trades Count ...
result = isTradeAvailable && xUSCHF5MaxAllowedTrades >= 1;
if (!result)
{
//
LogMessage("XUSCHF5 Number of Trades not valid ...");
//
return result;
}
//
// Check Free Margin ...
result =
isTradeAvailable &&
xUSCHF5FreeMarginFactorForOpenTrades > 0 &&
xUSCHF5FreeMarginFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XUSCHF5 Invalid Free Margin ...");
//
return result;
}
//
// Check min Balance for Open Trades ...
result =
isTradeAvailable &&
xUSCHF5BalanceFactorForOpenTrades > 0 &&
xUSCHF5BalanceFactorForOpenTrades < 1;
if (!result)
{
//
LogMessage("XUSCHF5 Invalid Min Balance for Open Trades ...");
//
return result;
}
//
// Check Min Reward Per Trade ...
result = xUSCHF5MinRewardInPips > 0;
if (!result)
{
//
LogMessage("XUSCHF5 Invalid Min Reward Per Trade ...");
//
return result;
}
//
// Check Trades Volume ...
result = xUSCHF5StaticVolumeFactor > 0;
if (!result)
{
//
LogMessage("XUSCHF5 Invalid Static Volume ...");
//
return result;
}
//
// Check Volume Multiplier ...
result = xUSCHF5VolumeMultiplier >= 0;
if (!result)
{
//
LogMessage("XUSCHF5 Invalid Volume Multiplier ...");
//
return result;
}
//
result =
xUSCHF5CriticalDrawDownFactor == 0 || (xUSCHF5CriticalDrawDownFactor > 0 &&
xUSCHF5CriticalDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XUSCHF5 Invalid Critical DrawDown Factor ...");
//
return result;
}
//
result =
xUSCHF5MaxAllowedDrawDownFactor == 0 || (xUSCHF5MaxAllowedDrawDownFactor > 0 &&
xUSCHF5MaxAllowedDrawDownFactor < 1);
if (!result)
{
//
LogMessage("XUSCHF5 Invalid Max Allowed DrawDown Factor ...");
//
return result;
}
//
// Check Guard Actions ...
//
result =
xUSCHF5CriticalDrawDownFactor > 0 &&
xUSCHF5CriticalDrawDownFactor < 1 &&
xUSCHF5MaxAllowedDrawDownFactor > 0 &&
xUSCHF5MaxAllowedDrawDownFactor < 1;
if (!result)
{
//
LogMessage("XUSCHF5 For Critical Drawdown, you have to Specify Max Drawdown also ...");
//
return result;
}
//
result = xUSCHF5CriticalDrawDownFactor > 0 && xUSCHF5CriticalDrawDownFactor < xUSCHF5MaxAllowedDrawDownFactor;
if (!result)
{
//
LogMessage("XUSCHF5 Critical Drawdown must Smaller than Max Drawdown ...");
//
return result;
}
//
if (xUSCHF5CriticalDrawDownFactor > 0 && xUSCHF5CriticalGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XUSCHF5 IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ...");
}
//
if (xUSCHF5MaxAllowedDrawDownFactor > 0 && xUSCHF5MaxAllowedGuardAction == X_GUARD_DO_NOTHING)
{
LogMessage("XUSCHF5 IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ...");
}
//
result = true;
//
return result;
}
@@ -254,14 +254,14 @@ struct XMarketConditions
//
//
class XCPriver : public XCBase
class XCProvider : public XCBase
{
//
// Public ...
public:
//
// Constructor ...
XCPriver(
XCProvider(
//
// Common Requirements ...
string xSymbol, // Which Symbol is Used
@@ -362,7 +362,7 @@ public:
//
// Deconstructor ...
~XCPriver() {}
~XCProvider() {}
//
// START Common Functions ...
@@ -58,10 +58,10 @@ input bool xAU5XTSFIAllowShortSignals = true; // Enable Short Signals
//
// XOBDLH ...
input group "XAU5 XOBDLH Signaller";
input bool xAU5XOBDLHEnableSignaller = true; // Enable Signaller
input bool xAU5XOBDLHAllowLongSignals = true; // Enable Long Signals
input bool xAU5XOBDLHAllowShortSignals = true; // Enable Short Signals
// input group "XAU5 XOBDLH Signaller";
// input bool xAU5XOBDLHEnableSignaller = true; // Enable Signaller
// input bool xAU5XOBDLHAllowLongSignals = true; // Enable Long Signals
// input bool xAU5XOBDLHAllowShortSignals = true; // Enable Short Signals
//
// XCHMACC ...
@@ -72,17 +72,17 @@ input bool xAU5XCHMACCAllowShortSignals = true; // Enable Short Signals
//
// XCHMAMX ...
input group "XAU5 XCHMAMX Signaller";
input bool xAU5XCHMAMXEnableSignaller = true; // Enable Signaller
input bool xAU5XCHMAMXAllowLongSignals = true; // Enable Long Signals
input bool xAU5XCHMAMXAllowShortSignals = true; // Enable Short Signals
// input group "XAU5 XCHMAMX Signaller";
// input bool xAU5XCHMAMXEnableSignaller = true; // Enable Signaller
// input bool xAU5XCHMAMXAllowLongSignals = true; // Enable Long Signals
// input bool xAU5XCHMAMXAllowShortSignals = true; // Enable Short Signals
//
// XCHMAMN ...
input group "XAU5 XCHMAMN Signaller";
input bool xAU5XCHMAMNEnableSignaller = true; // Enable Signaller
input bool xAU5XCHMAMNAllowLongSignals = true; // Enable Long Signals
input bool xAU5XCHMAMNAllowShortSignals = true; // Enable Short Signals
// input group "XAU5 XCHMAMN Signaller";
// input bool xAU5XCHMAMNEnableSignaller = true; // Enable Signaller
// input bool xAU5XCHMAMNAllowLongSignals = true; // Enable Long Signals
// input bool xAU5XCHMAMNAllowShortSignals = true; // Enable Short Signals
//
// Check in Test Mode or not ...
@@ -128,9 +128,9 @@ bool xAU5MXTSFIAllowShortSignals = xAU5XTSFIAllowShortSignals;
//
// XOBDLH ...
bool xAU5MXOBDLHEnableSignaller = xAU5XOBDLHEnableSignaller;
bool xAU5MXOBDLHAllowLongSignals = xAU5XOBDLHAllowLongSignals;
bool xAU5MXOBDLHAllowShortSignals = xAU5XOBDLHAllowShortSignals;
bool xAU5MXOBDLHEnableSignaller = false; //xAU5XOBDLHEnableSignaller;
bool xAU5MXOBDLHAllowLongSignals = false; //xAU5XOBDLHAllowLongSignals;
bool xAU5MXOBDLHAllowShortSignals = false; //xAU5XOBDLHAllowShortSignals;
//
// XCHMACC ...
@@ -140,18 +140,18 @@ bool xAU5MXCHMACCAllowShortSignals = xAU5XCHMACCAllowShortSignals;
//
// XCHMAMX ...
bool xAU5MXCHMAMXEnableSignaller = xAU5XCHMAMXEnableSignaller;
bool xAU5MXCHMAMXAllowLongSignals = xAU5XCHMAMXAllowLongSignals;
bool xAU5MXCHMAMXAllowShortSignals = xAU5XCHMAMXAllowShortSignals;
bool xAU5MXCHMAMXEnableSignaller = false; // xAU5XCHMAMXEnableSignaller;
bool xAU5MXCHMAMXAllowLongSignals = false; // xAU5XCHMAMXAllowLongSignals;
bool xAU5MXCHMAMXAllowShortSignals = false; // xAU5XCHMAMXAllowShortSignals;
//
// XCHMAMN ...
bool xAU5MXCHMAMNEnableSignaller = xAU5XCHMAMNEnableSignaller;
bool xAU5MXCHMAMNAllowLongSignals = xAU5XCHMAMNAllowLongSignals;
bool xAU5MXCHMAMNAllowShortSignals = xAU5XCHMAMNAllowShortSignals;
bool xAU5MXCHMAMNEnableSignaller = false; // xAU5XCHMAMNEnableSignaller;
bool xAU5MXCHMAMNAllowLongSignals = false; // xAU5XCHMAMNAllowLongSignals;
bool xAU5MXCHMAMNAllowShortSignals = false; // xAU5XCHMAMNAllowShortSignals;
//
XCPriver *xAU5Provider;
XCProvider *xAU5Provider;
//
// Validate Indicators Inputs ...
@@ -241,8 +241,8 @@ bool XAU5ValidateIndicatorsInputs()
}
//
// Make an Instance Of XCPriver Class for Use ...
xAU5Provider = new XCPriver(
// Make an Instance Of XCProvider Class for Use ...
xAU5Provider = new XCProvider(
//
// Commons ...
_Symbol,
@@ -436,10 +436,10 @@ bool XAU5InitIndicators()
//
// XOBDLH ...
bool isXOBDLHEnable =
xAU5XOBDLHEnableSignaller &&
(xAU5XOBDLHAllowLongSignals ||
xAU5XOBDLHAllowShortSignals);
bool isXOBDLHEnable = false;
// xAU5XOBDLHEnableSignaller &&
// (xAU5XOBDLHAllowLongSignals ||
// xAU5XOBDLHAllowShortSignals);
//
// XCHMACC ...
@@ -450,17 +450,17 @@ bool XAU5InitIndicators()
//
// XCHMAMX ...
bool isXCHMAMXEnable =
xAU5XCHMAMXEnableSignaller &&
(xAU5XCHMAMXAllowLongSignals ||
xAU5XCHMAMXAllowShortSignals);
bool isXCHMAMXEnable = false;
// xAU5XCHMAMXEnableSignaller &&
// (xAU5XCHMAMXAllowLongSignals ||
// xAU5XCHMAMXAllowShortSignals);
//
// XCHMAMN ...
bool isXCHMAMNEnable =
xAU5XCHMAMNEnableSignaller &&
(xAU5XCHMAMNAllowLongSignals ||
xAU5XCHMAMNAllowShortSignals);
bool isXCHMAMNEnable = false;
// xAU5XCHMAMNEnableSignaller &&
// (xAU5XCHMAMNAllowLongSignals ||
// xAU5XCHMAMNAllowShortSignals);
//
bool hasSignaller =
@@ -1103,12 +1103,12 @@ void XAU5DisableLongSignallers()
//
// XOBDLH ...
if (xAU5MXOBDLHEnableSignaller)
{
//
xAU5Provider.DisbaleXOBDLHLongs();
xAU5MXOBDLHAllowLongSignals = false;
}
// if (xAU5MXOBDLHEnableSignaller)
// {
// //
// xAU5Provider.DisbaleXOBDLHLongs();
// xAU5MXOBDLHAllowLongSignals = false;
// }
//
// XCHMACC ...
@@ -1121,21 +1121,21 @@ void XAU5DisableLongSignallers()
//
// XCHMAMX ...
if (xAU5MXCHMAMXEnableSignaller)
{
//
xAU5Provider.DisbaleXCHMAMXLongs();
xAU5MXCHMAMXAllowLongSignals = false;
}
// if (xAU5MXCHMAMXEnableSignaller)
// {
// //
// xAU5Provider.DisbaleXCHMAMXLongs();
// xAU5MXCHMAMXAllowLongSignals = false;
// }
//
// XCHMAMN ...
if (xAU5MXCHMAMNEnableSignaller)
{
//
xAU5Provider.DisbaleXCHMAMNLongs();
xAU5MXCHMAMNAllowLongSignals = false;
}
// if (xAU5MXCHMAMNEnableSignaller)
// {
// //
// xAU5Provider.DisbaleXCHMAMNLongs();
// xAU5MXCHMAMNAllowLongSignals = false;
// }
}
//
@@ -1213,20 +1213,20 @@ void XAU5EnableLongSignallers()
//
// XOBDLH ...
if (xAU5MXOBDLHEnableSignaller)
{
//
xAU5MXOBDLHAllowLongSignals =
xAU5XOBDLHAllowLongSignals
? true
: xAU5MXOBDLHAllowLongSignals;
// if (xAU5MXOBDLHEnableSignaller)
// {
// //
// xAU5MXOBDLHAllowLongSignals =
// xAU5XOBDLHAllowLongSignals
// ? true
// : xAU5MXOBDLHAllowLongSignals;
//
if (xAU5MXOBDLHAllowLongSignals)
{
xAU5Provider.EnableXOBDLHLongs();
}
}
// //
// if (xAU5MXOBDLHAllowLongSignals)
// {
// xAU5Provider.EnableXOBDLHLongs();
// }
// }
//
// XCHMACC ...
@@ -1247,37 +1247,37 @@ void XAU5EnableLongSignallers()
//
// XCHMAMX ...
if (xAU5MXCHMAMXEnableSignaller)
{
//
xAU5MXCHMAMXAllowLongSignals =
xAU5XCHMAMXAllowLongSignals
? true
: xAU5MXCHMAMXAllowLongSignals;
// if (xAU5MXCHMAMXEnableSignaller)
// {
// //
// xAU5MXCHMAMXAllowLongSignals =
// xAU5XCHMAMXAllowLongSignals
// ? true
// : xAU5MXCHMAMXAllowLongSignals;
//
if (xAU5MXCHMAMXAllowLongSignals)
{
xAU5Provider.EnableXCHMAMXLongs();
}
}
// //
// if (xAU5MXCHMAMXAllowLongSignals)
// {
// xAU5Provider.EnableXCHMAMXLongs();
// }
// }
//
// XCHMAMN ...
if (xAU5MXCHMAMNEnableSignaller)
{
//
xAU5MXCHMAMNAllowLongSignals =
xAU5XCHMAMNAllowLongSignals
? true
: xAU5MXCHMAMNAllowLongSignals;
// if (xAU5MXCHMAMNEnableSignaller)
// {
// //
// xAU5MXCHMAMNAllowLongSignals =
// xAU5XCHMAMNAllowLongSignals
// ? true
// : xAU5MXCHMAMNAllowLongSignals;
//
if (xAU5MXCHMAMNAllowLongSignals)
{
xAU5Provider.EnableXCHMAMNLongs();
}
}
// //
// if (xAU5MXCHMAMNAllowLongSignals)
// {
// xAU5Provider.EnableXCHMAMNLongs();
// }
// }
}
//
@@ -1322,12 +1322,12 @@ void XAU5DisableShortSignallers()
//
// XOBDLH ...
if (xAU5MXOBDLHEnableSignaller)
{
//
xAU5Provider.DisableXOBDLHShorts();
xAU5MXOBDLHAllowShortSignals = false;
}
// if (xAU5MXOBDLHEnableSignaller)
// {
// //
// xAU5Provider.DisableXOBDLHShorts();
// xAU5MXOBDLHAllowShortSignals = false;
// }
//
// XCHMACC ...
@@ -1340,21 +1340,21 @@ void XAU5DisableShortSignallers()
//
// XCHMAMX ...
if (xAU5MXCHMAMXEnableSignaller)
{
//
xAU5Provider.DisableXCHMAMXShorts();
xAU5MXCHMAMXAllowShortSignals = false;
}
// if (xAU5MXCHMAMXEnableSignaller)
// {
// //
// xAU5Provider.DisableXCHMAMXShorts();
// xAU5MXCHMAMXAllowShortSignals = false;
// }
//
// XCHMAMN ...
if (xAU5MXCHMAMNEnableSignaller)
{
//
xAU5Provider.DisableXCHMAMNShorts();
xAU5MXCHMAMNAllowShortSignals = false;
}
// if (xAU5MXCHMAMNEnableSignaller)
// {
// //
// xAU5Provider.DisableXCHMAMNShorts();
// xAU5MXCHMAMNAllowShortSignals = false;
// }
}
//
@@ -1432,20 +1432,20 @@ void XAU5EnableShortSignallers()
//
// XOBDLH ...
if (xAU5MXOBDLHEnableSignaller)
{
//
xAU5MXOBDLHAllowShortSignals =
xAU5XOBDLHAllowShortSignals
? true
: xAU5MXOBDLHAllowShortSignals;
// if (xAU5MXOBDLHEnableSignaller)
// {
// //
// xAU5MXOBDLHAllowShortSignals =
// xAU5XOBDLHAllowShortSignals
// ? true
// : xAU5MXOBDLHAllowShortSignals;
//
if (xAU5MXOBDLHAllowShortSignals)
{
xAU5Provider.EnableXOBDLHShorts();
}
}
// //
// if (xAU5MXOBDLHAllowShortSignals)
// {
// xAU5Provider.EnableXOBDLHShorts();
// }
// }
//
// XCHMACC ...
@@ -1466,37 +1466,37 @@ void XAU5EnableShortSignallers()
//
// XCHMAMX ...
if (xAU5MXCHMAMXEnableSignaller)
{
//
xAU5MXCHMAMXAllowShortSignals =
xAU5XCHMAMXAllowShortSignals
? true
: xAU5MXCHMAMXAllowShortSignals;
// if (xAU5MXCHMAMXEnableSignaller)
// {
// //
// xAU5MXCHMAMXAllowShortSignals =
// xAU5XCHMAMXAllowShortSignals
// ? true
// : xAU5MXCHMAMXAllowShortSignals;
//
if (xAU5MXCHMAMXAllowShortSignals)
{
xAU5Provider.EnableXCHMAMXShorts();
}
}
// //
// if (xAU5MXCHMAMXAllowShortSignals)
// {
// xAU5Provider.EnableXCHMAMXShorts();
// }
// }
//
// XCHMAMN ...
if (xAU5MXCHMAMNEnableSignaller)
{
//
xAU5MXCHMAMNAllowShortSignals =
xAU5XCHMAMNAllowShortSignals
? true
: xAU5MXCHMAMNAllowShortSignals;
// if (xAU5MXCHMAMNEnableSignaller)
// {
// //
// xAU5MXCHMAMNAllowShortSignals =
// xAU5XCHMAMNAllowShortSignals
// ? true
// : xAU5MXCHMAMNAllowShortSignals;
//
if (xAU5MXCHMAMNAllowShortSignals)
{
xAU5Provider.EnableXCHMAMNShorts();
}
}
// //
// if (xAU5MXCHMAMNAllowShortSignals)
// {
// xAU5Provider.EnableXCHMAMNShorts();
// }
// }
}
//
@@ -36,15 +36,15 @@ 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 = true; // Send Alert on each new Day
input bool xAU5EnableWeeklyAlerts = true; // Send Alert on each new Week
input bool xAU5EnableMonthlyAlerts = true; // Send Alert on each new Month
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 = false; // 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 xAU5EnableDailyReports = false; // Send Report on each new Day
input bool xAU5EnableWeeklyReports = false; // Send Report on each new Week
input bool xAU5EnableMonthlyReports = false; // Send Report on each new Month
//
@@ -68,11 +68,11 @@ input int xAU5MaxAllowedTrades = 10;
input ENUM_X_CROSS_SIGNAL_METHOD xAU5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
//
// Max Allowed Trade Age ...
input int xAU5MaxAllowedTradeAge = 1800; // Detect Long Time Trades
input int xAU5MaxAllowedTradeAge = 1500; // 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 double xAU5StaticVolumeFactor = 0.0001; // 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
@@ -82,14 +82,14 @@ input double xAU5IncreasedMaxSupportedVolumeRate = 0;
// Trade Profits ...
input double xAU5MinRewardInPips = 60; // Minimum Reward Per Trade in Pips
input double xAU5RiskFreeStepInPips = 0; // Make Trades Risk Free Steps in Pips
input double xAU5RiskFreeRate = 0; // Volume Multiplier for Risk Free Trades
input double xAU5RiskFreeRate = 0; // Volume Multiplier for Risk Free Trades
//
// Guard Riskable Money and Profits ...
input double xAU5CriticalDrawDownFactor = 0.30; // 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.40; // 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
input double xAU5CriticalDrawDownFactor = 0.20; // Critical Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xAU5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // Specify Guard Action on Critical Drawdown
input double xAU5MaxAllowedDrawDownFactor = 0.25; // Max Allowed Drawdown Factor based on Balance
input ENUM_X_GUARD_ACTIONS xAU5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Max Allowed Drawdown
input int xAU5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
//
// Account Conditions for Trading ...