Cleanup Work Space after Backup 14040203 ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,856 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XCX121XDELTASHelper
|
||||
// Description: provides all Indicator
|
||||
// Helper requirements ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Classes/x-saherelm.x-helper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
enum ENUM_X121_XDELTA_BUFFERS
|
||||
{
|
||||
//
|
||||
X121_XDELTA_VOLUME_LINE = 0,
|
||||
X121_XDELTA_HISTOGRAM_LINE = 1,
|
||||
X121_XDELTA_MA_LINE = 3,
|
||||
X121_XDELTA_STATE_LINE = 5,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct X121XDELTAInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Makret ...
|
||||
int maLength; // Moving Averge Length
|
||||
ENUM_X_MA_METHOD maMethod; // Moving Averge Method
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
int startCalculationForLastBars; // Calculate Last n Bars
|
||||
bool showDeltaLine; // Show Delta Line
|
||||
bool showDeltaHistogram; // Show Delta Histogram
|
||||
bool showDeltaMa; // Show Delta Moving Average
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
X121XDELTAInputs()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup Model ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Makret ...
|
||||
maLength = 0; // Moving Averge Length
|
||||
maMethod = X_MA_MODE_NONE; // Moving Averge Method
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
startCalculationForLastBars = 0; // Calculate Last n Bars
|
||||
showDeltaLine = false; // Show Delta Line
|
||||
showDeltaHistogram = false; // Show Delta Histogram
|
||||
showDeltaMa = false; // Show Delta Moving Average
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Inputs ...
|
||||
*/
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Makret ...
|
||||
maLength = 14; // Moving Averge Length
|
||||
maMethod = X_MA_MODE_EMA; // Moving Averge Method
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
startCalculationForLastBars = 1000; // Calculate Last n Bars
|
||||
showDeltaLine = true; // Show Delta Line
|
||||
showDeltaHistogram = true; // Show Delta Histogram
|
||||
showDeltaMa = true; // Show Delta Moving Average
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
maLength > 0 &&
|
||||
IsValid(maMethod)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Max Input Length ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, maLength);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
struct X121XDELTAConditions
|
||||
{
|
||||
//
|
||||
// Common ...
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double deltaBuffer[];
|
||||
double deltaMaBuffer[];
|
||||
double deltaStateBuffer[];
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
bool isDeltaBullish;
|
||||
bool isDeltaBearish;
|
||||
bool isDeltaSwitchedToBullish;
|
||||
bool isDeltaSwitchedToBearish;
|
||||
|
||||
//
|
||||
bool isDeltaOverMa;
|
||||
bool isDeltaUnderMa;
|
||||
bool isDeltaCrossedOverMa;
|
||||
bool isDeltaCrossedUnderMa;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
X121XDELTAConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleaning Up ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Commons ...
|
||||
time = NULL;
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
Clean(deltaBuffer);
|
||||
Clean(deltaMaBuffer);
|
||||
Clean(deltaStateBuffer);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(deltaBuffer, true);
|
||||
ArraySetAsSeries(deltaMaBuffer, true);
|
||||
ArraySetAsSeries(deltaStateBuffer, true);
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
isDeltaBullish = false;
|
||||
isDeltaBearish = false;
|
||||
isDeltaSwitchedToBullish = false;
|
||||
isDeltaSwitchedToBearish = false;
|
||||
|
||||
//
|
||||
isDeltaOverMa = false;
|
||||
isDeltaUnderMa = false;
|
||||
isDeltaCrossedOverMa = false;
|
||||
isDeltaCrossedUnderMa = false;
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Conditions Scores ...
|
||||
*
|
||||
* @param bullishScore: Double, Directional Scores Reference ...
|
||||
* @param bearishScore: Double, Directional Scores Reference ...
|
||||
*/
|
||||
void GenerateScore(
|
||||
double &bullishScore,
|
||||
double &bearishScore //
|
||||
)
|
||||
{
|
||||
//
|
||||
bullishScore = 0;
|
||||
bearishScore = 0;
|
||||
|
||||
//
|
||||
double score = 1;
|
||||
double minScore = 0.5;
|
||||
double highScore = 1.5;
|
||||
|
||||
//
|
||||
if (isDeltaOverMa)
|
||||
{
|
||||
bullishScore += minScore;
|
||||
}
|
||||
if (isDeltaBullish)
|
||||
{
|
||||
bullishScore += minScore;
|
||||
}
|
||||
if (isDeltaCrossedOverMa)
|
||||
{
|
||||
bullishScore += score;
|
||||
}
|
||||
if (isDeltaSwitchedToBullish)
|
||||
{
|
||||
bullishScore += score;
|
||||
}
|
||||
|
||||
if (isDeltaBearish)
|
||||
{
|
||||
bearishScore += minScore;
|
||||
}
|
||||
if (isDeltaUnderMa)
|
||||
{
|
||||
bearishScore += minScore;
|
||||
}
|
||||
if (isDeltaCrossedUnderMa)
|
||||
{
|
||||
bearishScore += score;
|
||||
}
|
||||
if (isDeltaSwitchedToBearish)
|
||||
{
|
||||
bearishScore += score;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Summary String for Represent Conditions State ...
|
||||
*
|
||||
* @param onlyCommons: Boolean, Just Generate Only Commons Conditions ...
|
||||
* @param onlyConditions: Boolean, Just Generate Only Conditions ...
|
||||
* @param includeScores: Boolean, Attach Scores Representations on Result ...
|
||||
* @param ignoreFalseConditions: Boolean, Ignore False Conditions on Result ...
|
||||
* @param separator: String, Separate Lines ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GenerateSummary(
|
||||
bool onlyCommons = false,
|
||||
bool onlyConditions = false,
|
||||
bool includeScores = true,
|
||||
bool ignoreFalseConditions = true,
|
||||
string separator = "\n" //
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
|
||||
//
|
||||
string scoresStr =
|
||||
//
|
||||
"Scores: " + separator +
|
||||
"---------------" + separator +
|
||||
"Bullish: " + ToString(bullishScore) + separator +
|
||||
"Bearish: " + ToString(bearishScore) + separator +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
string commonStr = GenerateSpecifiedCommonSummary(
|
||||
this,
|
||||
separator,
|
||||
includeScores //
|
||||
);
|
||||
|
||||
//
|
||||
string conditionsStr =
|
||||
//
|
||||
"-----------------------" + separator +
|
||||
"XDELTA: " + separator +
|
||||
"-----------------------" + separator +
|
||||
ToString("isDeltaBullish", isDeltaBullish, ignoreFalseConditions, separator) +
|
||||
ToString("isDeltaBearish", isDeltaBearish, ignoreFalseConditions, separator) +
|
||||
ToString("isDeltaSwitchedToBullish", isDeltaSwitchedToBullish, ignoreFalseConditions, separator) +
|
||||
ToString("isDeltaSwitchedToBearish", isDeltaSwitchedToBearish, ignoreFalseConditions, separator) +
|
||||
ToString("isDeltaOverMa", isDeltaOverMa, ignoreFalseConditions, separator) +
|
||||
ToString("isDeltaUnderMa", isDeltaUnderMa, ignoreFalseConditions, separator) +
|
||||
ToString("isDeltaCrossedOverMa", isDeltaCrossedOverMa, ignoreFalseConditions, separator) +
|
||||
ToString("isDeltaCrossedUnderMa", isDeltaCrossedUnderMa, ignoreFalseConditions, separator) +
|
||||
//
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
"[" + GetTag() + "]" + separator +
|
||||
(onlyConditions
|
||||
? ""
|
||||
: commonStr) +
|
||||
(!includeScores
|
||||
? ""
|
||||
: scoresStr) +
|
||||
" " + separator +
|
||||
(onlyCommons
|
||||
? ""
|
||||
: conditionsStr) +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve nique Tag Identifier ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetTag()
|
||||
{
|
||||
return GetTypeName(this);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XCX121XDELTAHelper : public XCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XCX121XDELTAHelper()
|
||||
: XCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XCX121XDELTAHelper()
|
||||
{
|
||||
//
|
||||
mInputs.Clean();
|
||||
|
||||
//
|
||||
Clean(deltaBuffer);
|
||||
Clean(deltaMaBuffer);
|
||||
Clean(deltaStateBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
X121XDELTAInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ArraySetAsSeries(deltaBuffer, true);
|
||||
ArraySetAsSeries(deltaMaBuffer, true);
|
||||
ArraySetAsSeries(deltaStateBuffer, true);
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.x121.xdelta",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.maLength,
|
||||
mInputs.maMethod,
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
//
|
||||
mInputs.startCalculationForLastBars,
|
||||
mInputs.showDeltaLine,
|
||||
mInputs.showDeltaHistogram,
|
||||
mInputs.showDeltaMa
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
X121XDELTAInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
X121XDELTAInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Readers ...
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
|
||||
//
|
||||
double GetDelta(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate(barIndex);
|
||||
|
||||
//
|
||||
int count = ArraySize(deltaBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return deltaBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
int CopyDelta(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate(start);
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
0,
|
||||
count,
|
||||
deltaBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetDeltaState(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate(barIndex);
|
||||
|
||||
//
|
||||
int count = ArraySize(deltaStateBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return deltaStateBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
int CopyDeltaState(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate(start);
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
0,
|
||||
count,
|
||||
deltaStateBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetDeltaMa(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate(barIndex);
|
||||
|
||||
//
|
||||
int count = ArraySize(deltaMaBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return deltaMaBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
int CopyDeltaMa(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate(start);
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
0,
|
||||
count,
|
||||
deltaMaBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
void Free() override
|
||||
{
|
||||
Cleanup(10);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetConditions(
|
||||
X121XDELTAConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
if (loopback < 5)
|
||||
{
|
||||
loopback = 5;
|
||||
}
|
||||
|
||||
//
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
conditions.symbol = mSymbol;
|
||||
conditions.period = mPeriod;
|
||||
conditions.time = TimeCurrent();
|
||||
|
||||
//
|
||||
int zIndex = barIndex;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
CopyDelta(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.deltaBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
CopyDeltaState(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.deltaStateBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
CopyDeltaMa(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.deltaMaBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
int cIDX = 1;
|
||||
int pIDX = cIDX + 1;
|
||||
int pPIDX = pIDX + 1;
|
||||
|
||||
//
|
||||
bool isDeltaBullish = conditions.deltaBuffer[cIDX] > conditions.deltaBuffer[pIDX];
|
||||
bool isDeltaBullishP = conditions.deltaBuffer[pIDX] > conditions.deltaBuffer[pPIDX];
|
||||
bool isDeltaSwitchedToBullish = isDeltaBullish &&
|
||||
!isDeltaBullishP;
|
||||
|
||||
//
|
||||
bool isDeltaBearish = conditions.deltaBuffer[cIDX] < conditions.deltaBuffer[pIDX];
|
||||
bool isDeltaBearishP = conditions.deltaBuffer[pIDX] < conditions.deltaBuffer[pPIDX];
|
||||
bool isDeltaSwitchedToBearish = isDeltaBearish &&
|
||||
!isDeltaBearishP;
|
||||
|
||||
//
|
||||
bool isDeltaOverMa = conditions.deltaBuffer[cIDX] > conditions.deltaMaBuffer[cIDX];
|
||||
bool isDeltaOverMaP = conditions.deltaBuffer[pIDX] > conditions.deltaMaBuffer[pIDX];
|
||||
bool isDeltaCrossedOverMa = isDeltaOverMa &&
|
||||
!isDeltaOverMaP;
|
||||
|
||||
//
|
||||
bool isDeltaUnderMa = conditions.deltaBuffer[cIDX] < conditions.deltaMaBuffer[cIDX];
|
||||
bool isDeltaUnderMaP = conditions.deltaBuffer[pIDX] < conditions.deltaMaBuffer[pIDX];
|
||||
bool isDeltaCrossedUnderMa = isDeltaUnderMa &&
|
||||
!isDeltaUnderMaP;
|
||||
|
||||
//
|
||||
conditions.isDeltaBullish = isDeltaBullish;
|
||||
conditions.isDeltaBearish = isDeltaBearish;
|
||||
conditions.isDeltaSwitchedToBullish = isDeltaSwitchedToBullish;
|
||||
conditions.isDeltaSwitchedToBearish = isDeltaSwitchedToBearish;
|
||||
|
||||
//
|
||||
conditions.isDeltaOverMa = isDeltaOverMa;
|
||||
conditions.isDeltaUnderMa = isDeltaUnderMa;
|
||||
conditions.isDeltaCrossedOverMa = isDeltaCrossedOverMa;
|
||||
conditions.isDeltaCrossedUnderMa = isDeltaCrossedUnderMa;
|
||||
|
||||
//
|
||||
Cleanup();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
X121XDELTAInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double deltaBuffer[];
|
||||
double deltaMaBuffer[];
|
||||
double deltaStateBuffer[];
|
||||
|
||||
//
|
||||
void Calculate(
|
||||
int barIndex = 0,
|
||||
int maxRequiredBars = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Buffers ...
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X121_XDELTA_VOLUME_LINE,
|
||||
barIndex,
|
||||
maxRequiredBars,
|
||||
deltaBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X121_XDELTA_MA_LINE,
|
||||
barIndex,
|
||||
maxRequiredBars,
|
||||
deltaMaBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X121_XDELTA_STATE_LINE,
|
||||
barIndex,
|
||||
maxRequiredBars,
|
||||
deltaStateBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
void Cleanup(
|
||||
int maxAllowed = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
deltaBuffer,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
CleanupArray(
|
||||
deltaMaBuffer,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
CleanupArray(
|
||||
deltaStateBuffer,
|
||||
maxAllowed //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,797 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XCX121XMASHelper
|
||||
// Description: provides all Indicator
|
||||
// Helper requirements ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Classes/x-saherelm.x-helper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
enum ENUM_X121_XMAS_BUFFERS
|
||||
{
|
||||
//
|
||||
X121_XMAS_UPPER_LINE = 0,
|
||||
X121_XMAS_MID_LINE = 1,
|
||||
X121_XMAS_LOWER_LINE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct X121XMASInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
int length; // MA Length
|
||||
ENUM_MA_METHOD method; // MA Method
|
||||
ENUM_APPLIED_PRICE upperAppliedTo; // Upper Applied To
|
||||
ENUM_APPLIED_PRICE midAppliedTo; // Mid Applied To
|
||||
ENUM_APPLIED_PRICE lowerAppliedTo; // Lower Applied To
|
||||
|
||||
//
|
||||
int startCalculationForLastBars; // Calculate Last n Bars
|
||||
bool showUpper; // Show Upper
|
||||
bool showMid; // Show Mid
|
||||
bool showLower; // Show Lower
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
X121XMASInputs()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0; // MA Length
|
||||
method = MODE_EMA; // MA Method
|
||||
upperAppliedTo = PRICE_HIGH; // Upper Applied To
|
||||
midAppliedTo = PRICE_MEDIAN; // Mid Applied To
|
||||
lowerAppliedTo = PRICE_LOW; // Lower Applied To
|
||||
|
||||
//
|
||||
startCalculationForLastBars = 0; // Calculate Last n Bars
|
||||
showUpper = false; // Show Upper
|
||||
showMid = false; // Show Mid
|
||||
showLower = false; // Show Lower
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 14; // MA Length
|
||||
method = MODE_EMA; // MA Method
|
||||
upperAppliedTo = PRICE_HIGH; // Upper Applied To
|
||||
midAppliedTo = PRICE_MEDIAN; // Mid Applied To
|
||||
lowerAppliedTo = PRICE_LOW; // Lower Applied To
|
||||
|
||||
//
|
||||
startCalculationForLastBars = 1000; // Calculate Last n Bars
|
||||
showUpper = true; // Show Upper
|
||||
showMid = true; // Show Mid
|
||||
showLower = true; // Show Lower
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
struct X121XMASConditions
|
||||
{
|
||||
//
|
||||
// Common ...
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double upperBuffer[];
|
||||
double midBuffer[];
|
||||
double lowerBuffer[];
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
X121XMASConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleaning Up ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Commons ...
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
time = NULL;
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
Clean(upperBuffer);
|
||||
Clean(midBuffer);
|
||||
Clean(lowerBuffer);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(upperBuffer, true);
|
||||
ArraySetAsSeries(midBuffer, true);
|
||||
ArraySetAsSeries(lowerBuffer, true);
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Conditions Scores ...
|
||||
*
|
||||
* @param bullishScore: Double, Directional Scores Reference ...
|
||||
* @param bearishScore: Double, Directional Scores Reference ...
|
||||
*/
|
||||
void GenerateScore(
|
||||
double &bullishScore,
|
||||
double &bearishScore //
|
||||
)
|
||||
{
|
||||
//
|
||||
bullishScore = 0;
|
||||
bearishScore = 0;
|
||||
|
||||
//
|
||||
// TODO: Implement if Required ...
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Summary String for Represent Conditions State ...
|
||||
*
|
||||
* @param onlyCommons: Boolean, Just Generate Only Commons Conditions ...
|
||||
* @param onlyConditions: Boolean, Just Generate Only Conditions ...
|
||||
* @param includeScores: Boolean, Attach Scores Representations on Result ...
|
||||
* @param ignoreFalseConditions: Boolean, Ignore False Conditions on Result ...
|
||||
* @param separator: String, Separate Lines ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GenerateSummary(
|
||||
bool onlyCommons = false,
|
||||
bool onlyConditions = false,
|
||||
bool includeScores = true,
|
||||
bool ignoreFalseConditions = true,
|
||||
string separator = "\n" //
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
|
||||
//
|
||||
string scoresStr =
|
||||
//
|
||||
"Scores: " + separator +
|
||||
"---------------" + separator +
|
||||
"Bullish: " + ToString(bullishScore) + separator +
|
||||
"Bearish: " + ToString(bearishScore) + separator +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
string commonStr = GenerateSpecifiedCommonSummary(
|
||||
this,
|
||||
separator,
|
||||
includeScores //
|
||||
);
|
||||
|
||||
//
|
||||
string conditionsStr =
|
||||
//
|
||||
//
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
"[" + GetTag() + "]" + separator +
|
||||
(onlyConditions
|
||||
? ""
|
||||
: commonStr) +
|
||||
(!includeScores
|
||||
? ""
|
||||
: scoresStr) +
|
||||
" " + separator +
|
||||
(onlyCommons
|
||||
? ""
|
||||
: conditionsStr) +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve nique Tag Identifier ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetTag()
|
||||
{
|
||||
return GetTypeName(this);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XCX121XMASHelper : public XCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XCX121XMASHelper()
|
||||
: XCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XCX121XMASHelper()
|
||||
{
|
||||
//
|
||||
mInputs.Clean();
|
||||
|
||||
//
|
||||
Clean(upperBuffer);
|
||||
Clean(midBuffer);
|
||||
Clean(lowerBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
X121XMASInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ArraySetAsSeries(upperBuffer, true);
|
||||
ArraySetAsSeries(midBuffer, true);
|
||||
ArraySetAsSeries(lowerBuffer, true);
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.x121.xmas",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.length,
|
||||
mInputs.method,
|
||||
mInputs.upperAppliedTo,
|
||||
mInputs.midAppliedTo,
|
||||
mInputs.lowerAppliedTo,
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
//
|
||||
mInputs.startCalculationForLastBars,
|
||||
//
|
||||
mInputs.showUpper,
|
||||
mInputs.showMid,
|
||||
mInputs.showLower
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
X121XMASInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
X121XMASInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Readers ...
|
||||
|
||||
//
|
||||
// Upper ...
|
||||
|
||||
//
|
||||
double GetUpper(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate(barIndex);
|
||||
|
||||
//
|
||||
int count = ArraySize(upperBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return upperBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
int CopyUpper(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate(start);
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
0,
|
||||
count,
|
||||
upperBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Mid ...
|
||||
|
||||
//
|
||||
double GetUMid(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate(barIndex);
|
||||
|
||||
//
|
||||
int count = ArraySize(midBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return midBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
int CopyMid(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate(start);
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
0,
|
||||
count,
|
||||
midBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
|
||||
//
|
||||
double GetULower(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate(barIndex);
|
||||
|
||||
//
|
||||
int count = ArraySize(lowerBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lowerBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
int CopyLower(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate(start);
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
0,
|
||||
count,
|
||||
lowerBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
void Free() override
|
||||
{
|
||||
Cleanup(10);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetConditions(
|
||||
X121XMASConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
if (loopback < 5)
|
||||
{
|
||||
loopback = 5;
|
||||
}
|
||||
|
||||
//
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
conditions.symbol = mSymbol;
|
||||
conditions.period = mPeriod;
|
||||
conditions.time = TimeCurrent();
|
||||
|
||||
//
|
||||
int zIndex = barIndex;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
result = zBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
zIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
result = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
cIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
result = pBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
pIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
CopyUpper(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.upperBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
CopyMid(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.midBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
CopyLower(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.lowerBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
int cIDX = 1;
|
||||
int pIDX = cIDX + 1;
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
|
||||
//
|
||||
Cleanup();
|
||||
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
X121XMASInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double upperBuffer[];
|
||||
double midBuffer[];
|
||||
double lowerBuffer[];
|
||||
|
||||
//
|
||||
void Calculate(
|
||||
int barIndex = 0,
|
||||
int maxRequiredBars = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Buffers ...
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// FAST ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X121_XMAS_UPPER_LINE,
|
||||
barIndex,
|
||||
maxRequiredBars,
|
||||
upperBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// FAST STATE ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X121_XMAS_MID_LINE,
|
||||
barIndex,
|
||||
maxRequiredBars,
|
||||
midBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// MID ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X121_XMAS_LOWER_LINE,
|
||||
barIndex,
|
||||
maxRequiredBars,
|
||||
lowerBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
void Cleanup(
|
||||
int maxAllowed = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
upperBuffer,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
CleanupArray(
|
||||
midBuffer,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
CleanupArray(
|
||||
lowerBuffer,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user