refactor xTest EA to XGPUS5 for start Implementation ...
This commit is contained in:
+64
-64
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// SaherElm IT Center MQL5 Expert Advisor
|
||||
// ----------------------------------------
|
||||
// Name: XTEST
|
||||
// Name: XGPUS5
|
||||
// Description: this is an expert controller
|
||||
// advisors which provides a mechanism for use them ...
|
||||
//
|
||||
@@ -17,7 +17,7 @@
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm XTEST EA"
|
||||
#property description "SaherElm XGPUS5 EA"
|
||||
#property strict
|
||||
|
||||
//
|
||||
@@ -28,9 +28,9 @@ input group "Commons";
|
||||
|
||||
//
|
||||
// XCTIMER inputs ...
|
||||
input bool xTESTShowCandleTimer = true; // Show Condle Remaining Time
|
||||
input color xTESTCandleTimerColot = clrYellow; // Candle Timer Color
|
||||
input ENUM_BASE_CORNER xTESTCandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
|
||||
input bool xGPUS5ShowCandleTimer = true; // Show Condle Remaining Time
|
||||
input color xGPUS5CandleTimerColot = clrYellow; // Candle Timer Color
|
||||
input ENUM_BASE_CORNER xGPUS5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
@@ -57,8 +57,8 @@ input ENUM_BASE_CORNER xTESTCandleTimerCorner = CORNER_RIGHT_LOWER; // Where to
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||
|
||||
//
|
||||
// XTEST Signal Provider ...
|
||||
#include "../Providers/x-saherelm.xtest.provider.lib.mq5"
|
||||
// XGPUS5 Signal Provider ...
|
||||
#include "../Providers/x-saherelm.xgpus5.provider.lib.mq5"
|
||||
|
||||
//
|
||||
// END Including Providers ...
|
||||
@@ -67,13 +67,13 @@ input ENUM_BASE_CORNER xTESTCandleTimerCorner = CORNER_RIGHT_LOWER; // Where to
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
bool isXTESTNewHour;
|
||||
bool isXTESTNewDay;
|
||||
bool isXTESTNewWeek;
|
||||
bool isXTESTNewMonth;
|
||||
bool isXGPUS5NewHour;
|
||||
bool isXGPUS5NewDay;
|
||||
bool isXGPUS5NewWeek;
|
||||
bool isXGPUS5NewMonth;
|
||||
|
||||
//
|
||||
int xTESTCTimerHandler = INVALID_HANDLE;
|
||||
int xGPUS5CTimerHandler = INVALID_HANDLE;
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
@@ -87,7 +87,7 @@ int xTESTCTimerHandler = INVALID_HANDLE;
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
logTag = "XTESTEA";
|
||||
logTag = "XGPUS5EA";
|
||||
drawPrefix = logTag;
|
||||
alertPrefix = logTag;
|
||||
|
||||
@@ -107,17 +107,17 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize XTEST Provider ...
|
||||
if (!XTESTInitSignalProviderLibrary())
|
||||
// Initialize XGPUS5 Provider ...
|
||||
if (!XGPUS5InitSignalProviderLibrary())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Init XCTimer ...
|
||||
if (xTESTShowCandleTimer)
|
||||
if (xGPUS5ShowCandleTimer)
|
||||
{
|
||||
if (!XTESTCTimerInit())
|
||||
if (!XGPUS5CTimerInit())
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
@@ -148,15 +148,15 @@ void OnDeinit(const int reason)
|
||||
// Here we can handle De Initialization Reasons ...
|
||||
|
||||
//
|
||||
// De Initialize XTEST Provider ...
|
||||
XTESTDeinitSignalProviderLibrary(reason);
|
||||
// De Initialize XGPUS5 Provider ...
|
||||
XGPUS5DeinitSignalProviderLibrary(reason);
|
||||
|
||||
//
|
||||
// De Init XDraw Library ...
|
||||
// OnDeinitDrawLibrary();
|
||||
|
||||
//
|
||||
IndicatorRelease(xTESTCTimerHandler);
|
||||
IndicatorRelease(xGPUS5CTimerHandler);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -166,15 +166,15 @@ void OnTick()
|
||||
//
|
||||
// Handle Monthly Alert ...
|
||||
bool isFirstMonth = xMonth == -1;
|
||||
isXTESTNewMonth = IsNewMonth();
|
||||
isXGPUS5NewMonth = IsNewMonth();
|
||||
bool canMonthlyAlert =
|
||||
isXTESTNewMonth &&
|
||||
xTESTEnableAlerts &&
|
||||
xTESTEnableMonthlyAlerts;
|
||||
isXGPUS5NewMonth &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableMonthlyAlerts;
|
||||
bool canMonthlyReport =
|
||||
!isFirstMonth &&
|
||||
canMonthlyAlert &&
|
||||
xTESTEnableMonthlyReports;
|
||||
xGPUS5EnableMonthlyReports;
|
||||
if (canMonthlyAlert)
|
||||
{
|
||||
//
|
||||
@@ -185,7 +185,7 @@ void OnTick()
|
||||
if (canMonthlyReport)
|
||||
{
|
||||
//
|
||||
string report = xTESTReporter.GenerateReportString(XREPORT_MONTHLY);
|
||||
string report = xGPUS5Reporter.GenerateReportString(XREPORT_MONTHLY);
|
||||
|
||||
//
|
||||
message = "Last Month Report:\n" + report;
|
||||
@@ -193,7 +193,7 @@ void OnTick()
|
||||
|
||||
//
|
||||
// Reset Report ...
|
||||
xTESTReporter.Reset(XREPORT_MONTHLY);
|
||||
xGPUS5Reporter.Reset(XREPORT_MONTHLY);
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
@@ -202,15 +202,15 @@ void OnTick()
|
||||
//
|
||||
// Handle Weekly Alert ...
|
||||
bool isFirstWeek = xDayOfWeek == -1;
|
||||
isXTESTNewWeek = IsNewWeek();
|
||||
isXGPUS5NewWeek = IsNewWeek();
|
||||
bool canWeeklyAlert =
|
||||
isXTESTNewWeek &&
|
||||
xTESTEnableAlerts &&
|
||||
xTESTEnableWeeklyAlerts;
|
||||
isXGPUS5NewWeek &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableWeeklyAlerts;
|
||||
bool canWeeklyReport =
|
||||
!isFirstWeek &&
|
||||
canWeeklyAlert &&
|
||||
xTESTEnableWeeklyReports;
|
||||
xGPUS5EnableWeeklyReports;
|
||||
if (canWeeklyAlert)
|
||||
{
|
||||
//
|
||||
@@ -221,7 +221,7 @@ void OnTick()
|
||||
if (canWeeklyReport)
|
||||
{
|
||||
//
|
||||
string report = xTESTReporter.GenerateReportString(XREPORT_WEEKLY);
|
||||
string report = xGPUS5Reporter.GenerateReportString(XREPORT_WEEKLY);
|
||||
|
||||
//
|
||||
message = "Last Week Report:\n" + report;
|
||||
@@ -229,7 +229,7 @@ void OnTick()
|
||||
|
||||
//
|
||||
// Reset Report ...
|
||||
xTESTReporter.Reset(XREPORT_WEEKLY);
|
||||
xGPUS5Reporter.Reset(XREPORT_WEEKLY);
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
@@ -238,15 +238,15 @@ void OnTick()
|
||||
//
|
||||
// Handle Daily Alert ...
|
||||
bool isFirstDay = xDay == -1;
|
||||
isXTESTNewDay = IsNewDay();
|
||||
isXGPUS5NewDay = IsNewDay();
|
||||
bool canDailyAlert =
|
||||
isXTESTNewDay &&
|
||||
xTESTEnableAlerts &&
|
||||
xTESTEnableDailyAlerts;
|
||||
isXGPUS5NewDay &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableDailyAlerts;
|
||||
bool canDailyReport =
|
||||
!isFirstDay &&
|
||||
canDailyAlert &&
|
||||
xTESTEnableDailyReports;
|
||||
xGPUS5EnableDailyReports;
|
||||
if (canDailyAlert)
|
||||
{
|
||||
//
|
||||
@@ -257,7 +257,7 @@ void OnTick()
|
||||
if (canDailyReport)
|
||||
{
|
||||
//
|
||||
string report = xTESTReporter.GenerateReportString(XREPORT_DAILY);
|
||||
string report = xGPUS5Reporter.GenerateReportString(XREPORT_DAILY);
|
||||
|
||||
//
|
||||
message = "Last Week Report:\n" + report;
|
||||
@@ -265,7 +265,7 @@ void OnTick()
|
||||
|
||||
//
|
||||
// Reset Report ...
|
||||
xTESTReporter.Reset(XREPORT_DAILY);
|
||||
xGPUS5Reporter.Reset(XREPORT_DAILY);
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
@@ -274,11 +274,11 @@ void OnTick()
|
||||
//
|
||||
// Handle Hourly Alert ...
|
||||
bool isFirstHour = xHour == -1;
|
||||
isXTESTNewHour = IsNewHour();
|
||||
isXGPUS5NewHour = IsNewHour();
|
||||
bool canHourlyAlert =
|
||||
isXTESTNewHour &&
|
||||
xTESTEnableAlerts &&
|
||||
xTESTEnableHourlyAlerts;
|
||||
isXGPUS5NewHour &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableHourlyAlerts;
|
||||
if (canHourlyAlert)
|
||||
{
|
||||
//
|
||||
@@ -290,33 +290,33 @@ void OnTick()
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xTESTEnableProvider)
|
||||
if (xGPUS5EnableProvider)
|
||||
{
|
||||
//
|
||||
// Handle Processing on XTEST Signal Provider ...
|
||||
XTESTSignalProviderDoControlState();
|
||||
// Handle Processing on XGPUS5 Signal Provider ...
|
||||
XGPUS5SignalProviderDoControlState();
|
||||
}
|
||||
|
||||
//
|
||||
// Check Can Ignore Tick or not ..
|
||||
bool canIgnoreTick = xTESTIsTestMode
|
||||
bool canIgnoreTick = xGPUS5IsTestMode
|
||||
? !IsNewCandle()
|
||||
: !IsNewCandle() && xTESTWaitUntilNextCandle;
|
||||
: !IsNewCandle() && xGPUS5WaitUntilNextCandle;
|
||||
if (canIgnoreTick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
xTESTWaitUntilNextCandle = false;
|
||||
xGPUS5WaitUntilNextCandle = false;
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xTESTEnableProvider)
|
||||
if (xGPUS5EnableProvider)
|
||||
{
|
||||
//
|
||||
// Handle Processing on XTEST Signal Provider ...
|
||||
XTESTSignalProviderHandleTick();
|
||||
// Handle Processing on XGPUS5 Signal Provider ...
|
||||
XGPUS5SignalProviderHandleTick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,11 +327,11 @@ void OnTrade()
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xTESTEnableProvider)
|
||||
if (xGPUS5EnableProvider)
|
||||
{
|
||||
//
|
||||
// Handle Processing Trades on XTEST Signal Provider ...
|
||||
XTESTSignalProviderHandleTrade();
|
||||
// Handle Processing Trades on XGPUS5 Signal Provider ...
|
||||
XGPUS5SignalProviderHandleTrade();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,8 +354,8 @@ bool ValidateInputs()
|
||||
// Validate Args ...
|
||||
|
||||
//
|
||||
// Validate XTEST Provider Inputs ...
|
||||
result = XTESTValidateInputs();
|
||||
// Validate XGPUS5 Provider Inputs ...
|
||||
result = XGPUS5ValidateInputs();
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
@@ -370,23 +370,23 @@ bool ValidateInputs()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool XTESTCTimerInit()
|
||||
bool XGPUS5CTimerInit()
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
xTESTCTimerHandler = iCustom(
|
||||
xGPUS5CTimerHandler = iCustom(
|
||||
_Symbol,
|
||||
_Period,
|
||||
"x-saherelm.xctimer.indicator",
|
||||
//
|
||||
// Inputs ...
|
||||
xTESTCandleTimerColot,
|
||||
xTESTCandleTimerCorner);
|
||||
xGPUS5CandleTimerColot,
|
||||
xGPUS5CandleTimerCorner);
|
||||
|
||||
//
|
||||
if (xTESTCTimerHandler == INVALID_HANDLE)
|
||||
if (xGPUS5CTimerHandler == INVALID_HANDLE)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
+428
-428
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,283 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XGPUS5 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 "XGPUS5 Provider";
|
||||
|
||||
//
|
||||
// Commonly Used Configurations ...
|
||||
input group "XGPUS5 Common";
|
||||
//
|
||||
// Provider ...
|
||||
input bool xGPUS5EnableProvider = true; // Enable Provider
|
||||
input int xGPUS5NumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
|
||||
//
|
||||
// Alerts ...
|
||||
input bool xGPUS5EnableAlerts = true; // Enable Events Alert
|
||||
input bool xGPUS5EnableHourlyAlerts = false; // Send Alert on each new Hour
|
||||
input bool xGPUS5EnableDailyAlerts = false; // Send Alert on each new Day
|
||||
input bool xGPUS5EnableWeeklyAlerts = false; // Send Alert on each new Week
|
||||
input bool xGPUS5EnableMonthlyAlerts = false; // Send Alert on each new Month
|
||||
//
|
||||
// Reports ...
|
||||
input bool xGPUS5EnableDailyReports = false; // Send Report on each new Day
|
||||
input bool xGPUS5EnableWeeklyReports = false; // Send Report on each new Week
|
||||
input bool xGPUS5EnableMonthlyReports = false; // Send Report on each new Month
|
||||
|
||||
//
|
||||
// Trader and Expert Specific Configurations ...
|
||||
input group "XGPUS5 Trader";
|
||||
input int xGPUS5MagicNumber = 16940563; // Trader MagicNumber
|
||||
input int xGPUS5Slippage = 10; // Trader Slippage
|
||||
|
||||
//
|
||||
// Trades Management Configurations ...
|
||||
input group "XGPUS5 Trade Management";
|
||||
input bool xGPUS5AllowLongTrades = true; // Allow Long Trades
|
||||
input bool xGPUS5AllowShortTrades = true; // Allow Short Trades
|
||||
|
||||
//
|
||||
// Risk Management Configurations ...
|
||||
input group "XGPUS5 Risk Management";
|
||||
//
|
||||
// Trade Count ...
|
||||
input int xGPUS5MaxAllowedTrades = 10; // Max Allowed Trades at Same Time
|
||||
input ENUM_X_CROSS_SIGNAL_METHOD xGPUS5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
|
||||
//
|
||||
// Max Allowed Trade Age ...
|
||||
input int xGPUS5MaxAllowedTradeAge = 300; // Detect Long Time Trades
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5OldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
|
||||
//
|
||||
// Trade Volume Specific Configurations ...
|
||||
input double xGPUS5StaticVolumeFactor = 0.0004; // Static Volume baesd on Balance
|
||||
input ENUM_STATIC_VOLUME_METHODS xGPUS5StaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
|
||||
input double xGPUS5VolumeMultiplier = 0; // Volume Increase Multiplier
|
||||
input double xGPUS5ApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
|
||||
input double xGPUS5MaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance
|
||||
input double xGPUS5IncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
|
||||
//
|
||||
// Trade Profits ...
|
||||
input double xGPUS5MinRewardInPips = 60; // Minimum Reward Per Trade in Pips
|
||||
input double xGPUS5RiskFreeStepInPips = 0; // Make Trades Risk Free Steps in Pips
|
||||
input double xGPUS5RiskFreeRate = 0; // Volume Multiplier for Risk Free Trades
|
||||
//
|
||||
// Guard Riskable Money and Profits ...
|
||||
input double xGPUS5CriticalDrawDownFactor = 0.10; // Critical Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // Specify Guard Action on Critical Drawdown
|
||||
input double xGPUS5MaxAllowedDrawDownFactor = 0.15; // Max Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Max Allowed Drawdown
|
||||
input int xGPUS5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
|
||||
|
||||
//
|
||||
// Account Conditions for Trading ...
|
||||
input double xGPUS5BalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
|
||||
input double xGPUS5FreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
|
||||
|
||||
//
|
||||
// May be Used Later as Input Params ...
|
||||
bool xGPUS5UseVirtualTPSl = false; // Use Virtual TP SL
|
||||
bool xGPUS5EnableSignalAlerts = false; // Send Signal Alert
|
||||
|
||||
//
|
||||
// Validate Inputs before Initialization ...
|
||||
bool XGPUS5ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Implement Other Verifications ...
|
||||
|
||||
//
|
||||
// Check Trading Availability ...
|
||||
bool isTradeAvailable = xGPUS5AllowLongTrades || xGPUS5AllowShortTrades;
|
||||
if (!isTradeAvailable)
|
||||
{
|
||||
LogMessage("XGPUS5 => Warning: Trading disabled ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Chekc Number of reading items per tick ...
|
||||
result = xGPUS5NumberOfItemsPerTick >= 5;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 invalid Number of items Reading Per Tick ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Max Allowed Trades Count ...
|
||||
result = isTradeAvailable && xGPUS5MaxAllowedTrades >= 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Number of Trades not valid ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Free Margin ...
|
||||
result =
|
||||
isTradeAvailable &&
|
||||
xGPUS5FreeMarginFactorForOpenTrades > 0 &&
|
||||
xGPUS5FreeMarginFactorForOpenTrades < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Free Margin ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check min Balance for Open Trades ...
|
||||
result =
|
||||
isTradeAvailable &&
|
||||
xGPUS5BalanceFactorForOpenTrades > 0 &&
|
||||
xGPUS5BalanceFactorForOpenTrades < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Min Balance for Open Trades ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Min Reward Per Trade ...
|
||||
result = xGPUS5MinRewardInPips > 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Min Reward Per Trade ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Trades Volume ...
|
||||
result = xGPUS5StaticVolumeFactor > 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Static Volume ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Volume Multiplier ...
|
||||
result = xGPUS5VolumeMultiplier >= 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Volume Multiplier ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xGPUS5CriticalDrawDownFactor == 0 || (xGPUS5CriticalDrawDownFactor > 0 &&
|
||||
xGPUS5CriticalDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Critical DrawDown Factor ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xGPUS5MaxAllowedDrawDownFactor == 0 || (xGPUS5MaxAllowedDrawDownFactor > 0 &&
|
||||
xGPUS5MaxAllowedDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Max Allowed DrawDown Factor ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Guard Actions ...
|
||||
//
|
||||
result =
|
||||
xGPUS5CriticalDrawDownFactor > 0 &&
|
||||
xGPUS5CriticalDrawDownFactor < 1 &&
|
||||
xGPUS5MaxAllowedDrawDownFactor > 0 &&
|
||||
xGPUS5MaxAllowedDrawDownFactor < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 For Critical Drawdown, you have to Specify Max Drawdown also ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = xGPUS5CriticalDrawDownFactor > 0 && xGPUS5CriticalDrawDownFactor < xGPUS5MaxAllowedDrawDownFactor;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Critical Drawdown must Smaller than Max Drawdown ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (xGPUS5CriticalDrawDownFactor > 0 && xGPUS5CriticalGuardAction == X_GUARD_DO_NOTHING)
|
||||
{
|
||||
LogMessage("XGPUS5 IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (xGPUS5MaxAllowedDrawDownFactor > 0 && xGPUS5MaxAllowedGuardAction == X_GUARD_DO_NOTHING)
|
||||
{
|
||||
LogMessage("XGPUS5 IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ...");
|
||||
}
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
+264
-264
File diff suppressed because it is too large
Load Diff
@@ -1,283 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XTEST 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 "XTEST Provider";
|
||||
|
||||
//
|
||||
// Commonly Used Configurations ...
|
||||
input group "XTEST Common";
|
||||
//
|
||||
// Provider ...
|
||||
input bool xTESTEnableProvider = true; // Enable Provider
|
||||
input int xTESTNumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
|
||||
//
|
||||
// Alerts ...
|
||||
input bool xTESTEnableAlerts = true; // Enable Events Alert
|
||||
input bool xTESTEnableHourlyAlerts = false; // Send Alert on each new Hour
|
||||
input bool xTESTEnableDailyAlerts = false; // Send Alert on each new Day
|
||||
input bool xTESTEnableWeeklyAlerts = false; // Send Alert on each new Week
|
||||
input bool xTESTEnableMonthlyAlerts = false; // Send Alert on each new Month
|
||||
//
|
||||
// Reports ...
|
||||
input bool xTESTEnableDailyReports = false; // Send Report on each new Day
|
||||
input bool xTESTEnableWeeklyReports = false; // Send Report on each new Week
|
||||
input bool xTESTEnableMonthlyReports = false; // Send Report on each new Month
|
||||
|
||||
//
|
||||
// Trader and Expert Specific Configurations ...
|
||||
input group "XTEST Trader";
|
||||
input int xTESTMagicNumber = 16940563; // Trader MagicNumber
|
||||
input int xTESTSlippage = 10; // Trader Slippage
|
||||
|
||||
//
|
||||
// Trades Management Configurations ...
|
||||
input group "XTEST Trade Management";
|
||||
input bool xTESTAllowLongTrades = true; // Allow Long Trades
|
||||
input bool xTESTAllowShortTrades = true; // Allow Short Trades
|
||||
|
||||
//
|
||||
// Risk Management Configurations ...
|
||||
input group "XTEST Risk Management";
|
||||
//
|
||||
// Trade Count ...
|
||||
input int xTESTMaxAllowedTrades = 10; // Max Allowed Trades at Same Time
|
||||
input ENUM_X_CROSS_SIGNAL_METHOD xTESTCrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
|
||||
//
|
||||
// Max Allowed Trade Age ...
|
||||
input int xTESTMaxAllowedTradeAge = 300; // Detect Long Time Trades
|
||||
input ENUM_X_GUARD_ACTIONS xTESTOldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
|
||||
//
|
||||
// Trade Volume Specific Configurations ...
|
||||
input double xTESTStaticVolumeFactor = 0.0004; // Static Volume baesd on Balance
|
||||
input ENUM_STATIC_VOLUME_METHODS xTESTStaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
|
||||
input double xTESTVolumeMultiplier = 0; // Volume Increase Multiplier
|
||||
input double xTESTApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
|
||||
input double xTESTMaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance
|
||||
input double xTESTIncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
|
||||
//
|
||||
// Trade Profits ...
|
||||
input double xTESTMinRewardInPips = 60; // Minimum Reward Per Trade in Pips
|
||||
input double xTESTRiskFreeStepInPips = 0; // Make Trades Risk Free Steps in Pips
|
||||
input double xTESTRiskFreeRate = 0; // Volume Multiplier for Risk Free Trades
|
||||
//
|
||||
// Guard Riskable Money and Profits ...
|
||||
input double xTESTCriticalDrawDownFactor = 0.10; // Critical Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xTESTCriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // Specify Guard Action on Critical Drawdown
|
||||
input double xTESTMaxAllowedDrawDownFactor = 0.15; // Max Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xTESTMaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Max Allowed Drawdown
|
||||
input int xTESTGuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
|
||||
|
||||
//
|
||||
// Account Conditions for Trading ...
|
||||
input double xTESTBalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
|
||||
input double xTESTFreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
|
||||
|
||||
//
|
||||
// May be Used Later as Input Params ...
|
||||
bool xTESTUseVirtualTPSl = false; // Use Virtual TP SL
|
||||
bool xTESTEnableSignalAlerts = false; // Send Signal Alert
|
||||
|
||||
//
|
||||
// Validate Inputs before Initialization ...
|
||||
bool XTESTValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Implement Other Verifications ...
|
||||
|
||||
//
|
||||
// Check Trading Availability ...
|
||||
bool isTradeAvailable = xTESTAllowLongTrades || xTESTAllowShortTrades;
|
||||
if (!isTradeAvailable)
|
||||
{
|
||||
LogMessage("XTEST => Warning: Trading disabled ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Chekc Number of reading items per tick ...
|
||||
result = xTESTNumberOfItemsPerTick >= 5;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST invalid Number of items Reading Per Tick ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Max Allowed Trades Count ...
|
||||
result = isTradeAvailable && xTESTMaxAllowedTrades >= 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Number of Trades not valid ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Free Margin ...
|
||||
result =
|
||||
isTradeAvailable &&
|
||||
xTESTFreeMarginFactorForOpenTrades > 0 &&
|
||||
xTESTFreeMarginFactorForOpenTrades < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Free Margin ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check min Balance for Open Trades ...
|
||||
result =
|
||||
isTradeAvailable &&
|
||||
xTESTBalanceFactorForOpenTrades > 0 &&
|
||||
xTESTBalanceFactorForOpenTrades < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Min Balance for Open Trades ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Min Reward Per Trade ...
|
||||
result = xTESTMinRewardInPips > 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Min Reward Per Trade ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Trades Volume ...
|
||||
result = xTESTStaticVolumeFactor > 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Static Volume ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Volume Multiplier ...
|
||||
result = xTESTVolumeMultiplier >= 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Volume Multiplier ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xTESTCriticalDrawDownFactor == 0 || (xTESTCriticalDrawDownFactor > 0 &&
|
||||
xTESTCriticalDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Critical DrawDown Factor ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xTESTMaxAllowedDrawDownFactor == 0 || (xTESTMaxAllowedDrawDownFactor > 0 &&
|
||||
xTESTMaxAllowedDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Max Allowed DrawDown Factor ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Guard Actions ...
|
||||
//
|
||||
result =
|
||||
xTESTCriticalDrawDownFactor > 0 &&
|
||||
xTESTCriticalDrawDownFactor < 1 &&
|
||||
xTESTMaxAllowedDrawDownFactor > 0 &&
|
||||
xTESTMaxAllowedDrawDownFactor < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST For Critical Drawdown, you have to Specify Max Drawdown also ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = xTESTCriticalDrawDownFactor > 0 && xTESTCriticalDrawDownFactor < xTESTMaxAllowedDrawDownFactor;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Critical Drawdown must Smaller than Max Drawdown ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (xTESTCriticalDrawDownFactor > 0 && xTESTCriticalGuardAction == X_GUARD_DO_NOTHING)
|
||||
{
|
||||
LogMessage("XTEST IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (xTESTMaxAllowedDrawDownFactor > 0 && xTESTMaxAllowedGuardAction == X_GUARD_DO_NOTHING)
|
||||
{
|
||||
LogMessage("XTEST IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ...");
|
||||
}
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// SaherElm IT Center MQL5 Expert Advisor
|
||||
// ----------------------------------------
|
||||
// Name: XTEST
|
||||
// Name: XGPUS5
|
||||
// Description: this is an expert controller
|
||||
// advisors which provides a mechanism for use them ...
|
||||
//
|
||||
@@ -17,7 +17,7 @@
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm XTEST EA"
|
||||
#property description "SaherElm XGPUS5 EA"
|
||||
#property strict
|
||||
|
||||
//
|
||||
@@ -28,9 +28,9 @@ input group "Commons";
|
||||
|
||||
//
|
||||
// XCTIMER inputs ...
|
||||
input bool xTESTShowCandleTimer = true; // Show Condle Remaining Time
|
||||
input color xTESTCandleTimerColot = clrYellow; // Candle Timer Color
|
||||
input ENUM_BASE_CORNER xTESTCandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
|
||||
input bool xGPUS5ShowCandleTimer = true; // Show Condle Remaining Time
|
||||
input color xGPUS5CandleTimerColot = clrYellow; // Candle Timer Color
|
||||
input ENUM_BASE_CORNER xGPUS5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
@@ -57,8 +57,8 @@ input ENUM_BASE_CORNER xTESTCandleTimerCorner = CORNER_RIGHT_LOWER; // Where to
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||
|
||||
//
|
||||
// XTEST Signal Provider ...
|
||||
#include "../Providers/x-saherelm.xtest.provider.lib.mq5"
|
||||
// XGPUS5 Signal Provider ...
|
||||
#include "../Providers/x-saherelm.xgpus5.provider.lib.mq5"
|
||||
|
||||
//
|
||||
// END Including Providers ...
|
||||
@@ -67,13 +67,13 @@ input ENUM_BASE_CORNER xTESTCandleTimerCorner = CORNER_RIGHT_LOWER; // Where to
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
bool isXTESTNewHour;
|
||||
bool isXTESTNewDay;
|
||||
bool isXTESTNewWeek;
|
||||
bool isXTESTNewMonth;
|
||||
bool isXGPUS5NewHour;
|
||||
bool isXGPUS5NewDay;
|
||||
bool isXGPUS5NewWeek;
|
||||
bool isXGPUS5NewMonth;
|
||||
|
||||
//
|
||||
int xTESTCTimerHandler = INVALID_HANDLE;
|
||||
int xGPUS5CTimerHandler = INVALID_HANDLE;
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
@@ -87,7 +87,7 @@ int xTESTCTimerHandler = INVALID_HANDLE;
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
logTag = "XTESTEA";
|
||||
logTag = "XGPUS5EA";
|
||||
drawPrefix = logTag;
|
||||
alertPrefix = logTag;
|
||||
|
||||
@@ -107,17 +107,17 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize XTEST Provider ...
|
||||
if (!XTESTInitSignalProviderLibrary())
|
||||
// Initialize XGPUS5 Provider ...
|
||||
if (!XGPUS5InitSignalProviderLibrary())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Init XCTimer ...
|
||||
if (xTESTShowCandleTimer)
|
||||
if (xGPUS5ShowCandleTimer)
|
||||
{
|
||||
if (!XTESTCTimerInit())
|
||||
if (!XGPUS5CTimerInit())
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
@@ -148,15 +148,15 @@ void OnDeinit(const int reason)
|
||||
// Here we can handle De Initialization Reasons ...
|
||||
|
||||
//
|
||||
// De Initialize XTEST Provider ...
|
||||
XTESTDeinitSignalProviderLibrary(reason);
|
||||
// De Initialize XGPUS5 Provider ...
|
||||
XGPUS5DeinitSignalProviderLibrary(reason);
|
||||
|
||||
//
|
||||
// De Init XDraw Library ...
|
||||
// OnDeinitDrawLibrary();
|
||||
|
||||
//
|
||||
IndicatorRelease(xTESTCTimerHandler);
|
||||
IndicatorRelease(xGPUS5CTimerHandler);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -166,15 +166,15 @@ void OnTick()
|
||||
//
|
||||
// Handle Monthly Alert ...
|
||||
bool isFirstMonth = xMonth == -1;
|
||||
isXTESTNewMonth = IsNewMonth();
|
||||
isXGPUS5NewMonth = IsNewMonth();
|
||||
bool canMonthlyAlert =
|
||||
isXTESTNewMonth &&
|
||||
xTESTEnableAlerts &&
|
||||
xTESTEnableMonthlyAlerts;
|
||||
isXGPUS5NewMonth &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableMonthlyAlerts;
|
||||
bool canMonthlyReport =
|
||||
!isFirstMonth &&
|
||||
canMonthlyAlert &&
|
||||
xTESTEnableMonthlyReports;
|
||||
xGPUS5EnableMonthlyReports;
|
||||
if (canMonthlyAlert)
|
||||
{
|
||||
//
|
||||
@@ -185,7 +185,7 @@ void OnTick()
|
||||
if (canMonthlyReport)
|
||||
{
|
||||
//
|
||||
string report = xTESTReporter.GenerateReportString(XREPORT_MONTHLY);
|
||||
string report = xGPUS5Reporter.GenerateReportString(XREPORT_MONTHLY);
|
||||
|
||||
//
|
||||
message = "Last Month Report:\n" + report;
|
||||
@@ -193,7 +193,7 @@ void OnTick()
|
||||
|
||||
//
|
||||
// Reset Report ...
|
||||
xTESTReporter.Reset(XREPORT_MONTHLY);
|
||||
xGPUS5Reporter.Reset(XREPORT_MONTHLY);
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
@@ -202,15 +202,15 @@ void OnTick()
|
||||
//
|
||||
// Handle Weekly Alert ...
|
||||
bool isFirstWeek = xDayOfWeek == -1;
|
||||
isXTESTNewWeek = IsNewWeek();
|
||||
isXGPUS5NewWeek = IsNewWeek();
|
||||
bool canWeeklyAlert =
|
||||
isXTESTNewWeek &&
|
||||
xTESTEnableAlerts &&
|
||||
xTESTEnableWeeklyAlerts;
|
||||
isXGPUS5NewWeek &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableWeeklyAlerts;
|
||||
bool canWeeklyReport =
|
||||
!isFirstWeek &&
|
||||
canWeeklyAlert &&
|
||||
xTESTEnableWeeklyReports;
|
||||
xGPUS5EnableWeeklyReports;
|
||||
if (canWeeklyAlert)
|
||||
{
|
||||
//
|
||||
@@ -221,7 +221,7 @@ void OnTick()
|
||||
if (canWeeklyReport)
|
||||
{
|
||||
//
|
||||
string report = xTESTReporter.GenerateReportString(XREPORT_WEEKLY);
|
||||
string report = xGPUS5Reporter.GenerateReportString(XREPORT_WEEKLY);
|
||||
|
||||
//
|
||||
message = "Last Week Report:\n" + report;
|
||||
@@ -229,7 +229,7 @@ void OnTick()
|
||||
|
||||
//
|
||||
// Reset Report ...
|
||||
xTESTReporter.Reset(XREPORT_WEEKLY);
|
||||
xGPUS5Reporter.Reset(XREPORT_WEEKLY);
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
@@ -238,15 +238,15 @@ void OnTick()
|
||||
//
|
||||
// Handle Daily Alert ...
|
||||
bool isFirstDay = xDay == -1;
|
||||
isXTESTNewDay = IsNewDay();
|
||||
isXGPUS5NewDay = IsNewDay();
|
||||
bool canDailyAlert =
|
||||
isXTESTNewDay &&
|
||||
xTESTEnableAlerts &&
|
||||
xTESTEnableDailyAlerts;
|
||||
isXGPUS5NewDay &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableDailyAlerts;
|
||||
bool canDailyReport =
|
||||
!isFirstDay &&
|
||||
canDailyAlert &&
|
||||
xTESTEnableDailyReports;
|
||||
xGPUS5EnableDailyReports;
|
||||
if (canDailyAlert)
|
||||
{
|
||||
//
|
||||
@@ -257,7 +257,7 @@ void OnTick()
|
||||
if (canDailyReport)
|
||||
{
|
||||
//
|
||||
string report = xTESTReporter.GenerateReportString(XREPORT_DAILY);
|
||||
string report = xGPUS5Reporter.GenerateReportString(XREPORT_DAILY);
|
||||
|
||||
//
|
||||
message = "Last Week Report:\n" + report;
|
||||
@@ -265,7 +265,7 @@ void OnTick()
|
||||
|
||||
//
|
||||
// Reset Report ...
|
||||
xTESTReporter.Reset(XREPORT_DAILY);
|
||||
xGPUS5Reporter.Reset(XREPORT_DAILY);
|
||||
|
||||
//
|
||||
SendAlert(message);
|
||||
@@ -274,11 +274,11 @@ void OnTick()
|
||||
//
|
||||
// Handle Hourly Alert ...
|
||||
bool isFirstHour = xHour == -1;
|
||||
isXTESTNewHour = IsNewHour();
|
||||
isXGPUS5NewHour = IsNewHour();
|
||||
bool canHourlyAlert =
|
||||
isXTESTNewHour &&
|
||||
xTESTEnableAlerts &&
|
||||
xTESTEnableHourlyAlerts;
|
||||
isXGPUS5NewHour &&
|
||||
xGPUS5EnableAlerts &&
|
||||
xGPUS5EnableHourlyAlerts;
|
||||
if (canHourlyAlert)
|
||||
{
|
||||
//
|
||||
@@ -290,33 +290,33 @@ void OnTick()
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xTESTEnableProvider)
|
||||
if (xGPUS5EnableProvider)
|
||||
{
|
||||
//
|
||||
// Handle Processing on XTEST Signal Provider ...
|
||||
XTESTSignalProviderDoControlState();
|
||||
// Handle Processing on XGPUS5 Signal Provider ...
|
||||
XGPUS5SignalProviderDoControlState();
|
||||
}
|
||||
|
||||
//
|
||||
// Check Can Ignore Tick or not ..
|
||||
bool canIgnoreTick = xTESTIsTestMode
|
||||
bool canIgnoreTick = xGPUS5IsTestMode
|
||||
? !IsNewCandle()
|
||||
: !IsNewCandle() && xTESTWaitUntilNextCandle;
|
||||
: !IsNewCandle() && xGPUS5WaitUntilNextCandle;
|
||||
if (canIgnoreTick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
xTESTWaitUntilNextCandle = false;
|
||||
xGPUS5WaitUntilNextCandle = false;
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xTESTEnableProvider)
|
||||
if (xGPUS5EnableProvider)
|
||||
{
|
||||
//
|
||||
// Handle Processing on XTEST Signal Provider ...
|
||||
XTESTSignalProviderHandleTick();
|
||||
// Handle Processing on XGPUS5 Signal Provider ...
|
||||
XGPUS5SignalProviderHandleTick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,11 +327,11 @@ void OnTrade()
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xTESTEnableProvider)
|
||||
if (xGPUS5EnableProvider)
|
||||
{
|
||||
//
|
||||
// Handle Processing Trades on XTEST Signal Provider ...
|
||||
XTESTSignalProviderHandleTrade();
|
||||
// Handle Processing Trades on XGPUS5 Signal Provider ...
|
||||
XGPUS5SignalProviderHandleTrade();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,8 +354,8 @@ bool ValidateInputs()
|
||||
// Validate Args ...
|
||||
|
||||
//
|
||||
// Validate XTEST Provider Inputs ...
|
||||
result = XTESTValidateInputs();
|
||||
// Validate XGPUS5 Provider Inputs ...
|
||||
result = XGPUS5ValidateInputs();
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
@@ -370,23 +370,23 @@ bool ValidateInputs()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool XTESTCTimerInit()
|
||||
bool XGPUS5CTimerInit()
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
xTESTCTimerHandler = iCustom(
|
||||
xGPUS5CTimerHandler = iCustom(
|
||||
_Symbol,
|
||||
_Period,
|
||||
"x-saherelm.xctimer.indicator",
|
||||
//
|
||||
// Inputs ...
|
||||
xTESTCandleTimerColot,
|
||||
xTESTCandleTimerCorner);
|
||||
xGPUS5CandleTimerColot,
|
||||
xGPUS5CandleTimerCorner);
|
||||
|
||||
//
|
||||
if (xTESTCTimerHandler == INVALID_HANDLE)
|
||||
if (xGPUS5CTimerHandler == INVALID_HANDLE)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
@@ -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 ...
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// SaherElm IT Center MQL5 Expert Advisor
|
||||
// ----------------------------------------
|
||||
// Name: XAUUSD
|
||||
// Name: XGPUS5
|
||||
// Description: this is an expert controller
|
||||
// advisors which provides a mechanism for use them ...
|
||||
//
|
||||
@@ -27,10 +27,16 @@
|
||||
input group "Commons";
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
// XCTIMER inputs ...
|
||||
input bool xGPUS5ShowCandleTimer = true; // Show Condle Remaining Time
|
||||
input color xGPUS5CandleTimerColot = clrYellow; // Candle Timer Color
|
||||
input ENUM_BASE_CORNER xGPUS5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
//
|
||||
// START Including Providers ...
|
||||
//
|
||||
|
||||
@@ -65,6 +71,9 @@ bool isXGPUS5NewHour;
|
||||
bool isXGPUS5NewDay;
|
||||
bool isXGPUS5NewWeek;
|
||||
bool isXGPUS5NewMonth;
|
||||
|
||||
//
|
||||
int xGPUS5CTimerHandler = INVALID_HANDLE;
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
@@ -104,6 +113,16 @@ int OnInit()
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Init XCTimer ...
|
||||
if (xGPUS5ShowCandleTimer)
|
||||
{
|
||||
if (!XGPUS5CTimerInit())
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Init Succeed ...
|
||||
return INIT_SUCCEEDED;
|
||||
@@ -135,6 +154,9 @@ void OnDeinit(const int reason)
|
||||
//
|
||||
// De Init XDraw Library ...
|
||||
// OnDeinitDrawLibrary();
|
||||
|
||||
//
|
||||
IndicatorRelease(xGPUS5CTimerHandler);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -266,7 +288,6 @@ void OnTick()
|
||||
SendAlert(message);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xGPUS5EnableProvider)
|
||||
@@ -277,11 +298,18 @@ void OnTick()
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsNewCandle())
|
||||
// Check Can Ignore Tick or not ..
|
||||
bool canIgnoreTick = xGPUS5IsTestMode
|
||||
? !IsNewCandle()
|
||||
: !IsNewCandle() && xGPUS5WaitUntilNextCandle;
|
||||
if (canIgnoreTick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
xGPUS5WaitUntilNextCandle = false;
|
||||
|
||||
//
|
||||
// Prevent Going Forward if user Disable it ...
|
||||
if (xGPUS5EnableProvider)
|
||||
@@ -342,6 +370,30 @@ bool ValidateInputs()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool XGPUS5CTimerInit()
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
xGPUS5CTimerHandler = iCustom(
|
||||
_Symbol,
|
||||
_Period,
|
||||
"x-saherelm.xctimer.indicator",
|
||||
//
|
||||
// Inputs ...
|
||||
xGPUS5CandleTimerColot,
|
||||
xGPUS5CandleTimerCorner);
|
||||
|
||||
//
|
||||
if (xGPUS5CTimerHandler == INVALID_HANDLE)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XCTimer Indicator
|
||||
// ---------------------------------------------
|
||||
// Name: XCTimer
|
||||
// Description: Trend Magic Indicator ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm XCTimer Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
#define ShortName "XCTimer"
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
input color clr = clrYellow;
|
||||
input ENUM_BASE_CORNER corner = CORNER_RIGHT_LOWER;
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
//
|
||||
// END Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
CreateIndicatorObject();
|
||||
|
||||
//
|
||||
// Set Indicator ShortName ...
|
||||
SetIndicatorName();
|
||||
|
||||
//
|
||||
// Init Succeed ...
|
||||
return INIT_SUCCEEDED;
|
||||
}
|
||||
|
||||
//
|
||||
// DeInitialization ...
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
//
|
||||
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
||||
// REASON_REMOVE 1 Program removed from a chart
|
||||
// REASON_RECOMPILE 2 Program recompiled
|
||||
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
|
||||
// REASON_CHARTCLOSE 4 Chart closed
|
||||
// REASON_PARAMETERS 5 Inputs changed by a user
|
||||
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
|
||||
// REASON_TEMPLATE 7 Another chart template applied
|
||||
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
||||
// REASON_CLOSE 9 Terminal closed
|
||||
|
||||
//
|
||||
// Delete Object ...
|
||||
ObjectDelete(0, ShortName);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculations ...
|
||||
//
|
||||
// Calculating what we want ...
|
||||
int OnCalculate(
|
||||
//
|
||||
// total Candles on chart ...
|
||||
const int rates_total,
|
||||
//
|
||||
// total calculated Candles on charts ...
|
||||
const int prev_calculated,
|
||||
//
|
||||
// history of Candles Open Time ...
|
||||
const datetime &time[],
|
||||
//
|
||||
// history of Candles Open Price ...
|
||||
const double &open[],
|
||||
//
|
||||
// history of Candles High Price ...
|
||||
const double &high[],
|
||||
//
|
||||
// history of Candles Low Price ...
|
||||
const double &low[],
|
||||
//
|
||||
// history of Candles Close Price ...
|
||||
const double &close[],
|
||||
//
|
||||
// history of Tick Volumes on Candle ...
|
||||
const long &tick_volume[],
|
||||
//
|
||||
// history of Trade Volumes ...
|
||||
const long &volume[],
|
||||
//
|
||||
// history of Candles Spread Price ...
|
||||
const int &spread[])
|
||||
{
|
||||
//
|
||||
ArraySetAsSeries(time, true);
|
||||
|
||||
//
|
||||
int m = int(time[0] + PeriodSeconds() - TimeCurrent());
|
||||
int s = m % 60;
|
||||
m = (m - s) / 60;
|
||||
|
||||
//
|
||||
long mSpread = SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
|
||||
|
||||
string _sp = "", _m = "", _s = "";
|
||||
if (mSpread < 10)
|
||||
_sp = "..";
|
||||
else if (mSpread < 100)
|
||||
_sp = ".";
|
||||
if (m < 10)
|
||||
_m = "0";
|
||||
if (s < 10)
|
||||
_s = "0";
|
||||
|
||||
//
|
||||
string objText = "Spread: " + IntegerToString(mSpread) + _sp + " Next Bar in " + _m + IntegerToString(m) + ":" + _s + IntegerToString(s);
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, ShortName, OBJPROP_COLOR, clr);
|
||||
ObjectSetString(0, ShortName, OBJPROP_TEXT, objText);
|
||||
ObjectSetInteger(0, ShortName, OBJPROP_FONTSIZE, 10);
|
||||
ObjectSetString(0, ShortName, OBJPROP_FONT, "Courier");
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
//
|
||||
// END Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||
}
|
||||
|
||||
void CreateIndicatorObject()
|
||||
{
|
||||
//
|
||||
ObjectCreate(0, ShortName, OBJ_LABEL, 0, 0, 0);
|
||||
ObjectSetInteger(0, ShortName, OBJPROP_CORNER, corner);
|
||||
ObjectSetInteger(0, ShortName, OBJPROP_XDISTANCE, 10);
|
||||
ObjectSetInteger(0, ShortName, 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, ShortName, OBJPROP_ANCHOR, Anchor);
|
||||
}
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
@@ -36,21 +36,21 @@ input bool xGPUS5EnableProvider = true; // Enable Provider
|
||||
input int xGPUS5NumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
|
||||
//
|
||||
// Alerts ...
|
||||
input bool xGPUS5EnableAlerts = true; // Enable Events Alert
|
||||
input bool xGPUS5EnableHourlyAlerts = false; // Send Alert on each new Hour
|
||||
input bool xGPUS5EnableDailyAlerts = false; // Send Alert on each new Day
|
||||
input bool xGPUS5EnableWeeklyAlerts = false; // Send Alert on each new Week
|
||||
input bool xGPUS5EnableMonthlyAlerts = true; // Send Alert on each new Month
|
||||
input bool xGPUS5EnableAlerts = true; // Enable Events Alert
|
||||
input bool xGPUS5EnableHourlyAlerts = false; // Send Alert on each new Hour
|
||||
input bool xGPUS5EnableDailyAlerts = false; // Send Alert on each new Day
|
||||
input bool xGPUS5EnableWeeklyAlerts = false; // Send Alert on each new Week
|
||||
input bool xGPUS5EnableMonthlyAlerts = false; // Send Alert on each new Month
|
||||
//
|
||||
// Reports ...
|
||||
input bool xGPUS5EnableDailyReports = false; // Send Report on each new Day
|
||||
input bool xGPUS5EnableWeeklyReports = false; // Send Report on each new Week
|
||||
input bool xGPUS5EnableMonthlyReports = true; // Send Report on each new Month
|
||||
input bool xGPUS5EnableDailyReports = false; // Send Report on each new Day
|
||||
input bool xGPUS5EnableWeeklyReports = false; // Send Report on each new Week
|
||||
input bool xGPUS5EnableMonthlyReports = false; // Send Report on each new Month
|
||||
|
||||
//
|
||||
// Trader and Expert Specific Configurations ...
|
||||
input group "XGPUS5 Trader";
|
||||
input int xGPUS5MagicNumber = 16940561; // Trader MagicNumber
|
||||
input int xGPUS5MagicNumber = 16940563; // Trader MagicNumber
|
||||
input int xGPUS5Slippage = 10; // Trader Slippage
|
||||
|
||||
//
|
||||
@@ -63,18 +63,16 @@ input bool xGPUS5AllowShortTrades = true; // Allow Short Trades
|
||||
// Risk Management Configurations ...
|
||||
input group "XGPUS5 Risk Management";
|
||||
//
|
||||
input bool xGPUS5UseVirtualTPSl = false; // Use Virtual TP SL
|
||||
//
|
||||
// Trade Count ...
|
||||
input int xGPUS5MaxAllowedTrades = 10; // Max Allowed Trades at Same Time
|
||||
input ENUM_X_CROSS_SIGNAL_METHOD xGPUS5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
|
||||
//
|
||||
// Max Allowed Trade Age ...
|
||||
input int xGPUS5MaxAllowedTradeAge = 2000; // Detect Long Time Trades
|
||||
input int xGPUS5MaxAllowedTradeAge = 300; // Detect Long Time Trades
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5OldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
|
||||
//
|
||||
// Trade Volume Specific Configurations ...
|
||||
input double xGPUS5StaticVolumeFactor = 0.0002; // Static Volume baesd on Balance
|
||||
input double xGPUS5StaticVolumeFactor = 0.0004; // Static Volume baesd on Balance
|
||||
input ENUM_STATIC_VOLUME_METHODS xGPUS5StaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
|
||||
input double xGPUS5VolumeMultiplier = 0; // Volume Increase Multiplier
|
||||
input double xGPUS5ApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
|
||||
@@ -82,22 +80,27 @@ input double xGPUS5MaxSupportedVolumePerTradeFactor = 0;
|
||||
input double xGPUS5IncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
|
||||
//
|
||||
// Trade Profits ...
|
||||
input double xGPUS5MinRewardInPips = 150; // Minimum Reward Per Trade in Pips
|
||||
input double xGPUS5RiskFreeStepInPips = 60; // Make Trades Risk Free Steps in Pips
|
||||
input double xGPUS5RiskFreeRate = 0.6; // Volume Multiplier for Risk Free Trades
|
||||
input double xGPUS5MinRewardInPips = 60; // Minimum Reward Per Trade in Pips
|
||||
input double xGPUS5RiskFreeStepInPips = 0; // Make Trades Risk Free Steps in Pips
|
||||
input double xGPUS5RiskFreeRate = 0; // Volume Multiplier for Risk Free Trades
|
||||
//
|
||||
// Guard Riskable Money and Profits ...
|
||||
input double xGPUS5CriticalDrawDownFactor = 0.43; // Critical Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Critical Drawdown
|
||||
input double xGPUS5MaxAllowedDrawDownFactor = 0.45; // Max Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_10; // Specify Guard Action on Max Allowed Drawdown
|
||||
input int xGPUS5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
|
||||
input double xGPUS5CriticalDrawDownFactor = 0.10; // Critical Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // Specify Guard Action on Critical Drawdown
|
||||
input double xGPUS5MaxAllowedDrawDownFactor = 0.15; // Max Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Max Allowed Drawdown
|
||||
input int xGPUS5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
|
||||
|
||||
//
|
||||
// Account Conditions for Trading ...
|
||||
input double xGPUS5BalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
|
||||
input double xGPUS5FreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
|
||||
|
||||
//
|
||||
// May be Used Later as Input Params ...
|
||||
bool xGPUS5UseVirtualTPSl = false; // Use Virtual TP SL
|
||||
bool xGPUS5EnableSignalAlerts = false; // Send Signal Alert
|
||||
|
||||
//
|
||||
// Validate Inputs before Initialization ...
|
||||
bool XGPUS5ValidateInputs()
|
||||
@@ -209,7 +212,7 @@ bool XGPUS5ValidateInputs()
|
||||
//
|
||||
result =
|
||||
xGPUS5CriticalDrawDownFactor == 0 || (xGPUS5CriticalDrawDownFactor > 0 &&
|
||||
xGPUS5CriticalDrawDownFactor < 1);
|
||||
xGPUS5CriticalDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
@@ -222,7 +225,7 @@ bool XGPUS5ValidateInputs()
|
||||
//
|
||||
result =
|
||||
xGPUS5MaxAllowedDrawDownFactor == 0 || (xGPUS5MaxAllowedDrawDownFactor > 0 &&
|
||||
xGPUS5MaxAllowedDrawDownFactor < 1);
|
||||
xGPUS5MaxAllowedDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
|
||||
@@ -513,6 +513,9 @@ void XGPUS5HandleOpenTrades()
|
||||
// Update Reports ...
|
||||
XGPUS5UpdateReports();
|
||||
|
||||
//
|
||||
xGPUS5WaitUntilNextCandle = true;
|
||||
|
||||
//
|
||||
// Open Long Trades ...
|
||||
if (
|
||||
|
||||
+428
-428
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,283 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XGPUS5 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 "XGPUS5 Provider";
|
||||
|
||||
//
|
||||
// Commonly Used Configurations ...
|
||||
input group "XGPUS5 Common";
|
||||
//
|
||||
// Provider ...
|
||||
input bool xGPUS5EnableProvider = true; // Enable Provider
|
||||
input int xGPUS5NumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
|
||||
//
|
||||
// Alerts ...
|
||||
input bool xGPUS5EnableAlerts = true; // Enable Events Alert
|
||||
input bool xGPUS5EnableHourlyAlerts = false; // Send Alert on each new Hour
|
||||
input bool xGPUS5EnableDailyAlerts = false; // Send Alert on each new Day
|
||||
input bool xGPUS5EnableWeeklyAlerts = false; // Send Alert on each new Week
|
||||
input bool xGPUS5EnableMonthlyAlerts = false; // Send Alert on each new Month
|
||||
//
|
||||
// Reports ...
|
||||
input bool xGPUS5EnableDailyReports = false; // Send Report on each new Day
|
||||
input bool xGPUS5EnableWeeklyReports = false; // Send Report on each new Week
|
||||
input bool xGPUS5EnableMonthlyReports = false; // Send Report on each new Month
|
||||
|
||||
//
|
||||
// Trader and Expert Specific Configurations ...
|
||||
input group "XGPUS5 Trader";
|
||||
input int xGPUS5MagicNumber = 16940563; // Trader MagicNumber
|
||||
input int xGPUS5Slippage = 10; // Trader Slippage
|
||||
|
||||
//
|
||||
// Trades Management Configurations ...
|
||||
input group "XGPUS5 Trade Management";
|
||||
input bool xGPUS5AllowLongTrades = true; // Allow Long Trades
|
||||
input bool xGPUS5AllowShortTrades = true; // Allow Short Trades
|
||||
|
||||
//
|
||||
// Risk Management Configurations ...
|
||||
input group "XGPUS5 Risk Management";
|
||||
//
|
||||
// Trade Count ...
|
||||
input int xGPUS5MaxAllowedTrades = 10; // Max Allowed Trades at Same Time
|
||||
input ENUM_X_CROSS_SIGNAL_METHOD xGPUS5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
|
||||
//
|
||||
// Max Allowed Trade Age ...
|
||||
input int xGPUS5MaxAllowedTradeAge = 300; // Detect Long Time Trades
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5OldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
|
||||
//
|
||||
// Trade Volume Specific Configurations ...
|
||||
input double xGPUS5StaticVolumeFactor = 0.0004; // Static Volume baesd on Balance
|
||||
input ENUM_STATIC_VOLUME_METHODS xGPUS5StaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
|
||||
input double xGPUS5VolumeMultiplier = 0; // Volume Increase Multiplier
|
||||
input double xGPUS5ApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
|
||||
input double xGPUS5MaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance
|
||||
input double xGPUS5IncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
|
||||
//
|
||||
// Trade Profits ...
|
||||
input double xGPUS5MinRewardInPips = 60; // Minimum Reward Per Trade in Pips
|
||||
input double xGPUS5RiskFreeStepInPips = 0; // Make Trades Risk Free Steps in Pips
|
||||
input double xGPUS5RiskFreeRate = 0; // Volume Multiplier for Risk Free Trades
|
||||
//
|
||||
// Guard Riskable Money and Profits ...
|
||||
input double xGPUS5CriticalDrawDownFactor = 0.10; // Critical Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // Specify Guard Action on Critical Drawdown
|
||||
input double xGPUS5MaxAllowedDrawDownFactor = 0.15; // Max Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xGPUS5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Max Allowed Drawdown
|
||||
input int xGPUS5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
|
||||
|
||||
//
|
||||
// Account Conditions for Trading ...
|
||||
input double xGPUS5BalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
|
||||
input double xGPUS5FreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
|
||||
|
||||
//
|
||||
// May be Used Later as Input Params ...
|
||||
bool xGPUS5UseVirtualTPSl = false; // Use Virtual TP SL
|
||||
bool xGPUS5EnableSignalAlerts = false; // Send Signal Alert
|
||||
|
||||
//
|
||||
// Validate Inputs before Initialization ...
|
||||
bool XGPUS5ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Implement Other Verifications ...
|
||||
|
||||
//
|
||||
// Check Trading Availability ...
|
||||
bool isTradeAvailable = xGPUS5AllowLongTrades || xGPUS5AllowShortTrades;
|
||||
if (!isTradeAvailable)
|
||||
{
|
||||
LogMessage("XGPUS5 => Warning: Trading disabled ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Chekc Number of reading items per tick ...
|
||||
result = xGPUS5NumberOfItemsPerTick >= 5;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 invalid Number of items Reading Per Tick ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Max Allowed Trades Count ...
|
||||
result = isTradeAvailable && xGPUS5MaxAllowedTrades >= 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Number of Trades not valid ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Free Margin ...
|
||||
result =
|
||||
isTradeAvailable &&
|
||||
xGPUS5FreeMarginFactorForOpenTrades > 0 &&
|
||||
xGPUS5FreeMarginFactorForOpenTrades < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Free Margin ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check min Balance for Open Trades ...
|
||||
result =
|
||||
isTradeAvailable &&
|
||||
xGPUS5BalanceFactorForOpenTrades > 0 &&
|
||||
xGPUS5BalanceFactorForOpenTrades < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Min Balance for Open Trades ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Min Reward Per Trade ...
|
||||
result = xGPUS5MinRewardInPips > 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Min Reward Per Trade ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Trades Volume ...
|
||||
result = xGPUS5StaticVolumeFactor > 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Static Volume ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Volume Multiplier ...
|
||||
result = xGPUS5VolumeMultiplier >= 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Volume Multiplier ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xGPUS5CriticalDrawDownFactor == 0 || (xGPUS5CriticalDrawDownFactor > 0 &&
|
||||
xGPUS5CriticalDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Critical DrawDown Factor ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xGPUS5MaxAllowedDrawDownFactor == 0 || (xGPUS5MaxAllowedDrawDownFactor > 0 &&
|
||||
xGPUS5MaxAllowedDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Invalid Max Allowed DrawDown Factor ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Guard Actions ...
|
||||
//
|
||||
result =
|
||||
xGPUS5CriticalDrawDownFactor > 0 &&
|
||||
xGPUS5CriticalDrawDownFactor < 1 &&
|
||||
xGPUS5MaxAllowedDrawDownFactor > 0 &&
|
||||
xGPUS5MaxAllowedDrawDownFactor < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 For Critical Drawdown, you have to Specify Max Drawdown also ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = xGPUS5CriticalDrawDownFactor > 0 && xGPUS5CriticalDrawDownFactor < xGPUS5MaxAllowedDrawDownFactor;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XGPUS5 Critical Drawdown must Smaller than Max Drawdown ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (xGPUS5CriticalDrawDownFactor > 0 && xGPUS5CriticalGuardAction == X_GUARD_DO_NOTHING)
|
||||
{
|
||||
LogMessage("XGPUS5 IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (xGPUS5MaxAllowedDrawDownFactor > 0 && xGPUS5MaxAllowedGuardAction == X_GUARD_DO_NOTHING)
|
||||
{
|
||||
LogMessage("XGPUS5 IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ...");
|
||||
}
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
+264
-264
File diff suppressed because it is too large
Load Diff
@@ -1,283 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XTEST 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 "XTEST Provider";
|
||||
|
||||
//
|
||||
// Commonly Used Configurations ...
|
||||
input group "XTEST Common";
|
||||
//
|
||||
// Provider ...
|
||||
input bool xTESTEnableProvider = true; // Enable Provider
|
||||
input int xTESTNumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick
|
||||
//
|
||||
// Alerts ...
|
||||
input bool xTESTEnableAlerts = true; // Enable Events Alert
|
||||
input bool xTESTEnableHourlyAlerts = false; // Send Alert on each new Hour
|
||||
input bool xTESTEnableDailyAlerts = false; // Send Alert on each new Day
|
||||
input bool xTESTEnableWeeklyAlerts = false; // Send Alert on each new Week
|
||||
input bool xTESTEnableMonthlyAlerts = false; // Send Alert on each new Month
|
||||
//
|
||||
// Reports ...
|
||||
input bool xTESTEnableDailyReports = false; // Send Report on each new Day
|
||||
input bool xTESTEnableWeeklyReports = false; // Send Report on each new Week
|
||||
input bool xTESTEnableMonthlyReports = false; // Send Report on each new Month
|
||||
|
||||
//
|
||||
// Trader and Expert Specific Configurations ...
|
||||
input group "XTEST Trader";
|
||||
input int xTESTMagicNumber = 16940563; // Trader MagicNumber
|
||||
input int xTESTSlippage = 10; // Trader Slippage
|
||||
|
||||
//
|
||||
// Trades Management Configurations ...
|
||||
input group "XTEST Trade Management";
|
||||
input bool xTESTAllowLongTrades = true; // Allow Long Trades
|
||||
input bool xTESTAllowShortTrades = true; // Allow Short Trades
|
||||
|
||||
//
|
||||
// Risk Management Configurations ...
|
||||
input group "XTEST Risk Management";
|
||||
//
|
||||
// Trade Count ...
|
||||
input int xTESTMaxAllowedTrades = 10; // Max Allowed Trades at Same Time
|
||||
input ENUM_X_CROSS_SIGNAL_METHOD xTESTCrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method
|
||||
//
|
||||
// Max Allowed Trade Age ...
|
||||
input int xTESTMaxAllowedTradeAge = 300; // Detect Long Time Trades
|
||||
input ENUM_X_GUARD_ACTIONS xTESTOldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades
|
||||
//
|
||||
// Trade Volume Specific Configurations ...
|
||||
input double xTESTStaticVolumeFactor = 0.0004; // Static Volume baesd on Balance
|
||||
input ENUM_STATIC_VOLUME_METHODS xTESTStaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume
|
||||
input double xTESTVolumeMultiplier = 0; // Volume Increase Multiplier
|
||||
input double xTESTApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance
|
||||
input double xTESTMaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance
|
||||
input double xTESTIncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance
|
||||
//
|
||||
// Trade Profits ...
|
||||
input double xTESTMinRewardInPips = 60; // Minimum Reward Per Trade in Pips
|
||||
input double xTESTRiskFreeStepInPips = 0; // Make Trades Risk Free Steps in Pips
|
||||
input double xTESTRiskFreeRate = 0; // Volume Multiplier for Risk Free Trades
|
||||
//
|
||||
// Guard Riskable Money and Profits ...
|
||||
input double xTESTCriticalDrawDownFactor = 0.10; // Critical Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xTESTCriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // Specify Guard Action on Critical Drawdown
|
||||
input double xTESTMaxAllowedDrawDownFactor = 0.15; // Max Allowed Drawdown Factor based on Balance
|
||||
input ENUM_X_GUARD_ACTIONS xTESTMaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Max Allowed Drawdown
|
||||
input int xTESTGuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched
|
||||
|
||||
//
|
||||
// Account Conditions for Trading ...
|
||||
input double xTESTBalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades
|
||||
input double xTESTFreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades
|
||||
|
||||
//
|
||||
// May be Used Later as Input Params ...
|
||||
bool xTESTUseVirtualTPSl = false; // Use Virtual TP SL
|
||||
bool xTESTEnableSignalAlerts = false; // Send Signal Alert
|
||||
|
||||
//
|
||||
// Validate Inputs before Initialization ...
|
||||
bool XTESTValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Implement Other Verifications ...
|
||||
|
||||
//
|
||||
// Check Trading Availability ...
|
||||
bool isTradeAvailable = xTESTAllowLongTrades || xTESTAllowShortTrades;
|
||||
if (!isTradeAvailable)
|
||||
{
|
||||
LogMessage("XTEST => Warning: Trading disabled ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Chekc Number of reading items per tick ...
|
||||
result = xTESTNumberOfItemsPerTick >= 5;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST invalid Number of items Reading Per Tick ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Max Allowed Trades Count ...
|
||||
result = isTradeAvailable && xTESTMaxAllowedTrades >= 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Number of Trades not valid ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Free Margin ...
|
||||
result =
|
||||
isTradeAvailable &&
|
||||
xTESTFreeMarginFactorForOpenTrades > 0 &&
|
||||
xTESTFreeMarginFactorForOpenTrades < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Free Margin ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check min Balance for Open Trades ...
|
||||
result =
|
||||
isTradeAvailable &&
|
||||
xTESTBalanceFactorForOpenTrades > 0 &&
|
||||
xTESTBalanceFactorForOpenTrades < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Min Balance for Open Trades ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Min Reward Per Trade ...
|
||||
result = xTESTMinRewardInPips > 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Min Reward Per Trade ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Trades Volume ...
|
||||
result = xTESTStaticVolumeFactor > 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Static Volume ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Volume Multiplier ...
|
||||
result = xTESTVolumeMultiplier >= 0;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Volume Multiplier ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xTESTCriticalDrawDownFactor == 0 || (xTESTCriticalDrawDownFactor > 0 &&
|
||||
xTESTCriticalDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Critical DrawDown Factor ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xTESTMaxAllowedDrawDownFactor == 0 || (xTESTMaxAllowedDrawDownFactor > 0 &&
|
||||
xTESTMaxAllowedDrawDownFactor < 1);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Invalid Max Allowed DrawDown Factor ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Guard Actions ...
|
||||
//
|
||||
result =
|
||||
xTESTCriticalDrawDownFactor > 0 &&
|
||||
xTESTCriticalDrawDownFactor < 1 &&
|
||||
xTESTMaxAllowedDrawDownFactor > 0 &&
|
||||
xTESTMaxAllowedDrawDownFactor < 1;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST For Critical Drawdown, you have to Specify Max Drawdown also ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = xTESTCriticalDrawDownFactor > 0 && xTESTCriticalDrawDownFactor < xTESTMaxAllowedDrawDownFactor;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTEST Critical Drawdown must Smaller than Max Drawdown ...");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (xTESTCriticalDrawDownFactor > 0 && xTESTCriticalGuardAction == X_GUARD_DO_NOTHING)
|
||||
{
|
||||
LogMessage("XTEST IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (xTESTMaxAllowedDrawDownFactor > 0 && xTESTMaxAllowedGuardAction == X_GUARD_DO_NOTHING)
|
||||
{
|
||||
LogMessage("XTEST IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ...");
|
||||
}
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user