cleanup some unused code from xea ...
This commit is contained in:
@@ -88,9 +88,6 @@ struct XSignalInfo
|
||||
bearishScore = 0;
|
||||
signal.Clean();
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
ResetGrid();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -323,21 +320,6 @@ struct XSignalInfo
|
||||
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);
|
||||
|
||||
//
|
||||
// Disbale Using Signal Collector ...
|
||||
UseSignalCollector(false);
|
||||
mSignalCollector = new XSignalInfoCollector();
|
||||
}
|
||||
|
||||
@@ -565,20 +551,6 @@ public:
|
||||
// Deconstructor ...
|
||||
~XSCX121SetupEA()
|
||||
{
|
||||
//
|
||||
int count = CountSignalInfos();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
mSignalCollector.Save(mSignalInfos[i]);
|
||||
}
|
||||
|
||||
//
|
||||
Clean(mSignalInfos);
|
||||
}
|
||||
|
||||
//
|
||||
delete mSignalCollector;
|
||||
|
||||
@@ -867,6 +839,18 @@ public:
|
||||
mGridVolumeMultiplier = value;
|
||||
}
|
||||
|
||||
//
|
||||
bool UseSignalCollector()
|
||||
{
|
||||
return mUseSignalCollector;
|
||||
}
|
||||
|
||||
//
|
||||
void UseSignalCollector(bool value)
|
||||
{
|
||||
mUseSignalCollector = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
@@ -1416,13 +1400,17 @@ public:
|
||||
);
|
||||
|
||||
//
|
||||
AddNewSignal(
|
||||
cPusher,
|
||||
cSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
cConditions //
|
||||
);
|
||||
if (UseSignalCollector())
|
||||
{
|
||||
//
|
||||
AddNewSignal(
|
||||
cPusher,
|
||||
cSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
cConditions //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1510,13 +1498,17 @@ public:
|
||||
);
|
||||
|
||||
//
|
||||
AddNewSignal(
|
||||
sPusher,
|
||||
sSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
sConditions //
|
||||
);
|
||||
if (UseSignalCollector())
|
||||
{
|
||||
//
|
||||
AddNewSignal(
|
||||
sPusher,
|
||||
sSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
sConditions //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1604,13 +1596,17 @@ public:
|
||||
);
|
||||
|
||||
//
|
||||
AddNewSignal(
|
||||
mPusher,
|
||||
mSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
mConditions //
|
||||
);
|
||||
if (UseSignalCollector())
|
||||
{
|
||||
//
|
||||
AddNewSignal(
|
||||
mPusher,
|
||||
mSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
mConditions //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1698,13 +1694,17 @@ public:
|
||||
);
|
||||
|
||||
//
|
||||
AddNewSignal(
|
||||
lPusher,
|
||||
lSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
lConditions //
|
||||
);
|
||||
if (UseSignalCollector())
|
||||
{
|
||||
//
|
||||
AddNewSignal(
|
||||
lPusher,
|
||||
lSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
lConditions //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1791,13 +1791,17 @@ public:
|
||||
);
|
||||
|
||||
//
|
||||
AddNewSignal(
|
||||
hPusher,
|
||||
hSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
hConditions //
|
||||
);
|
||||
if (UseSignalCollector())
|
||||
{
|
||||
//
|
||||
AddNewSignal(
|
||||
hPusher,
|
||||
hSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
hConditions //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1963,13 +1967,17 @@ public:
|
||||
void OnDealsChangedHandler(int count) override
|
||||
{
|
||||
//
|
||||
XDeal deal;
|
||||
bool hasDeal = mTrader.GetLastDeal(deal);
|
||||
if (hasDeal)
|
||||
if (UseSignalCollector())
|
||||
{
|
||||
//
|
||||
// Update Signal Info State ...
|
||||
UpdateSignalState(deal);
|
||||
XDeal deal;
|
||||
bool hasDeal = mTrader.GetLastDeal(deal);
|
||||
if (hasDeal)
|
||||
{
|
||||
//
|
||||
// Update Signal Info State ...
|
||||
UpdateSignalState(deal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1981,19 +1989,10 @@ public:
|
||||
) override
|
||||
{
|
||||
//
|
||||
UpdateSignalState(ticket, position, comment);
|
||||
}
|
||||
|
||||
//
|
||||
void OnGoingToProfit(XProfitTrack &track) override
|
||||
{
|
||||
// RemoveEQMOrders();
|
||||
}
|
||||
|
||||
//
|
||||
void OnGoingToDrawdown(XProfitTrack &track) override
|
||||
{
|
||||
// PlaceEQMOrders();
|
||||
if (UseSignalCollector())
|
||||
{
|
||||
UpdateSignalState(ticket, position, comment);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2065,6 +2064,7 @@ private:
|
||||
//
|
||||
XSignalInfo mSignalInfos[];
|
||||
XSignalInfoCollector *mSignalCollector;
|
||||
bool mUseSignalCollector; // Enable or Disable Signal Collector
|
||||
|
||||
//
|
||||
int CountSignalInfos()
|
||||
@@ -2198,6 +2198,12 @@ private:
|
||||
X121SetupConditions &conditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
if (!UseSignalCollector())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XSignalInfo info;
|
||||
bool isFilled = info.Fill(
|
||||
@@ -2222,6 +2228,12 @@ private:
|
||||
//
|
||||
void UpdateSignalState(XDeal &deal)
|
||||
{
|
||||
//
|
||||
if (!UseSignalCollector())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
if (!deal.IsValid())
|
||||
{
|
||||
@@ -2243,30 +2255,6 @@ private:
|
||||
mSignalInfos[infoIDX].ticket = deal.positionId;
|
||||
mSignalInfos[infoIDX].commission = deal.commission;
|
||||
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)
|
||||
{
|
||||
@@ -2309,6 +2297,12 @@ private:
|
||||
const string message //
|
||||
)
|
||||
{
|
||||
//
|
||||
if (!UseSignalCollector())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int infoIDX = FindSignalInfoIndex(ticket);
|
||||
if (!IsValidIndex(infoIDX))
|
||||
@@ -2632,141 +2626,141 @@ private:
|
||||
void DoEQMGrid()
|
||||
{
|
||||
//
|
||||
if (!mUseGrid)
|
||||
if (!UseGrid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int infosCount = CountSignalInfos();
|
||||
if (!IsValidSize(infosCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// //
|
||||
// int infosCount = CountSignalInfos();
|
||||
// if (!IsValidSize(infosCount))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
//
|
||||
for (int i = 0; i < infosCount; i++)
|
||||
{
|
||||
//
|
||||
// Check Signal Executed or not ...
|
||||
if (mSignalInfos[i].ticket <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// //
|
||||
// for (int i = 0; i < infosCount; i++)
|
||||
// {
|
||||
// //
|
||||
// // Check Signal Executed or not ...
|
||||
// if (mSignalInfos[i].ticket <= 0)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//
|
||||
// Check Specific Position not a Support Position ...
|
||||
XPosition position;
|
||||
bool hasPosition = mTrader.GetPosition(
|
||||
mSignalInfos[i].ticket,
|
||||
position //
|
||||
);
|
||||
if (!hasPosition)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// //
|
||||
// // Check Specific Position not a Support Position ...
|
||||
// XPosition position;
|
||||
// bool hasPosition = mTrader.GetPosition(
|
||||
// mSignalInfos[i].ticket,
|
||||
// position //
|
||||
// );
|
||||
// if (!hasPosition)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//
|
||||
// Check Position not a Support or EQM Support ...
|
||||
ulong supParent = 0;
|
||||
supParent = ExtractSupportedTicket(position.comment);
|
||||
if (supParent > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
supParent = ExtractEQMSupportedTicket(position.comment);
|
||||
if (supParent > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// //
|
||||
// // Check Position not a Support or EQM Support ...
|
||||
// ulong supParent = 0;
|
||||
// supParent = ExtractSupportedTicket(position.comment);
|
||||
// if (supParent > 0)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// supParent = ExtractEQMSupportedTicket(position.comment);
|
||||
// if (supParent > 0)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//
|
||||
// Check Grid Data ...
|
||||
if (mSignalInfos[i].gEntry <= 0 || mSignalInfos[i].gVolume <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// //
|
||||
// // Check Grid Data ...
|
||||
// if (mSignalInfos[i].gEntry <= 0 || mSignalInfos[i].gVolume <= 0)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//
|
||||
// Retrieve Type of Position ...
|
||||
bool isLong = IsLong(mSignalInfos[i].signal.type);
|
||||
// //
|
||||
// // Retrieve Type of Position ...
|
||||
// bool isLong = IsLong(mSignalInfos[i].signal.type);
|
||||
|
||||
//
|
||||
// Retrieve Cureent Entry Price based on Signal ...
|
||||
double cEntry = GetEntry(
|
||||
mSignalInfos[i].symbol,
|
||||
mSignalInfos[i].signal.type //
|
||||
);
|
||||
// //
|
||||
// // Retrieve Cureent Entry Price based on Signal ...
|
||||
// double cEntry = GetEntry(
|
||||
// mSignalInfos[i].symbol,
|
||||
// mSignalInfos[i].signal.type //
|
||||
// );
|
||||
|
||||
//
|
||||
// Check Price Distance passed or not ...
|
||||
bool isPriceDistancePassedForGrid =
|
||||
isLong
|
||||
? cEntry <= mSignalInfos[i].gEntry
|
||||
: cEntry >= mSignalInfos[i].gEntry;
|
||||
if (!isPriceDistancePassedForGrid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// //
|
||||
// // Check Price Distance passed or not ...
|
||||
// bool isPriceDistancePassedForGrid =
|
||||
// isLong
|
||||
// ? cEntry <= mSignalInfos[i].gEntry
|
||||
// : cEntry >= mSignalInfos[i].gEntry;
|
||||
// if (!isPriceDistancePassedForGrid)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//
|
||||
// Prepare Grid Signal ...
|
||||
XSignal gSignal;
|
||||
bool isPrepared = gSignal.Prepare(
|
||||
mSignalInfos[i].signal.symbol,
|
||||
mSignalInfos[i].signal.provider,
|
||||
mSignalInfos[i].signal.period,
|
||||
mSignalInfos[i].signal.type,
|
||||
X_ORDER_MODE_MARKET,
|
||||
mSignalInfos[i].gEntry,
|
||||
mSignalInfos[i].gVolume,
|
||||
0, // SL ...
|
||||
0 // TP ...
|
||||
);
|
||||
if (!isPrepared)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// //
|
||||
// // Prepare Grid Signal ...
|
||||
// XSignal gSignal;
|
||||
// bool isPrepared = gSignal.Prepare(
|
||||
// mSignalInfos[i].signal.symbol,
|
||||
// mSignalInfos[i].signal.provider,
|
||||
// mSignalInfos[i].signal.period,
|
||||
// mSignalInfos[i].signal.type,
|
||||
// X_ORDER_MODE_MARKET,
|
||||
// mSignalInfos[i].gEntry,
|
||||
// mSignalInfos[i].gVolume,
|
||||
// 0, // SL ...
|
||||
// 0 // TP ...
|
||||
// );
|
||||
// if (!isPrepared)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//
|
||||
// Add Support Tag ...
|
||||
string comment = GenerateSupportTag(mSignalInfos[i].ticket);
|
||||
gSignal.comment = comment;
|
||||
// //
|
||||
// // Add Support Tag ...
|
||||
// string comment = GenerateSupportTag(mSignalInfos[i].ticket);
|
||||
// gSignal.comment = comment;
|
||||
|
||||
//
|
||||
// Try to Execute Grid Signal ...
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT gState;
|
||||
int isExecuted = mTrader.ExecuteSignal(
|
||||
gSignal,
|
||||
gState,
|
||||
ORDER_TIME_GTC,
|
||||
NULL,
|
||||
false // Ignore Policies ...
|
||||
);
|
||||
if (isExecuted)
|
||||
{
|
||||
//
|
||||
// Update Grid State of Signal Info ...
|
||||
// //
|
||||
// // Try to Execute Grid Signal ...
|
||||
// ENUM_X_SIGNAL_EXECUTION_RESULT gState;
|
||||
// int isExecuted = mTrader.ExecuteSignal(
|
||||
// gSignal,
|
||||
// gState,
|
||||
// ORDER_TIME_GTC,
|
||||
// NULL,
|
||||
// false // Ignore Policies ...
|
||||
// );
|
||||
// if (isExecuted)
|
||||
// {
|
||||
// //
|
||||
// // Update Grid State of Signal Info ...
|
||||
|
||||
//
|
||||
double gDistancePrice = PointToPrice(
|
||||
mGridDistance,
|
||||
mSignalInfos[i].signal.symbol //
|
||||
);
|
||||
// //
|
||||
// double gDistancePrice = PointToPrice(
|
||||
// mGridDistance,
|
||||
// mSignalInfos[i].signal.symbol //
|
||||
// );
|
||||
|
||||
//
|
||||
mSignalInfos[i].gVolume *= mGridVolumeMultiplier;
|
||||
mSignalInfos[i].gEntry = isLong
|
||||
? mSignalInfos[i].gEntry - gDistancePrice
|
||||
: mSignalInfos[i].gEntry + gDistancePrice;
|
||||
// //
|
||||
// mSignalInfos[i].gVolume *= mGridVolumeMultiplier;
|
||||
// mSignalInfos[i].gEntry = isLong
|
||||
// ? 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
Reference in New Issue
Block a user