cleanup some unused code from xea ...

This commit is contained in:
2024-06-15 02:51:47 +03:30
parent 20ba42ce3c
commit 87e3cb2661
2 changed files with 220 additions and 2368 deletions
+220 -226
View File
@@ -88,9 +88,6 @@ struct XSignalInfo
bearishScore = 0; bearishScore = 0;
signal.Clean(); signal.Clean();
conditions.Clean(); conditions.Clean();
//
ResetGrid();
} }
// //
@@ -323,21 +320,6 @@ struct XSignalInfo
return result; return result;
} }
//
// Grid ...
//
double gVolume; // Next Grid Volume
double gEntry; // Next Grid Entry
//
void ResetGrid()
{
//
gEntry = 0;
gVolume = 0;
}
// //
}; };
@@ -558,6 +540,10 @@ public:
{ {
// //
Clean(mSignalInfos); Clean(mSignalInfos);
//
// Disbale Using Signal Collector ...
UseSignalCollector(false);
mSignalCollector = new XSignalInfoCollector(); mSignalCollector = new XSignalInfoCollector();
} }
@@ -565,20 +551,6 @@ public:
// Deconstructor ... // Deconstructor ...
~XSCX121SetupEA() ~XSCX121SetupEA()
{ {
//
int count = CountSignalInfos();
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
mSignalCollector.Save(mSignalInfos[i]);
}
//
Clean(mSignalInfos);
}
// //
delete mSignalCollector; delete mSignalCollector;
@@ -867,6 +839,18 @@ public:
mGridVolumeMultiplier = value; mGridVolumeMultiplier = value;
} }
//
bool UseSignalCollector()
{
return mUseSignalCollector;
}
//
void UseSignalCollector(bool value)
{
mUseSignalCollector = value;
}
// //
// Overrides ... // Overrides ...
@@ -1416,13 +1400,17 @@ public:
); );
// //
AddNewSignal( if (UseSignalCollector())
cPusher, {
cSignal, //
mBullishScore, AddNewSignal(
mBearishScore, cPusher,
cConditions // cSignal,
); mBullishScore,
mBearishScore,
cConditions //
);
}
} }
} }
} }
@@ -1510,13 +1498,17 @@ public:
); );
// //
AddNewSignal( if (UseSignalCollector())
sPusher, {
sSignal, //
mBullishScore, AddNewSignal(
mBearishScore, sPusher,
sConditions // sSignal,
); mBullishScore,
mBearishScore,
sConditions //
);
}
} }
} }
} }
@@ -1604,13 +1596,17 @@ public:
); );
// //
AddNewSignal( if (UseSignalCollector())
mPusher, {
mSignal, //
mBullishScore, AddNewSignal(
mBearishScore, mPusher,
mConditions // mSignal,
); mBullishScore,
mBearishScore,
mConditions //
);
}
} }
} }
} }
@@ -1698,13 +1694,17 @@ public:
); );
// //
AddNewSignal( if (UseSignalCollector())
lPusher, {
lSignal, //
mBullishScore, AddNewSignal(
mBearishScore, lPusher,
lConditions // lSignal,
); mBullishScore,
mBearishScore,
lConditions //
);
}
} }
} }
} }
@@ -1791,13 +1791,17 @@ public:
); );
// //
AddNewSignal( if (UseSignalCollector())
hPusher, {
hSignal, //
mBullishScore, AddNewSignal(
mBearishScore, hPusher,
hConditions // hSignal,
); mBullishScore,
mBearishScore,
hConditions //
);
}
} }
} }
} }
@@ -1963,13 +1967,17 @@ public:
void OnDealsChangedHandler(int count) override void OnDealsChangedHandler(int count) override
{ {
// //
XDeal deal; if (UseSignalCollector())
bool hasDeal = mTrader.GetLastDeal(deal);
if (hasDeal)
{ {
// //
// Update Signal Info State ... XDeal deal;
UpdateSignalState(deal); bool hasDeal = mTrader.GetLastDeal(deal);
if (hasDeal)
{
//
// Update Signal Info State ...
UpdateSignalState(deal);
}
} }
} }
@@ -1981,19 +1989,10 @@ public:
) override ) override
{ {
// //
UpdateSignalState(ticket, position, comment); if (UseSignalCollector())
} {
UpdateSignalState(ticket, position, comment);
// }
void OnGoingToProfit(XProfitTrack &track) override
{
// RemoveEQMOrders();
}
//
void OnGoingToDrawdown(XProfitTrack &track) override
{
// PlaceEQMOrders();
} }
// //
@@ -2065,6 +2064,7 @@ private:
// //
XSignalInfo mSignalInfos[]; XSignalInfo mSignalInfos[];
XSignalInfoCollector *mSignalCollector; XSignalInfoCollector *mSignalCollector;
bool mUseSignalCollector; // Enable or Disable Signal Collector
// //
int CountSignalInfos() int CountSignalInfos()
@@ -2198,6 +2198,12 @@ private:
X121SetupConditions &conditions // X121SetupConditions &conditions //
) )
{ {
//
if (!UseSignalCollector())
{
return;
}
// //
XSignalInfo info; XSignalInfo info;
bool isFilled = info.Fill( bool isFilled = info.Fill(
@@ -2222,6 +2228,12 @@ private:
// //
void UpdateSignalState(XDeal &deal) void UpdateSignalState(XDeal &deal)
{ {
//
if (!UseSignalCollector())
{
return;
}
// //
if (!deal.IsValid()) if (!deal.IsValid())
{ {
@@ -2243,30 +2255,6 @@ private:
mSignalInfos[infoIDX].ticket = deal.positionId; mSignalInfos[infoIDX].ticket = deal.positionId;
mSignalInfos[infoIDX].commission = deal.commission; mSignalInfos[infoIDX].commission = deal.commission;
mSignalInfos[infoIDX].signal.positionId = deal.positionId; mSignalInfos[infoIDX].signal.positionId = deal.positionId;
//
bool isLong = IsLong(mSignalInfos[infoIDX].signal.type);
double sEntry = mSignalInfos[infoIDX].signal.entry;
//
// Setting Grid Data ...
if (mUseGrid)
{
//
mSignalInfos[infoIDX].ResetGrid();
//
double gDistancePrice = PointToPrice(
mGridDistance,
mSignalInfos[infoIDX].signal.symbol //
);
//
mSignalInfos[infoIDX].gVolume = mSignalInfos[infoIDX].volume * mGridVolumeMultiplier;
mSignalInfos[infoIDX].gEntry = isLong
? sEntry - gDistancePrice
: sEntry + gDistancePrice;
}
} }
else if (deal.entry == DEAL_ENTRY_OUT) else if (deal.entry == DEAL_ENTRY_OUT)
{ {
@@ -2309,6 +2297,12 @@ private:
const string message // const string message //
) )
{ {
//
if (!UseSignalCollector())
{
return;
}
// //
int infoIDX = FindSignalInfoIndex(ticket); int infoIDX = FindSignalInfoIndex(ticket);
if (!IsValidIndex(infoIDX)) if (!IsValidIndex(infoIDX))
@@ -2632,141 +2626,141 @@ private:
void DoEQMGrid() void DoEQMGrid()
{ {
// //
if (!mUseGrid) if (!UseGrid())
{ {
return; return;
} }
// // //
int infosCount = CountSignalInfos(); // int infosCount = CountSignalInfos();
if (!IsValidSize(infosCount)) // if (!IsValidSize(infosCount))
{ // {
return; // return;
} // }
// // //
for (int i = 0; i < infosCount; i++) // for (int i = 0; i < infosCount; i++)
{ // {
// // //
// Check Signal Executed or not ... // // Check Signal Executed or not ...
if (mSignalInfos[i].ticket <= 0) // if (mSignalInfos[i].ticket <= 0)
{ // {
continue; // continue;
} // }
// // //
// Check Specific Position not a Support Position ... // // Check Specific Position not a Support Position ...
XPosition position; // XPosition position;
bool hasPosition = mTrader.GetPosition( // bool hasPosition = mTrader.GetPosition(
mSignalInfos[i].ticket, // mSignalInfos[i].ticket,
position // // position //
); // );
if (!hasPosition) // if (!hasPosition)
{ // {
continue; // continue;
} // }
// // //
// Check Position not a Support or EQM Support ... // // Check Position not a Support or EQM Support ...
ulong supParent = 0; // ulong supParent = 0;
supParent = ExtractSupportedTicket(position.comment); // supParent = ExtractSupportedTicket(position.comment);
if (supParent > 0) // if (supParent > 0)
{ // {
continue; // continue;
} // }
supParent = ExtractEQMSupportedTicket(position.comment); // supParent = ExtractEQMSupportedTicket(position.comment);
if (supParent > 0) // if (supParent > 0)
{ // {
continue; // continue;
} // }
// // //
// Check Grid Data ... // // Check Grid Data ...
if (mSignalInfos[i].gEntry <= 0 || mSignalInfos[i].gVolume <= 0) // if (mSignalInfos[i].gEntry <= 0 || mSignalInfos[i].gVolume <= 0)
{ // {
continue; // continue;
} // }
// // //
// Retrieve Type of Position ... // // Retrieve Type of Position ...
bool isLong = IsLong(mSignalInfos[i].signal.type); // bool isLong = IsLong(mSignalInfos[i].signal.type);
// // //
// Retrieve Cureent Entry Price based on Signal ... // // Retrieve Cureent Entry Price based on Signal ...
double cEntry = GetEntry( // double cEntry = GetEntry(
mSignalInfos[i].symbol, // mSignalInfos[i].symbol,
mSignalInfos[i].signal.type // // mSignalInfos[i].signal.type //
); // );
// // //
// Check Price Distance passed or not ... // // Check Price Distance passed or not ...
bool isPriceDistancePassedForGrid = // bool isPriceDistancePassedForGrid =
isLong // isLong
? cEntry <= mSignalInfos[i].gEntry // ? cEntry <= mSignalInfos[i].gEntry
: cEntry >= mSignalInfos[i].gEntry; // : cEntry >= mSignalInfos[i].gEntry;
if (!isPriceDistancePassedForGrid) // if (!isPriceDistancePassedForGrid)
{ // {
continue; // continue;
} // }
// // //
// Prepare Grid Signal ... // // Prepare Grid Signal ...
XSignal gSignal; // XSignal gSignal;
bool isPrepared = gSignal.Prepare( // bool isPrepared = gSignal.Prepare(
mSignalInfos[i].signal.symbol, // mSignalInfos[i].signal.symbol,
mSignalInfos[i].signal.provider, // mSignalInfos[i].signal.provider,
mSignalInfos[i].signal.period, // mSignalInfos[i].signal.period,
mSignalInfos[i].signal.type, // mSignalInfos[i].signal.type,
X_ORDER_MODE_MARKET, // X_ORDER_MODE_MARKET,
mSignalInfos[i].gEntry, // mSignalInfos[i].gEntry,
mSignalInfos[i].gVolume, // mSignalInfos[i].gVolume,
0, // SL ... // 0, // SL ...
0 // TP ... // 0 // TP ...
); // );
if (!isPrepared) // if (!isPrepared)
{ // {
continue; // continue;
} // }
// // //
// Add Support Tag ... // // Add Support Tag ...
string comment = GenerateSupportTag(mSignalInfos[i].ticket); // string comment = GenerateSupportTag(mSignalInfos[i].ticket);
gSignal.comment = comment; // gSignal.comment = comment;
// // //
// Try to Execute Grid Signal ... // // Try to Execute Grid Signal ...
ENUM_X_SIGNAL_EXECUTION_RESULT gState; // ENUM_X_SIGNAL_EXECUTION_RESULT gState;
int isExecuted = mTrader.ExecuteSignal( // int isExecuted = mTrader.ExecuteSignal(
gSignal, // gSignal,
gState, // gState,
ORDER_TIME_GTC, // ORDER_TIME_GTC,
NULL, // NULL,
false // Ignore Policies ... // false // Ignore Policies ...
); // );
if (isExecuted) // if (isExecuted)
{ // {
// // //
// Update Grid State of Signal Info ... // // Update Grid State of Signal Info ...
// // //
double gDistancePrice = PointToPrice( // double gDistancePrice = PointToPrice(
mGridDistance, // mGridDistance,
mSignalInfos[i].signal.symbol // // mSignalInfos[i].signal.symbol //
); // );
// // //
mSignalInfos[i].gVolume *= mGridVolumeMultiplier; // mSignalInfos[i].gVolume *= mGridVolumeMultiplier;
mSignalInfos[i].gEntry = isLong // mSignalInfos[i].gEntry = isLong
? mSignalInfos[i].gEntry - gDistancePrice // ? mSignalInfos[i].gEntry - gDistancePrice
: mSignalInfos[i].gEntry + gDistancePrice; // : mSignalInfos[i].gEntry + gDistancePrice;
// // //
string message = XEQMSupportToken + " Execute Grid ..."; // string message = XEQMSupportToken + " Execute Grid ...";
// // //
Alert(message); // Alert(message);
} // }
} // }
} }
// //
File diff suppressed because it is too large Load Diff