complete save signalinfo in files after a position finished by it's conditions, also remove force XASCT verifications and add new Signal Provider based on it ...
This commit is contained in:
@@ -42,9 +42,12 @@ struct XSignalInfo
|
||||
datetime time; // Issue Time (Open Position)
|
||||
|
||||
//
|
||||
double profit; // Profit on Close
|
||||
datetime endTime; // End Time
|
||||
string message; // Close Reason
|
||||
double profit; // Profit on Close
|
||||
double commission; // Commission
|
||||
double swap; // Swap
|
||||
double volume; // Volume
|
||||
datetime endTime; // End Time
|
||||
string message; // Close Reason
|
||||
|
||||
//
|
||||
double bullishScore; // Bullish Score On Signal Time
|
||||
@@ -72,8 +75,13 @@ struct XSignalInfo
|
||||
ticket = 0;
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
provider = NULL;
|
||||
pushers = 0;
|
||||
time = NULL;
|
||||
profit = 0;
|
||||
commission = 0;
|
||||
swap = 0;
|
||||
volume = 0;
|
||||
endTime = NULL;
|
||||
message = NULL;
|
||||
bullishScore = 0;
|
||||
@@ -86,6 +94,8 @@ struct XSignalInfo
|
||||
bool Fill(
|
||||
int _pushers,
|
||||
XSignal &_signal,
|
||||
double _bullishScore,
|
||||
double _bearishScore,
|
||||
X121SetupConditions &_conditions //
|
||||
)
|
||||
{
|
||||
@@ -117,6 +127,10 @@ struct XSignalInfo
|
||||
signal = _signal;
|
||||
conditions = _conditions;
|
||||
|
||||
//
|
||||
bullishScore = _bullishScore;
|
||||
bearishScore = _bearishScore;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -186,6 +200,44 @@ struct XSignalInfo
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int GetAge()
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!IsValid(symbol) ||
|
||||
!IsValid(time) ||
|
||||
!IsValid(endTime) ||
|
||||
!IsValid(period))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int startIndex = iBarShift(
|
||||
symbol,
|
||||
period,
|
||||
time,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
int endIndex = iBarShift(
|
||||
symbol,
|
||||
period,
|
||||
endTime,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
result = MathAbs(startIndex - endIndex);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string GetFileName()
|
||||
{
|
||||
@@ -205,7 +257,7 @@ struct XSignalInfo
|
||||
provider + "_" +
|
||||
ToString(ticket) + "_" +
|
||||
ToString(period) + "_" +
|
||||
ToString(time)
|
||||
ToFormatString(time)
|
||||
//
|
||||
;
|
||||
|
||||
@@ -214,7 +266,7 @@ struct XSignalInfo
|
||||
}
|
||||
|
||||
//
|
||||
string ToModelString()
|
||||
string ToString()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
@@ -225,24 +277,34 @@ struct XSignalInfo
|
||||
false, // Only Commons ...
|
||||
true, // Only Conditions ...
|
||||
false, // Include Score ...
|
||||
false // Include False Conditions ...ّ
|
||||
false // Include False Conditions ...
|
||||
);
|
||||
|
||||
//
|
||||
int age = GetAge();
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
ToString("Ticket", ticket) +
|
||||
ToString("Symbol", symbol) +
|
||||
ToString("Period", period) +
|
||||
ToString("Pushers", pushers) +
|
||||
ToString("Provider", provider) +
|
||||
ToString("Time", time) +
|
||||
ToString("BullishScore", bullishScore) +
|
||||
ToString("BearishScore", bearishScore) +
|
||||
ToString("Volume", volume) +
|
||||
ToString("Profit", profit) +
|
||||
ToString("Commission", commission) +
|
||||
ToString("Swap", swap) +
|
||||
ToString("End Time", endTime) +
|
||||
ToString("Age", age) +
|
||||
ToString("Message", message) +
|
||||
"-------------" + "\n" +
|
||||
ToString("Signal", signal.ToModelString()) +
|
||||
ToString("Conditions", conditionsStr) +
|
||||
ToString("Signal", "\n" + signal.ToString()) +
|
||||
"-------------" + "\n" +
|
||||
ToString("Conditions", "\n" + conditionsStr) +
|
||||
//
|
||||
""
|
||||
//
|
||||
@@ -315,7 +377,7 @@ public:
|
||||
}
|
||||
|
||||
//
|
||||
string content = item.ToModelString();
|
||||
string content = item.ToString();
|
||||
result = IsValid(content);
|
||||
if (!result)
|
||||
{
|
||||
@@ -368,7 +430,7 @@ private:
|
||||
//
|
||||
result =
|
||||
//
|
||||
mPath + "\\" + fileName
|
||||
mPath + "\\" + fileName + ".x121.log"
|
||||
//
|
||||
;
|
||||
|
||||
@@ -517,6 +579,63 @@ public:
|
||||
mAllowShort = value;
|
||||
}
|
||||
|
||||
//
|
||||
double Volume()
|
||||
{
|
||||
return mVolume;
|
||||
}
|
||||
|
||||
//
|
||||
void Volume(double value)
|
||||
{
|
||||
//
|
||||
if (value < 0.01)
|
||||
{
|
||||
value = 0.01;
|
||||
}
|
||||
|
||||
//
|
||||
mVolume = value;
|
||||
}
|
||||
|
||||
//
|
||||
double TPPoint()
|
||||
{
|
||||
return mTPPoint;
|
||||
}
|
||||
|
||||
//
|
||||
void TPPoint(double value)
|
||||
{
|
||||
//
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
//
|
||||
mTPPoint = value;
|
||||
}
|
||||
|
||||
//
|
||||
double SLPoint()
|
||||
{
|
||||
return mSLPoint;
|
||||
}
|
||||
|
||||
//
|
||||
void SLPoint(double value)
|
||||
{
|
||||
//
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
//
|
||||
mSLPoint = value;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsEnable()
|
||||
{
|
||||
@@ -584,25 +703,39 @@ public:
|
||||
string separator = "\n";
|
||||
|
||||
//
|
||||
X121SetupConditions cConditions;
|
||||
X121SetupConditions sConditions;
|
||||
X121SetupConditions mConditions;
|
||||
X121SetupConditions lConditions;
|
||||
X121SetupConditions hConditions;
|
||||
|
||||
//
|
||||
// Current ...
|
||||
XSignal cSignal;
|
||||
XSignal sSignal;
|
||||
XSignal mSignal;
|
||||
XSignal lSignal;
|
||||
XSignal hSignal;
|
||||
int cPusher = 0;
|
||||
string cProvider = NULL;
|
||||
X121SetupConditions cConditions;
|
||||
|
||||
//
|
||||
int cPusher = 0;
|
||||
// Short ...
|
||||
XSignal sSignal;
|
||||
int sPusher = 0;
|
||||
string sProvider = NULL;
|
||||
X121SetupConditions sConditions;
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
XSignal mSignal;
|
||||
int mPusher = 0;
|
||||
string mProvider = NULL;
|
||||
X121SetupConditions mConditions;
|
||||
|
||||
//
|
||||
// Long ...
|
||||
XSignal lSignal;
|
||||
int lPusher = 0;
|
||||
string lProvider = NULL;
|
||||
X121SetupConditions lConditions;
|
||||
|
||||
//
|
||||
// Hind ...
|
||||
XSignal hSignal;
|
||||
int hPusher = 0;
|
||||
string hProvider = NULL;
|
||||
X121SetupConditions hConditions;
|
||||
|
||||
//
|
||||
X121SignalGenerator signalGenerator;
|
||||
@@ -661,8 +794,12 @@ public:
|
||||
cConditions,
|
||||
cSignal,
|
||||
cPusher,
|
||||
cProvider,
|
||||
mAllowLong,
|
||||
mAllowShort //
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mTPPoint //
|
||||
);
|
||||
|
||||
//
|
||||
@@ -714,8 +851,12 @@ public:
|
||||
sConditions,
|
||||
sSignal,
|
||||
sPusher,
|
||||
sProvider,
|
||||
mAllowLong,
|
||||
mAllowShort //
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mTPPoint //
|
||||
);
|
||||
|
||||
//
|
||||
@@ -767,8 +908,12 @@ public:
|
||||
mConditions,
|
||||
mSignal,
|
||||
mPusher,
|
||||
mProvider,
|
||||
mAllowLong,
|
||||
mAllowShort //
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mTPPoint //
|
||||
);
|
||||
|
||||
//
|
||||
@@ -820,8 +965,12 @@ public:
|
||||
lConditions,
|
||||
lSignal,
|
||||
lPusher,
|
||||
lProvider,
|
||||
mAllowLong,
|
||||
mAllowShort //
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mTPPoint //
|
||||
);
|
||||
|
||||
//
|
||||
@@ -873,8 +1022,12 @@ public:
|
||||
hConditions,
|
||||
hSignal,
|
||||
hPusher,
|
||||
hProvider,
|
||||
mAllowLong,
|
||||
mAllowShort //
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mTPPoint //
|
||||
);
|
||||
|
||||
//
|
||||
@@ -907,6 +1060,8 @@ public:
|
||||
AddNewSignal(
|
||||
cPusher,
|
||||
cSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
cConditions //
|
||||
);
|
||||
}
|
||||
@@ -925,6 +1080,8 @@ public:
|
||||
AddNewSignal(
|
||||
sPusher,
|
||||
sSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
sConditions //
|
||||
);
|
||||
}
|
||||
@@ -943,6 +1100,8 @@ public:
|
||||
AddNewSignal(
|
||||
mPusher,
|
||||
mSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
mConditions //
|
||||
);
|
||||
}
|
||||
@@ -961,6 +1120,8 @@ public:
|
||||
AddNewSignal(
|
||||
lPusher,
|
||||
lSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
lConditions //
|
||||
);
|
||||
}
|
||||
@@ -979,6 +1140,8 @@ public:
|
||||
AddNewSignal(
|
||||
hPusher,
|
||||
hSignal,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
hConditions //
|
||||
);
|
||||
}
|
||||
@@ -1083,6 +1246,7 @@ public:
|
||||
// Tools For Signal Info Collect ...
|
||||
|
||||
//
|
||||
// Used for Signal Info States ...
|
||||
void OnDealsChangedHandler(int count)
|
||||
{
|
||||
//
|
||||
@@ -1090,6 +1254,8 @@ public:
|
||||
bool hasDeal = mTrader.GetLastDeal(deal);
|
||||
if (hasDeal)
|
||||
{
|
||||
//
|
||||
// Update Signal Info State ...
|
||||
UpdateSignalState(deal);
|
||||
}
|
||||
}
|
||||
@@ -1115,10 +1281,9 @@ private:
|
||||
//
|
||||
bool mAllowLong; // Allow Long
|
||||
bool mAllowShort; // Allow Short
|
||||
|
||||
//
|
||||
// TODO:
|
||||
// Add Volume and TP SL Points as Properties here ...
|
||||
double mVolume; // Volume
|
||||
double mTPPoint; // TP Point
|
||||
double mSLPoint; // SL Point
|
||||
|
||||
//
|
||||
XSignalInfo mSignalInfos[];
|
||||
@@ -1242,6 +1407,8 @@ private:
|
||||
void AddNewSignal(
|
||||
int pusher,
|
||||
XSignal &signal,
|
||||
double bullishScore,
|
||||
double bearishScore,
|
||||
X121SetupConditions &conditions //
|
||||
)
|
||||
{
|
||||
@@ -1250,6 +1417,8 @@ private:
|
||||
bool isFilled = info.Fill(
|
||||
pusher,
|
||||
signal,
|
||||
bullishScore,
|
||||
bearishScore,
|
||||
conditions //
|
||||
);
|
||||
|
||||
@@ -1286,11 +1455,42 @@ private:
|
||||
//
|
||||
mSignalInfos[infoIDX].time = deal.time;
|
||||
mSignalInfos[infoIDX].ticket = deal.positionId;
|
||||
Print("Open Position: " + ToString(deal.positionId));
|
||||
mSignalInfos[infoIDX].commission = deal.commission;
|
||||
mSignalInfos[infoIDX].signal.positionId = deal.positionId;
|
||||
}
|
||||
else if (deal.entry == DEAL_ENTRY_OUT)
|
||||
{
|
||||
Print("Close Position: " + ToString(deal.positionId));
|
||||
//
|
||||
mSignalInfos[infoIDX].swap = deal.swap;
|
||||
mSignalInfos[infoIDX].endTime = deal.time;
|
||||
mSignalInfos[infoIDX].profit = deal.profit;
|
||||
|
||||
//
|
||||
string message =
|
||||
//
|
||||
deal.reason == DEAL_REASON_TP
|
||||
? "TP"
|
||||
: deal.reason == DEAL_REASON_SL
|
||||
? "SL"
|
||||
: IsValid(deal.comment)
|
||||
? deal.comment
|
||||
: "Force Close ..."
|
||||
//
|
||||
;
|
||||
mSignalInfos[infoIDX].message = message;
|
||||
|
||||
//
|
||||
// Now we can Save Signal Info and Remove it from mSignal Infos ...
|
||||
bool isSaved = mSignalCollector.Save(mSignalInfos[infoIDX]);
|
||||
if (isSaved)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
mSignalInfos,
|
||||
infoIDX,
|
||||
1 //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user