last works ...
This commit is contained in:
@@ -299,7 +299,8 @@ class XCTradeManager : public XCBase
|
||||
iMaxAllowedPositions,
|
||||
iRestrictionsDescriptor //
|
||||
);
|
||||
if (has) {
|
||||
if (has)
|
||||
{
|
||||
AddOrUpdateSymbolConfiguration(iConfig);
|
||||
}
|
||||
|
||||
@@ -377,8 +378,7 @@ class XCTradeManager : public XCBase
|
||||
{
|
||||
//
|
||||
// Handle Restrictions ...
|
||||
// TODO: Complete this ...
|
||||
// HandleRestrictions();
|
||||
HandleRestrictions();
|
||||
|
||||
//
|
||||
// Check Contains Trades for Managing ...
|
||||
@@ -715,39 +715,57 @@ class XCTradeManager : public XCBase
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Symbol is Active for
|
||||
* Analysing or Open Trades ...
|
||||
* Check Can Analyse Market based on Configurations ...
|
||||
*
|
||||
* @param symbol: Symbol
|
||||
* @param period: Period
|
||||
* @param time: Analysing Time
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsActiveSession(string symbol)
|
||||
bool CanAnalyse(
|
||||
string symbol,
|
||||
ENUM_TIMEFRAMES period,
|
||||
datetime time //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
result = IsValid(symbol);
|
||||
// Finding Symbol Configuration Index ...
|
||||
int idx = FindSymbolConfigurationIndex(
|
||||
symbol,
|
||||
period //
|
||||
);
|
||||
|
||||
//
|
||||
// If Not Exists ...
|
||||
if (!IsValidIndex(idx))
|
||||
{
|
||||
//
|
||||
result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// If Exists ...
|
||||
|
||||
//
|
||||
// Check Session is Active ...
|
||||
result = symbolTradeConfigs[idx].CanTrade(time);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Complete this ...
|
||||
|
||||
// //
|
||||
// // Check Symbol Session Exists or not ...
|
||||
// int symbolSessionIDX = -1;
|
||||
// bool isSymbolSessionExists = FindSymbolSession(
|
||||
// symbolSessionIDX,
|
||||
// symbol //
|
||||
// );
|
||||
|
||||
// //
|
||||
// // Chack Trade Session Validating ...
|
||||
// if (isSymbolSessionExists)
|
||||
// {
|
||||
// result = sessions[symbolSessionIDX].CanTrade();
|
||||
// }
|
||||
// Check Symbol Restrictions ...
|
||||
result = symbolTradeConfigs[idx].IsRestricted(time);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -838,6 +856,29 @@ class XCTradeManager : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle All Exists Symbol Configurations Restrictions ...
|
||||
*/
|
||||
void HandleRestrictions()
|
||||
{
|
||||
//
|
||||
// Count Symbol Configurations ...
|
||||
int count = ArraySize(symbolTradeConfigs);
|
||||
bool has = IsValidSize(count);
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Restrictions ...
|
||||
datetime cTime = TimeCurrent();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
symbolTradeConfigs[i].HandleRestrictions(cTime);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute Specified Signal ...
|
||||
*
|
||||
@@ -1071,19 +1112,21 @@ class XCTradeManager : public XCBase
|
||||
HandleReportBalance(prefix);
|
||||
|
||||
//
|
||||
// Handle Symbol Info ...
|
||||
// Handle Symbol Config ...
|
||||
|
||||
// //
|
||||
// XTradeSymbolInfo iSymbolInfo;
|
||||
|
||||
// //
|
||||
// iSymbolInfo.profits = 1;
|
||||
// iSymbolInfo.managedTPs = 1;
|
||||
// iSymbolInfo.symbol = trades[idx].signal.symbol;
|
||||
// iSymbolInfo.managedProfits = trades[idx].profit;
|
||||
|
||||
// //
|
||||
// AddOrUpdateSymbolInfo(iSymbolInfo);
|
||||
//
|
||||
int configIdx = FindSymbolConfigurationIndex(
|
||||
trades[idx].symbol,
|
||||
tardes[idx].period //
|
||||
);
|
||||
isExists = IsValidIndex(configIdx);
|
||||
if (isExists)
|
||||
{
|
||||
//
|
||||
symbolTradeConfigs[configIdx].profits += 1;
|
||||
symbolTradeConfigs[configIdx].managedTPs += 1;
|
||||
symbolTradeConfigs[configIdx].managedProfits += trades[idx].profit;
|
||||
}
|
||||
|
||||
//
|
||||
RemoveTrade(idx);
|
||||
@@ -1138,27 +1181,34 @@ class XCTradeManager : public XCBase
|
||||
SaveLost(trades[idx]);
|
||||
}
|
||||
|
||||
// //
|
||||
// XTradeSymbolInfo iSymbolInfo;
|
||||
//
|
||||
// Handle Symbol Config ...
|
||||
|
||||
// //
|
||||
// if (isInProfit)
|
||||
// {
|
||||
// //
|
||||
// iSymbolInfo.profits = 1;
|
||||
// iSymbolInfo.managedTPs = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// iSymbolInfo.losses = 1;
|
||||
// iSymbolInfo.managedSLs = 1;
|
||||
// }
|
||||
// iSymbolInfo.symbol = trades[idx].signal.symbol;
|
||||
// iSymbolInfo.managedProfits = trades[idx].profit;
|
||||
//
|
||||
int configIdx = FindSymbolConfigurationIndex(
|
||||
trades[idx].symbol,
|
||||
tardes[idx].period //
|
||||
);
|
||||
isExists = IsValidIndex(configIdx);
|
||||
if (isExists)
|
||||
{
|
||||
//
|
||||
if (isInProfit)
|
||||
{
|
||||
//
|
||||
symbolTradeConfigs[configIdx].profits += 1;
|
||||
symbolTradeConfigs[configIdx].managedTPs += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
symbolTradeConfigs[configIdx].losses += 1;
|
||||
symbolTradeConfigs[configIdx].managedSLs += 1;
|
||||
}
|
||||
|
||||
// //
|
||||
// AddOrUpdateSymbolInfo(iSymbolInfo);
|
||||
//
|
||||
symbolTradeConfigs[configIdx].managedProfits += trades[idx].profit;
|
||||
}
|
||||
|
||||
//
|
||||
RemoveTrade(idx);
|
||||
@@ -1219,29 +1269,33 @@ class XCTradeManager : public XCBase
|
||||
HandleReportBalance(prefix);
|
||||
|
||||
//
|
||||
// Handle Symbol Info ...
|
||||
// Handle Symbol Config ...
|
||||
|
||||
//
|
||||
// XTradeSymbolInfo iSymbolInfo;
|
||||
int configIdx = FindSymbolConfigurationIndex(
|
||||
trades[idx].symbol,
|
||||
tardes[idx].period //
|
||||
);
|
||||
isExists = IsValidIndex(configIdx);
|
||||
if (isExists)
|
||||
{
|
||||
//
|
||||
if (isInProfit)
|
||||
{
|
||||
//
|
||||
symbolTradeConfigs[configIdx].profits += 1;
|
||||
symbolTradeConfigs[configIdx].managedTPs += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
symbolTradeConfigs[configIdx].losses += 1;
|
||||
symbolTradeConfigs[configIdx].managedSLs += 1;
|
||||
}
|
||||
|
||||
// //
|
||||
// if (isInProfit)
|
||||
// {
|
||||
// //
|
||||
// iSymbolInfo.profits = 1;
|
||||
// iSymbolInfo.managedTPs = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// iSymbolInfo.losses = 1;
|
||||
// iSymbolInfo.managedSLs = 1;
|
||||
// }
|
||||
// iSymbolInfo.symbol = trades[idx].signal.symbol;
|
||||
// iSymbolInfo.managedProfits = trades[idx].profit;
|
||||
|
||||
// //
|
||||
// AddOrUpdateSymbolInfo(iSymbolInfo);
|
||||
//
|
||||
symbolTradeConfigs[configIdx].managedProfits += trades[idx].profit;
|
||||
}
|
||||
|
||||
//
|
||||
RemoveTrade(idx);
|
||||
@@ -1884,6 +1938,43 @@ class XCTradeManager : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int FindSymbolConfigurationIndex(
|
||||
string symbol,
|
||||
ENUM_TIMEFRAMES period //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
!IsSpecifiedValid(symbol) ||
|
||||
!IsSpecifiedValid(period) ||
|
||||
!HasChild(symbolTradeConfigs))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(symbolTradeConfigs);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
if (symbolTradeConfigs[i].symbol == symbol &&
|
||||
symbolTradeConfigs[i].period == period)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user