last ...
This commit is contained in:
@@ -285,6 +285,27 @@ class XCTradeManager : public XCBase
|
|||||||
? iParts[5]
|
? iParts[5]
|
||||||
: "";
|
: "";
|
||||||
iRestrictionsDescriptor = EscapeString(iRestrictionsDescriptor);
|
iRestrictionsDescriptor = EscapeString(iRestrictionsDescriptor);
|
||||||
|
|
||||||
|
//
|
||||||
|
XSymbolTradeConfig iConfig;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Config ...
|
||||||
|
has = iConfig.Init(
|
||||||
|
iSymbol,
|
||||||
|
iPeriod,
|
||||||
|
iSessionsDescriptor,
|
||||||
|
iMaxAllowedSpread,
|
||||||
|
iMaxAllowedPositions,
|
||||||
|
iRestrictionsDescriptor //
|
||||||
|
);
|
||||||
|
if (has) {
|
||||||
|
AddOrUpdateSymbolConfiguration(iConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
iConfig.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -37,26 +37,33 @@ input string eaLogSuffix = ""; // Log Suffix
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Symbols
|
// Symbols
|
||||||
// [Symbol|period|(ST_04:00_08:30),(TL_10:30_12:00),(NY_16:00_20:00)]
|
// [
|
||||||
input string eaSymbolConfiguration; // Symbol Configurations
|
// Symbol|
|
||||||
|
// period|
|
||||||
|
// (ST_04:00_08:30),(TL_10:30_12:00),(NY_16:00_20:00)|
|
||||||
|
// maxAllowedSpread|
|
||||||
|
// maxAllowedPosition|
|
||||||
|
// (
|
||||||
|
// restrictionsPeriod,
|
||||||
|
// maxAllowedTPs,
|
||||||
|
// maxAllowedSLs,
|
||||||
|
// maxAllowedTrades,
|
||||||
|
// closeAllOpenTradesAt
|
||||||
|
// )
|
||||||
|
// ]
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// [XAUUSDb|M5|(ST_04:00_08:30),(TL_10:30_12:00),(NY_16:00_20:00)|25.0|5|(Per_Day,0,2,0)]
|
||||||
|
input string eaSymbolConfiguration = "[XAUUSDb|M5|(ST_04:00_08:30),(TL_10:30_12:00),(NY_16:00_20:00)|25.0|5|(XTRADE_RESTRICATION_DAILY,0,2,0)]"; // Symbol Configurations
|
||||||
|
|
||||||
//
|
//
|
||||||
// Management ...
|
// Management ...
|
||||||
// eaSessions => (ST_04:00_08:30),(TL_10:30_12:00),(NY_16:00_20:00)
|
|
||||||
input group "Management";
|
input group "Management";
|
||||||
input bool eaAllowGuards = false; // Allow Guards
|
input bool eaAllowGuards = false; // Allow Guards
|
||||||
input bool eaAllowTrade = true; // Allow Trade on Signals
|
input bool eaAllowTrade = true; // Allow Trade on Signals
|
||||||
input bool eaAllowLongs = true; // Allow Long Trades
|
input bool eaAllowLongs = true; // Allow Long Trades
|
||||||
input bool eaAllowShorts = true; // Allow Short Trades
|
input bool eaAllowShorts = true; // Allow Short Trades
|
||||||
input string eaSessions = ""; // Active Sessions
|
input double eaMaxAllowedDrawdownFactor = 0.3; // Max Allowed DrawDown for Trade
|
||||||
input ENUM_XTRADE_RESTRICTION_PERIOD eaRestrictionsPeriod = XTRADE_RESTRICATION_NONE; // Restrictions Period
|
|
||||||
input int eaMaxAllowedTPs = 0; // Max Allowed TP(s) in Restrictions Period
|
|
||||||
input int eaMaxAllowedSLs = 0; // Max Allowed SL(s) in Restrictions Period
|
|
||||||
input int eaMaxAllowedTrades = 0; // Max Allowed Trades in Restrictions Period
|
|
||||||
input int eaMaxAllowedPositions = 5; // Max Allowed Same Time Trades
|
|
||||||
input double eaMaxAllowedSpread = 25; // Max Allowed Spread For Trade
|
|
||||||
input double eaMaxAllowedDrawdownFactor = 0.3; // Max Allowed DrawDown for Trade
|
|
||||||
input string eaCloseAllOpenTradesAt = ""; // Close All Open Trades per Day At Specified Time
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Volume ...
|
// Volume ...
|
||||||
@@ -155,15 +162,7 @@ int OnInit()
|
|||||||
eaExpert.eaAllowTrade = eaAllowTrade;
|
eaExpert.eaAllowTrade = eaAllowTrade;
|
||||||
eaExpert.eaAllowLongs = eaAllowLongs;
|
eaExpert.eaAllowLongs = eaAllowLongs;
|
||||||
eaExpert.eaAllowShorts = eaAllowShorts;
|
eaExpert.eaAllowShorts = eaAllowShorts;
|
||||||
eaExpert.eaSessions = eaSessions;
|
|
||||||
eaExpert.eaRestrictionsPeriod = eaRestrictionsPeriod;
|
|
||||||
eaExpert.eaMaxAllowedTPs = eaMaxAllowedTPs;
|
|
||||||
eaExpert.eaMaxAllowedSLs = eaMaxAllowedSLs;
|
|
||||||
eaExpert.eaMaxAllowedTrades = eaMaxAllowedTrades;
|
|
||||||
eaExpert.eaMaxAllowedPositions = eaMaxAllowedPositions;
|
|
||||||
eaExpert.eaMaxAllowedSpread = eaMaxAllowedSpread;
|
|
||||||
eaExpert.eaMaxAllowedDrawdownFactor = eaMaxAllowedDrawdownFactor;
|
eaExpert.eaMaxAllowedDrawdownFactor = eaMaxAllowedDrawdownFactor;
|
||||||
eaExpert.eaCloseAllOpenTradesAt = eaCloseAllOpenTradesAt;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Volume ...
|
// Volume ...
|
||||||
|
|||||||
@@ -318,7 +318,61 @@ enum ENUM_XTRADE_RESTRICTION_PERIOD
|
|||||||
//
|
//
|
||||||
string ToXString(ENUM_XTRADE_RESTRICTION_PERIOD value)
|
string ToXString(ENUM_XTRADE_RESTRICTION_PERIOD value)
|
||||||
{
|
{
|
||||||
return EnumToString(value);
|
//
|
||||||
|
string result = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = EnumToString(value);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_XTRADE_RESTRICTION_PERIOD ToXRestrictionPeriod(string value)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ENUM_XTRADE_RESTRICTION_PERIOD result = XTRADE_RESTRICATION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsSpecifiedValid(value))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// None ...
|
||||||
|
if (value == ToXString(XTRADE_RESTRICATION_NONE))
|
||||||
|
{
|
||||||
|
result = XTRADE_RESTRICATION_NONE;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Per Hour ...
|
||||||
|
else if (value == ToXString(XTRADE_RESTRICATION_HOURLY))
|
||||||
|
{
|
||||||
|
result = XTRADE_RESTRICATION_HOURLY;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Per Day ...
|
||||||
|
else if (value == ToXString(XTRADE_RESTRICATION_DAILY))
|
||||||
|
{
|
||||||
|
result = XTRADE_RESTRICATION_DAILY;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Per Week ...
|
||||||
|
else if (value == ToXString(XTRADE_RESTRICATION_WEEKLY))
|
||||||
|
{
|
||||||
|
result = XTRADE_RESTRICATION_WEEKLY;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Per Month ...
|
||||||
|
else if (value == ToXString(XTRADE_RESTRICATION_MONTHLY))
|
||||||
|
{
|
||||||
|
result = XTRADE_RESTRICATION_MONTHLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2873,10 +2927,7 @@ struct XSymbolTradeConfig
|
|||||||
* @param _sessionsDescriptor: Sessions Description
|
* @param _sessionsDescriptor: Sessions Description
|
||||||
* @param _maxAllowedSpread: Max Allowed Spread for Open Trade
|
* @param _maxAllowedSpread: Max Allowed Spread for Open Trade
|
||||||
* @param _maxAllowedPositions: Max Allowed Same Time Position
|
* @param _maxAllowedPositions: Max Allowed Same Time Position
|
||||||
* @param _closeAllOpenTradesAt: Close All Open Trades
|
* @param _restrictionsDescriptor: Restrictions Descriptor
|
||||||
* @param _maxAllowedTPs: Max Allowed TPs in Restrictions Period
|
|
||||||
* @param _maxAllowedSLs: Max Allowed SLs in Restrictions Period
|
|
||||||
* @param _restrictionsPeriod: Restrictions Period
|
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
@@ -2887,10 +2938,6 @@ struct XSymbolTradeConfig
|
|||||||
double _maxAllowedSpread = 25,
|
double _maxAllowedSpread = 25,
|
||||||
int _maxAllowedPositions = 5,
|
int _maxAllowedPositions = 5,
|
||||||
string _restrictionsDescriptor = NULL //
|
string _restrictionsDescriptor = NULL //
|
||||||
// string _closeAllOpenTradesAt = NULL,
|
|
||||||
// int _maxAllowedTPs = 0,
|
|
||||||
// int _maxAllowedSLs = 0,
|
|
||||||
// ENUM_XTRADE_RESTRICTION_PERIOD _restrictionsPeriod = XTRADE_RESTRICATION_NONE //
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -2907,12 +2954,6 @@ struct XSymbolTradeConfig
|
|||||||
maxAllowedSpread = _maxAllowedSpread;
|
maxAllowedSpread = _maxAllowedSpread;
|
||||||
maxAllowedPositions = _maxAllowedPositions;
|
maxAllowedPositions = _maxAllowedPositions;
|
||||||
|
|
||||||
//
|
|
||||||
// maxAllowedTPs = _maxAllowedTPs;
|
|
||||||
// maxAllowedSLs = _maxAllowedSLs;
|
|
||||||
// restrictionsPeriod = _restrictionsPeriod;
|
|
||||||
// closeAllOpenTradesAt = _closeAllOpenTradesAt;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parse Sessions ...
|
// Parse Sessions ...
|
||||||
ParseSessions(_sessionsDescriptor);
|
ParseSessions(_sessionsDescriptor);
|
||||||
@@ -2922,6 +2963,7 @@ struct XSymbolTradeConfig
|
|||||||
ParseRestrictions(_restrictionsDescriptor);
|
ParseRestrictions(_restrictionsDescriptor);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// Check Validation ...
|
||||||
result = IsValid();
|
result = IsValid();
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -3011,6 +3053,7 @@ struct XSymbolTradeConfig
|
|||||||
void ParseSessions(string descriptor)
|
void ParseSessions(string descriptor)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
// Validate ...
|
||||||
if (!IsSpecifiedValid(descriptor))
|
if (!IsSpecifiedValid(descriptor))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -3098,8 +3141,98 @@ struct XSymbolTradeConfig
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Parse Restrictions ...
|
// Parse Restrictions ...
|
||||||
void ParseRestrictions(string descriptor) {
|
void ParseRestrictions(string descriptor)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
if (!IsSpecifiedValid(descriptor))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extract Content ...
|
||||||
|
descriptor = ExtractString(descriptor);
|
||||||
|
if (!IsSpecifiedValid(descriptor))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = 0;
|
||||||
|
bool has = false;
|
||||||
|
string iRestrictionsParts[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extract Parts ...
|
||||||
|
count = SplitContent(
|
||||||
|
iRestrictionsParts,
|
||||||
|
descriptor,
|
||||||
|
"," //
|
||||||
|
);
|
||||||
|
has = IsValidSize(count);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Default Restrictions ...
|
||||||
|
ApplyDefaultRestrictions();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try To Extract Required Parts ...
|
||||||
|
bool hasRestrictionsPeriod = count >= 1;
|
||||||
|
bool hasMaxAllowedTPs = count >= 2;
|
||||||
|
bool hasMaxAllowedSLs = count >= 3;
|
||||||
|
bool hasMaxAllowedTrades = count >= 4;
|
||||||
|
bool hasCloseAllOpenTradesAt = count >= 5;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Restrictions Period ...
|
||||||
|
restrictionsPeriod =
|
||||||
|
hasRestrictionsPeriod
|
||||||
|
? ToXRestrictionPeriod(Trim(iRestrictionsParts[0]))
|
||||||
|
: XTRADE_RESTRICATION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Max Allowed TPs ...
|
||||||
|
maxAllowedTPs =
|
||||||
|
hasMaxAllowedTPs
|
||||||
|
? (int)(Trim(iRestrictionsParts[1]))
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Max Allowed SLs ...
|
||||||
|
maxAllowedSLs =
|
||||||
|
hasMaxAllowedSLs
|
||||||
|
? (int)(Trim(iRestrictionsParts[2]))
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Max Allowed Trades ...
|
||||||
|
maxAllowedTrades =
|
||||||
|
hasMaxAllowedTrades
|
||||||
|
? (int)(Trim(iRestrictionsParts[3]))
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close All Open Trades At ...
|
||||||
|
closeAllOpenTradesAt =
|
||||||
|
hasCloseAllOpenTradesAt
|
||||||
|
? Trim(iRestrictionsParts[4])
|
||||||
|
: NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Apply Default Restrictions ...
|
||||||
|
void ApplyDefaultRestrictions()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
maxAllowedTPs = 0;
|
||||||
|
maxAllowedSLs = 0;
|
||||||
|
maxAllowedTrades = 0;
|
||||||
|
closeAllOpenTradesAt = NULL;
|
||||||
|
restrictionsPeriod = XTRADE_RESTRICATION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -58,15 +58,7 @@ class XCXOM1EAExpert : public XCBase
|
|||||||
bool eaAllowTrade; // Allow Trade on Signals
|
bool eaAllowTrade; // Allow Trade on Signals
|
||||||
bool eaAllowLongs; // Allow Long Trades
|
bool eaAllowLongs; // Allow Long Trades
|
||||||
bool eaAllowShorts; // Allow Short Trades
|
bool eaAllowShorts; // Allow Short Trades
|
||||||
string eaSessions; // Active Sessions
|
|
||||||
ENUM_XTRADE_RESTRICTION_PERIOD eaRestrictionsPeriod; // Restrictions Period
|
|
||||||
int eaMaxAllowedTPs; // Max Allowed TP(s) in Restrictions Period
|
|
||||||
int eaMaxAllowedSLs; // Max Allowed SL(s) in Restrictions Period
|
|
||||||
int eaMaxAllowedTrades; // Max Allowed Trades in Restrictions Period
|
|
||||||
int eaMaxAllowedPositions; // Max Allowed Same Time Trades
|
|
||||||
double eaMaxAllowedSpread; // Max Allowed Spread For Trade
|
|
||||||
double eaMaxAllowedDrawdownFactor; // Max Allowed DrawDown for Trade
|
double eaMaxAllowedDrawdownFactor; // Max Allowed DrawDown for Trade
|
||||||
string eaCloseAllOpenTradesAt; // Close All Open Trades per Day At Specified Time
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Volume ...
|
// Volume ...
|
||||||
@@ -375,8 +367,8 @@ class XCXOM1EAExpert : public XCBase
|
|||||||
eaTrade = new XCTrade(
|
eaTrade = new XCTrade(
|
||||||
eaSlippage,
|
eaSlippage,
|
||||||
eaMagicNumber,
|
eaMagicNumber,
|
||||||
eaMaxAllowedSpread,
|
0,
|
||||||
eaMaxAllowedPositions,
|
0,
|
||||||
eaMaxAllowedDrawdownFactor //
|
eaMaxAllowedDrawdownFactor //
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -551,7 +543,7 @@ class XCXOM1EAExpert : public XCBase
|
|||||||
eaTradeManager.SetSymbolConfigurations(eaSymbolConfiguration);
|
eaTradeManager.SetSymbolConfigurations(eaSymbolConfiguration);
|
||||||
count = eaTradeManager.FillSymbolConfigurations(symbolConfigurations);
|
count = eaTradeManager.FillSymbolConfigurations(symbolConfigurations);
|
||||||
has = IsValidSize(count);
|
has = IsValidSize(count);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here we Apply Symbols,Periods and Configs ...
|
// Here we Apply Symbols,Periods and Configs ...
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user