apply some fix on implementing new structure ...
This commit is contained in:
@@ -3945,6 +3945,54 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Conditions only save for Loss Signals ...
|
||||
// this means the profit must be Lower than Zero ...
|
||||
// ans also message Contains SL ...
|
||||
bool SaveConditions(XTradeData &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Item ...
|
||||
result =
|
||||
//
|
||||
item.profit < 0 &&
|
||||
Contains("SL", item.message)
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string content = item.signal.conditions;
|
||||
result = IsValid(content);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int mHandler = GetConditionsFileHandlerForWrite(item);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
FileSeek(mHandler, 0, SEEK_END);
|
||||
FileWrite(mHandler, content);
|
||||
FileFlush(mHandler);
|
||||
FileClose(mHandler);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
@@ -4010,6 +4058,37 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string GetConditionsFilePath(XTradeData &item)
|
||||
{
|
||||
//
|
||||
bool isLong = IsLong(item.type);
|
||||
|
||||
//
|
||||
string fileName =
|
||||
isLong
|
||||
? "Longs"
|
||||
: "Shorts";
|
||||
|
||||
//
|
||||
return GetConditionsFilePath(fileName);
|
||||
}
|
||||
string GetConditionsFilePath(string fileName)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
mPath + "\\" + "Conditions" + "\\" + fileName + ".x121.log"
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int GetFileHandlerForRead(XTradeData &item)
|
||||
{
|
||||
@@ -4097,6 +4176,50 @@ private:
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int GetConditionsFileHandlerForRead(XTradeData &item)
|
||||
{
|
||||
//
|
||||
int result = INVALID_HANDLE;
|
||||
|
||||
//
|
||||
string filePath = GetConditionsFilePath(item);
|
||||
if (!IsValid(filePath))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = FileOpen(
|
||||
filePath,
|
||||
FILE_READ | FILE_TXT //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
int GetConditionsFileHandlerForWrite(XTradeData &item)
|
||||
{
|
||||
//
|
||||
int result = INVALID_HANDLE;
|
||||
|
||||
//
|
||||
string filePath = GetConditionsFilePath(item);
|
||||
if (!IsValid(filePath))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = FileOpen(
|
||||
filePath,
|
||||
FILE_READ | FILE_WRITE | FILE_TXT //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
@@ -4153,6 +4276,18 @@ public:
|
||||
mSaveTrades = value;
|
||||
}
|
||||
|
||||
//
|
||||
bool SaveConditions()
|
||||
{
|
||||
return mSaveConditions;
|
||||
}
|
||||
|
||||
//
|
||||
void SaveConditions(bool value)
|
||||
{
|
||||
mSaveConditions = value;
|
||||
}
|
||||
|
||||
//
|
||||
int MaxSameTimeTrades()
|
||||
{
|
||||
@@ -5661,8 +5796,9 @@ protected:
|
||||
// Props ...
|
||||
|
||||
//
|
||||
bool mSaveSignals; // Save Signals
|
||||
bool mSaveTrades; // Save Trades
|
||||
bool mSaveSignals; // Save Signals
|
||||
bool mSaveTrades; // Save Trades
|
||||
bool mSaveConditions; // Save SL Conditions
|
||||
|
||||
//
|
||||
bool mAllowLong; // Allow Long/Buy Trade Type
|
||||
@@ -5890,6 +6026,12 @@ private:
|
||||
mCollector.Save(mData[index]);
|
||||
}
|
||||
|
||||
//
|
||||
if (mSaveConditions)
|
||||
{
|
||||
mCollector.SaveConditions(mData[index]);
|
||||
}
|
||||
|
||||
//
|
||||
// Remove Item From List ...
|
||||
ArrayRemove(
|
||||
|
||||
Reference in New Issue
Block a user