last ...
This commit is contained in:
@@ -253,7 +253,8 @@ struct XSignalInfo
|
||||
//
|
||||
result =
|
||||
//
|
||||
symbol + "_" +
|
||||
symbol + "\\" +
|
||||
ToString(signal.type) + "\\" +
|
||||
provider + "_" +
|
||||
ToString(ticket) + "_" +
|
||||
ToString(period) + "_" +
|
||||
@@ -332,6 +333,9 @@ public:
|
||||
string _path = NULL // Base Path
|
||||
)
|
||||
{
|
||||
//
|
||||
mAccount = new XSCAccount();
|
||||
|
||||
//
|
||||
if (IsValid(_path))
|
||||
{
|
||||
@@ -339,7 +343,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
mPath = "XSignalInfo";
|
||||
mPath = "XSignalInfo" + "\\" + mAccount.GetCompany();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,6 +417,9 @@ private:
|
||||
//
|
||||
string mPath; // Base Path ...
|
||||
|
||||
//
|
||||
XSCAccount *mAccount;
|
||||
|
||||
//
|
||||
string GetFilePath(XSignalInfo &item)
|
||||
{
|
||||
@@ -502,16 +509,24 @@ public:
|
||||
ulong magicNumber, // Specify Magic Number
|
||||
//
|
||||
// XSCTrade Event Handlers ...
|
||||
TOnSignal onSignal = NULL, // On Signal Recieved Event Handler
|
||||
TOnModify onModifyPosition = NULL, // On Modify Position Event Handler
|
||||
TOnStopLoss onStopLossTriggered = NULL, // On StopLoass Triggered Event Handler
|
||||
TOnTakeProfit onTakeProfitTriggered = NULL, // On TakeProfit Triggered Event Handler
|
||||
TOnForceClose onForceClosePosition = NULL, // On Force Close Position Event Handler
|
||||
TOnPartialClose onPartialClosePosition = NULL, // On Partial Close Position Event Handler
|
||||
TOnDealsChanged onDealsChangedHandler = NULL, // On Deals Changed Event Handler
|
||||
TOnOrdersChanged onOrdersChangedHandler = NULL, // On Orders Changed Event Handler
|
||||
TOnPositionsChanged onPositionsChangedHandler = NULL, // On Positions Changed Event Handler
|
||||
TOnTradeStateChanged onTradeStateChangedHandler = NULL // On Trade State Changed Event Handler
|
||||
) : XSCBaseEA(slippage,
|
||||
magicNumber,
|
||||
onSignal,
|
||||
onModifyPosition,
|
||||
onStopLossTriggered,
|
||||
onTakeProfitTriggered,
|
||||
onForceClosePosition,
|
||||
onPartialClosePosition,
|
||||
onDealsChangedHandler,
|
||||
onOrdersChangedHandler,
|
||||
onPositionsChangedHandler,
|
||||
@@ -527,6 +542,25 @@ public:
|
||||
// Deconstructor ...
|
||||
~XSCX121SetupEA()
|
||||
{
|
||||
//
|
||||
int count = CountSignalInfos();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
mSignalCollector.Save(mSignalInfos[i]);
|
||||
}
|
||||
|
||||
//
|
||||
Clean(mSignalInfos);
|
||||
}
|
||||
|
||||
//
|
||||
delete mSignalCollector;
|
||||
|
||||
//
|
||||
Clean(mSetups);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -660,6 +694,18 @@ public:
|
||||
mIgnoreSL = value;
|
||||
}
|
||||
|
||||
//
|
||||
bool CloseOnOpposit()
|
||||
{
|
||||
return mCloseOnOpposit;
|
||||
}
|
||||
|
||||
//
|
||||
void CloseOnOpposit(bool value)
|
||||
{
|
||||
mCloseOnOpposit = value;
|
||||
}
|
||||
|
||||
//
|
||||
int ReuiredSignalVerifications()
|
||||
{
|
||||
@@ -1118,7 +1164,7 @@ public:
|
||||
|
||||
//
|
||||
// Current Signals ...
|
||||
if (cPusher > mReuiredSignalVerifications && cSignal.IsValid())
|
||||
if (cPusher >= mReuiredSignalVerifications && cSignal.IsValid())
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
@@ -1138,7 +1184,7 @@ public:
|
||||
|
||||
//
|
||||
// Short Signals ...
|
||||
if (sPusher > mReuiredSignalVerifications && sSignal.IsValid())
|
||||
if (sPusher >= mReuiredSignalVerifications && sSignal.IsValid())
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
@@ -1158,7 +1204,7 @@ public:
|
||||
|
||||
//
|
||||
// Medium Signals ...
|
||||
if (mPusher > mReuiredSignalVerifications && mSignal.IsValid())
|
||||
if (mPusher >= mReuiredSignalVerifications && mSignal.IsValid())
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
@@ -1178,7 +1224,7 @@ public:
|
||||
|
||||
//
|
||||
// Long Signals ...
|
||||
if (lPusher > mReuiredSignalVerifications && lSignal.IsValid())
|
||||
if (lPusher >= mReuiredSignalVerifications && lSignal.IsValid())
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
@@ -1198,7 +1244,7 @@ public:
|
||||
|
||||
//
|
||||
// Hind Signals ...
|
||||
if (hPusher > mReuiredSignalVerifications && hSignal.IsValid())
|
||||
if (hPusher >= mReuiredSignalVerifications && hSignal.IsValid())
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
@@ -1273,6 +1319,46 @@ public:
|
||||
//
|
||||
XSignal iSignal = tmpSignals[i];
|
||||
|
||||
//
|
||||
// Handle Close All Positions when Opposit Signal Recieved ...
|
||||
if (mCloseOnOpposit)
|
||||
{
|
||||
//
|
||||
// Select Signal Opposit Positions ...
|
||||
ENUM_X_POSITION_TYPE iOpposit = GetOppositXPositionType(iSignal.type);
|
||||
|
||||
//
|
||||
XPosition iPositions[];
|
||||
int iPositionsCount = mTrader.GetPositions(
|
||||
iPositions,
|
||||
iSignal.symbol,
|
||||
NULL, // All Providers ...
|
||||
NULL, // All Periods ...
|
||||
iOpposit // Opposit Positions ...
|
||||
);
|
||||
|
||||
//
|
||||
if (IsValidSize(iPositionsCount))
|
||||
{
|
||||
//
|
||||
string comment = "Close due Opposit ...";
|
||||
|
||||
//
|
||||
int closeds = Close(
|
||||
iPositions,
|
||||
comment //
|
||||
);
|
||||
if (IsValidSize(closeds))
|
||||
{
|
||||
//
|
||||
string message = XEQMSupportToken + " Closed " + ToString(iPositionsCount) + " due Opposit Signal ...";
|
||||
|
||||
//
|
||||
Alert(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iSignal,
|
||||
@@ -1356,6 +1442,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void OnPositionClosed(
|
||||
const ulong ticket,
|
||||
const XPosition &position,
|
||||
const string comment //
|
||||
) override
|
||||
{
|
||||
//
|
||||
UpdateSignalState(ticket, position, comment);
|
||||
}
|
||||
|
||||
//
|
||||
void OnGoingToProfit(XProfitTrack &track) override
|
||||
{
|
||||
@@ -1388,6 +1485,7 @@ private:
|
||||
double mSLPoint; // SL Point
|
||||
bool mIgnoreTP; // Ignore Calculated TP
|
||||
bool mIgnoreSL; // Ignore Calculated SL
|
||||
bool mCloseOnOpposit; // Close all Positions on Opposit
|
||||
int mReuiredSignalVerifications; // Required Verifications for Validate Signals
|
||||
|
||||
//
|
||||
@@ -1598,6 +1696,38 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
void UpdateSignalState(
|
||||
const ulong ticket,
|
||||
const XPosition &position,
|
||||
const string message //
|
||||
)
|
||||
{
|
||||
//
|
||||
int infoIDX = FindSignalInfoIndex(ticket);
|
||||
if (!IsValidIndex(infoIDX))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
mSignalInfos[infoIDX].message = message;
|
||||
mSignalInfos[infoIDX].swap = position.swap;
|
||||
mSignalInfos[infoIDX].endTime = TimeCurrent();
|
||||
mSignalInfos[infoIDX].profit = position.profit;
|
||||
|
||||
//
|
||||
// Now we can Save Signal Info and Remove it from mSignal Infos ...
|
||||
bool isSaved = mSignalCollector.Save(mSignalInfos[infoIDX]);
|
||||
if (isSaved)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
mSignalInfos,
|
||||
infoIDX,
|
||||
1 //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
double mBullishScore;
|
||||
|
||||
Reference in New Issue
Block a user