last ...
This commit is contained in:
@@ -1755,24 +1755,27 @@ class XCSignalObject : public XCBaseObject
|
||||
*/
|
||||
bool Create(
|
||||
long chart_id,
|
||||
const string name,
|
||||
const int window,
|
||||
XSignal &signal //
|
||||
XSignal &signal,
|
||||
string prefix = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid(name) &&
|
||||
signal
|
||||
.IsValid();
|
||||
result = signal.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string name = signal.GetTag();
|
||||
if (IsValid(prefix))
|
||||
{
|
||||
name = prefix + "_" + name;
|
||||
}
|
||||
string nameMD5 = ToMD5(name);
|
||||
|
||||
//
|
||||
|
||||
@@ -2487,12 +2487,6 @@ class XCPOIDrawer : public XCBase
|
||||
long chartID = ChartIdentification();
|
||||
int window = SubWindowIdentification();
|
||||
|
||||
//
|
||||
// bool fill = BearishFVGFill();
|
||||
// int width = BearishFVGWidth();
|
||||
// color crl = BearishFVGColor();
|
||||
// ENUM_LINE_STYLE style = BearishFVGStyle();
|
||||
|
||||
//
|
||||
object = new XCTicksZoneObject();
|
||||
result = object.Create(
|
||||
@@ -2513,6 +2507,49 @@ class XCPOIDrawer : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Consolidation Zone Object ...
|
||||
*
|
||||
* @param zone: XConsolidationZone instance Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool CreateConsolidationZone(
|
||||
XConsolidationZone &zone,
|
||||
XCConsolidationZoneObject *&object //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
object = NULL;
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string prefix = Prefix();
|
||||
long chartID = ChartIdentification();
|
||||
int window = SubWindowIdentification();
|
||||
|
||||
//
|
||||
object = new XCConsolidationZoneObject();
|
||||
result = object.Create(
|
||||
chartID,
|
||||
window,
|
||||
zone,
|
||||
prefix //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw Specified Signal ...
|
||||
*
|
||||
@@ -2537,13 +2574,17 @@ class XCPOIDrawer : public XCBase
|
||||
}
|
||||
|
||||
//
|
||||
string name = signal.GetTag();
|
||||
string prefix = Prefix();
|
||||
long chartID = ChartIdentification();
|
||||
int window = SubWindowIdentification();
|
||||
|
||||
//
|
||||
object = new XCSignalObject();
|
||||
result = object.Create(
|
||||
ChartIdentification(),
|
||||
name,
|
||||
SubWindowIdentification(),
|
||||
signal //
|
||||
chartID,
|
||||
window,
|
||||
signal,
|
||||
prefix //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
@@ -3155,14 +3196,20 @@ class XCPOIDrawer : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string prefix = Prefix();
|
||||
long chartID = ChartIdentification();
|
||||
int window = SubWindowIdentification();
|
||||
|
||||
//
|
||||
// Draw Pivot it self ...
|
||||
XCXPVPivotObject *iPivotObj;
|
||||
iPivotObj = new XCXPVPivotObject();
|
||||
bool isCreated = iPivotObj.Create(
|
||||
ChartIdentification(),
|
||||
SubWindowIdentification(),
|
||||
pivot //
|
||||
chartID,
|
||||
window,
|
||||
pivot,
|
||||
prefix //
|
||||
);
|
||||
if (!isCreated)
|
||||
{
|
||||
|
||||
@@ -1,758 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCX3MAHelper
|
||||
// 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_X3MA_BUFFERS
|
||||
{
|
||||
//
|
||||
X3MA_FAST_LINE = 0,
|
||||
X3MA_MID_LINE = 1,
|
||||
X3MA_SLOW_LINE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct X3MAInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
int fastLength; // Fast Length
|
||||
int midLength; // Mid Length
|
||||
int slowLength; // Slow Length
|
||||
int shiftLength; // Shift
|
||||
ENUM_MA_METHOD method; // Mode
|
||||
ENUM_APPLIED_PRICE appliedTo; // Applied To
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
|
||||
//
|
||||
bool showFast; // Show Fast
|
||||
bool showMid; // Show Mid
|
||||
bool showSlow; // Show Slow
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
X3MAInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
fastLength = 0;
|
||||
midLength = 0;
|
||||
slowLength = 0;
|
||||
shiftLength = 0;
|
||||
method = MODE_SMA;
|
||||
appliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
showFast = false;
|
||||
showMid = false;
|
||||
showSlow = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
fastLength = 50;
|
||||
midLength = 100;
|
||||
slowLength = 200;
|
||||
shiftLength = 0;
|
||||
method = MODE_SMA;
|
||||
appliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
showFast = true;
|
||||
showMid = true;
|
||||
showSlow = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
fastLength > 2 &&
|
||||
midLength > fastLength &&
|
||||
slowLength > midLength &&
|
||||
//
|
||||
shiftLength >= 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(fastLength, midLength);
|
||||
result = MathMax(result, slowLength);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Define Conditions ...
|
||||
struct X3MAConditions
|
||||
{
|
||||
//
|
||||
// Common ...
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double fasts[];
|
||||
double mids[];
|
||||
double slows[];
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
bool isFastOverMid;
|
||||
bool isMidOverSlow;
|
||||
|
||||
//
|
||||
bool isFastUnderMid;
|
||||
bool isMidUnderSlow;
|
||||
|
||||
//
|
||||
bool isBullishOrdered;
|
||||
bool isBearishOrdered;
|
||||
|
||||
//
|
||||
bool isSwitchedToBullishOrdered;
|
||||
bool isSwitchedToBearishOrdered;
|
||||
|
||||
//
|
||||
void X3MAConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
Clean(fasts);
|
||||
Clean(mids);
|
||||
Clean(slows);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(fasts, true);
|
||||
ArraySetAsSeries(mids, true);
|
||||
ArraySetAsSeries(slows, true);
|
||||
|
||||
//
|
||||
isFastOverMid = false;
|
||||
isMidOverSlow = false;
|
||||
isFastUnderMid = false;
|
||||
isMidUnderSlow = false;
|
||||
isBullishOrdered = false;
|
||||
isBearishOrdered = false;
|
||||
isSwitchedToBullishOrdered = false;
|
||||
isSwitchedToBearishOrdered = false;
|
||||
}
|
||||
|
||||
//
|
||||
void GenerateScore(
|
||||
double &bullishScore,
|
||||
double &bearishScore //
|
||||
)
|
||||
{
|
||||
//
|
||||
bullishScore = 0;
|
||||
bearishScore = 0;
|
||||
|
||||
//
|
||||
// Since We have to Use this
|
||||
// Only for Filtering Signals ...
|
||||
// We Can Ignore Scoring ...
|
||||
// or Complete this later ...
|
||||
}
|
||||
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
string GetTag()
|
||||
{
|
||||
return "X3MA";
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XCX3MAHelper : public XCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XCX3MAHelper()
|
||||
: XCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XCX3MAHelper()
|
||||
{
|
||||
//
|
||||
Clean(fastBuffer);
|
||||
Clean(midBuffer);
|
||||
Clean(slowBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
X3MAInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(fastBuffer, true);
|
||||
ArraySetAsSeries(midBuffer, true);
|
||||
ArraySetAsSeries(slowBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.x3ma",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.fastLength,
|
||||
mInputs.midLength,
|
||||
mInputs.slowLength,
|
||||
mInputs.shiftLength,
|
||||
mInputs.method,
|
||||
mInputs.appliedTo,
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
//
|
||||
mInputs.showFast,
|
||||
mInputs.showMid,
|
||||
mInputs.showSlow
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
X3MAInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
X3MAInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetFast(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(fastBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return fastBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyFast(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
fastBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetMid(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(midBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return midBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
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();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
midBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetSlow(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(slowBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return slowBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopySlow(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
slowBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
bool GetConditions(
|
||||
X3MAConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
if (loopback < 3)
|
||||
{
|
||||
loopback = 3;
|
||||
}
|
||||
|
||||
//
|
||||
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 ...
|
||||
|
||||
//
|
||||
// Fast ...
|
||||
CopyFast(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.fasts //
|
||||
);
|
||||
|
||||
//
|
||||
// Mid ...
|
||||
CopyMid(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.mids //
|
||||
);
|
||||
|
||||
//
|
||||
// Slow ...
|
||||
CopySlow(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.slows //
|
||||
);
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
bool isFastOverMid =
|
||||
conditions.fasts[cIndex] > conditions.mids[cIndex];
|
||||
bool isFastOverMidPrev =
|
||||
conditions.fasts[pIndex] > conditions.mids[pIndex];
|
||||
|
||||
//
|
||||
bool isMidOverSlow =
|
||||
conditions.mids[cIndex] > conditions.slows[cIndex];
|
||||
bool isMidOverSlowPrev =
|
||||
conditions.mids[pIndex] > conditions.slows[pIndex];
|
||||
|
||||
//
|
||||
bool isFastUnderMid =
|
||||
conditions.fasts[cIndex] < conditions.mids[cIndex];
|
||||
bool isFastUnderMidPrev =
|
||||
conditions.fasts[pIndex] < conditions.mids[pIndex];
|
||||
|
||||
//
|
||||
bool isMidUnderSlow =
|
||||
conditions.mids[cIndex] < conditions.slows[cIndex];
|
||||
bool isMidUnderSlowPrev =
|
||||
conditions.mids[pIndex] < conditions.slows[pIndex];
|
||||
|
||||
//
|
||||
bool isBullishOrdered = isFastOverMid &&
|
||||
isMidOverSlow;
|
||||
bool isBullishOrderedPrev = isFastOverMidPrev &&
|
||||
isMidOverSlowPrev;
|
||||
|
||||
//
|
||||
bool isBearishOrdered = isFastUnderMid &&
|
||||
isMidUnderSlow;
|
||||
bool isBearishOrderedPrev = isFastUnderMidPrev &&
|
||||
isMidUnderSlowPrev;
|
||||
|
||||
//
|
||||
bool isSwitchedToBullishOrdered = isBullishOrdered &&
|
||||
!isBullishOrderedPrev;
|
||||
bool isSwitchedToBearishOrdered = isBearishOrdered &&
|
||||
!isBearishOrderedPrev;
|
||||
|
||||
//
|
||||
conditions.isFastOverMid = isFastOverMid;
|
||||
conditions.isMidOverSlow = isMidOverSlow;
|
||||
conditions.isFastUnderMid = isFastUnderMid;
|
||||
conditions.isMidUnderSlow = isMidUnderSlow;
|
||||
conditions.isBullishOrdered = isBullishOrdered;
|
||||
conditions.isBearishOrdered = isBearishOrdered;
|
||||
conditions.isSwitchedToBullishOrdered = isSwitchedToBullishOrdered;
|
||||
conditions.isSwitchedToBearishOrdered = isSwitchedToBearishOrdered;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
X3MAInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double fastBuffer[];
|
||||
double midBuffer[];
|
||||
double slowBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
if (totalBars > 1000)
|
||||
{
|
||||
totalBars = 1000;
|
||||
}
|
||||
|
||||
//
|
||||
// Fast ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X3MA_FAST_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
fastBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Mid ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X3MA_MID_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
midBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Slow ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X3MA_SLOW_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
slowBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
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
@@ -122,6 +122,9 @@ struct X121SMCStrategyXTWPVSignalConditions
|
||||
double point;
|
||||
XPVPivot pivot;
|
||||
|
||||
//
|
||||
XConsolidationZone consolidationZone;
|
||||
|
||||
//
|
||||
string method;
|
||||
|
||||
@@ -256,6 +259,7 @@ struct X121SMCStrategyXTWPVSignalConditions
|
||||
//
|
||||
point = 0;
|
||||
pivot.Clean();
|
||||
consolidationZone.Clean();
|
||||
|
||||
//
|
||||
method = NULL;
|
||||
@@ -419,6 +423,16 @@ struct X121SMCStrategyXTWPVSignalConditions
|
||||
return pivot.IsValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Model Has Consolidation Zone or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasConsolidationZone()
|
||||
{
|
||||
return consolidationZone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
@@ -515,14 +529,6 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
double llDown = cBar.FindLowesttDown(swingLoopback);
|
||||
double hhUp = cBar.FindHighestUp(swingLoopback);
|
||||
|
||||
//
|
||||
int zoneValidationDivider = 10;
|
||||
int validPivotRepetition = triggerCycleHelper.mX121Helper
|
||||
.GetDonChainLength();
|
||||
|
||||
//
|
||||
double selectedSL = 0;
|
||||
|
||||
//
|
||||
// Cycles Conditions ...
|
||||
|
||||
@@ -640,36 +646,43 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
//
|
||||
// Setup Conditions ...
|
||||
|
||||
// //
|
||||
// // Select Sources ...
|
||||
// XC121SMCCycleHelper *helper = analyseCycleHelper;
|
||||
// X121SMCCycleConditions helperConditions = analyseConditions;
|
||||
// XPOIState helperState = analyseState;
|
||||
|
||||
//
|
||||
// Select Sources ...
|
||||
XC121SMCCycleHelper *helper = analyseCycleHelper;
|
||||
X121SMCCycleConditions helperConditions = analyseConditions;
|
||||
XPOIState helperState = analyseState;
|
||||
|
||||
//
|
||||
// Instance Helper CBar ...
|
||||
XOHCL helperCBar;
|
||||
result = helper.GetBar(
|
||||
XOHCL analyseCBar;
|
||||
result = analyseCycleHelper.GetBar(
|
||||
cBar,
|
||||
helperCBar //
|
||||
analyseCBar //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL analysePBar;
|
||||
result = analyseCBar.GetPreviousBar(analysePBar);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double bullishFib = GetFibonacciLevel(
|
||||
helperCBar.high,
|
||||
helperCBar.low,
|
||||
analyseCBar.high,
|
||||
analyseCBar.low,
|
||||
GetFiboLevelValue(X_FIBO_LEVEL_382),
|
||||
-1 //
|
||||
);
|
||||
|
||||
//
|
||||
double bearishFib = GetFibonacciLevel(
|
||||
helperCBar.high,
|
||||
helperCBar.low,
|
||||
analyseCBar.high,
|
||||
analyseCBar.low,
|
||||
GetFiboLevelValue(X_FIBO_LEVEL_382),
|
||||
1 //
|
||||
);
|
||||
@@ -705,12 +718,12 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
|
||||
//
|
||||
XPVPivot peakPivot;
|
||||
bool hasPeakPivot = helper
|
||||
bool hasPeakPivot = analyseCycleHelper
|
||||
.GetActivePeakPivot(peakPivot);
|
||||
|
||||
//
|
||||
XPVPivot valePivot;
|
||||
bool hasValePivot = helper
|
||||
bool hasValePivot = analyseCycleHelper
|
||||
.GetActiveValePivot(valePivot);
|
||||
|
||||
//
|
||||
@@ -755,7 +768,7 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
{
|
||||
//
|
||||
conditions.pivot.to = cTime;
|
||||
helper.FillPivotState(conditions.pivot);
|
||||
analyseCycleHelper.FillPivotState(conditions.pivot);
|
||||
|
||||
//
|
||||
// Check Pivot Renewation ...
|
||||
@@ -886,24 +899,24 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
// PV Conditions ...
|
||||
|
||||
//
|
||||
double peak = helperConditions.x121Conditions.peaksBuffer[1];
|
||||
double peakPrev = helperConditions.x121Conditions.peaksBuffer[2];
|
||||
double peakDiff = MathAbs(peakPrev - peak);
|
||||
double analysePeak = analyseConditions.x121Conditions.peaksBuffer[1];
|
||||
double analysePeakPrev = analyseConditions.x121Conditions.peaksBuffer[2];
|
||||
double analysePeakDiff = MathAbs(analysePeakPrev - analysePeak);
|
||||
|
||||
//
|
||||
bool isNewPeak = helperConditions.x121Conditions.isNewPeak;
|
||||
bool isNewPeakOverLast = helperConditions.x121Conditions.isNewPeakOverLast;
|
||||
bool isNewPeakUnderLast = helperConditions.x121Conditions.isNewPeakUnderLast;
|
||||
bool isNewAnalysePeak = analyseConditions.x121Conditions.isNewPeak;
|
||||
bool isNewAnalysePeakOverLast = analyseConditions.x121Conditions.isNewPeakOverLast;
|
||||
bool isNewAnalysePeakUnderLast = analyseConditions.x121Conditions.isNewPeakUnderLast;
|
||||
|
||||
//
|
||||
double vale = helperConditions.x121Conditions.valesBuffer[1];
|
||||
double valePrev = helperConditions.x121Conditions.valesBuffer[2];
|
||||
double valeDiff = MathAbs(valePrev - vale);
|
||||
double analyseVale = analyseConditions.x121Conditions.valesBuffer[1];
|
||||
double analyseValePrev = analyseConditions.x121Conditions.valesBuffer[2];
|
||||
double analyseValeDiff = MathAbs(analyseValePrev - analyseVale);
|
||||
|
||||
//
|
||||
bool isNewVale = helperConditions.x121Conditions.isNewVale;
|
||||
bool isNewValeOverLast = helperConditions.x121Conditions.isNewValeOverLast;
|
||||
bool isNewValeUnderLast = helperConditions.x121Conditions.isNewValeUnderLast;
|
||||
bool isNewAnalyseVale = analyseConditions.x121Conditions.isNewVale;
|
||||
bool isNewAnalyseValeOverLast = analyseConditions.x121Conditions.isNewValeOverLast;
|
||||
bool isNewAnalyseValeUnderLast = analyseConditions.x121Conditions.isNewValeUnderLast;
|
||||
|
||||
//
|
||||
double triggerPeak = triggerConditions.x121Conditions.peaksBuffer[1];
|
||||
@@ -911,19 +924,19 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
|
||||
//
|
||||
int condition2MinPVDiffPoint = 30;
|
||||
bool isPeakDiffPointPassed = peakDiff >= (condition2MinPVDiffPoint * points);
|
||||
bool isValeDiffPointPassed = valeDiff >= (condition2MinPVDiffPoint * points);
|
||||
bool isPeakDiffPointPassed = analysePeakDiff >= (condition2MinPVDiffPoint * points);
|
||||
bool isValeDiffPointPassed = analyseValeDiff >= (condition2MinPVDiffPoint * points);
|
||||
|
||||
//
|
||||
// DONCHAIN Conditions ...
|
||||
|
||||
//
|
||||
double donCloseUpper = helperConditions.x121Conditions.donCloseUpperBuffer[1];
|
||||
double donCloseLower = helperConditions.x121Conditions.donCloseLowerBuffer[1];
|
||||
// //
|
||||
// double analyseDonCloseUpper = analyseConditions.x121Conditions.donCloseUpperBuffer[1];
|
||||
// double analyseDonCloseLower = analyseConditions.x121Conditions.donCloseLowerBuffer[1];
|
||||
|
||||
//
|
||||
double donOpenUpper = helperConditions.x121Conditions.donOpenUpperBuffer[1];
|
||||
double donOpenLower = helperConditions.x121Conditions.donOpenLowerBuffer[1];
|
||||
// //
|
||||
// double analyseonOpenUpper = analyseConditions.x121Conditions.donOpenUpperBuffer[1];
|
||||
// double analyseonOpenLower = analyseConditions.x121Conditions.donOpenLowerBuffer[1];
|
||||
|
||||
//
|
||||
// OPEN ...
|
||||
@@ -1029,12 +1042,12 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (isRejectDonUpper ||
|
||||
isRejectDonLower)
|
||||
{
|
||||
Print("Don Rejected ...");
|
||||
}
|
||||
// //
|
||||
// if (isRejectDonUpper ||
|
||||
// isRejectDonLower)
|
||||
// {
|
||||
// Print("Don Rejected ...");
|
||||
// }
|
||||
|
||||
//
|
||||
bool isBreakedDonUpper =
|
||||
@@ -1073,12 +1086,12 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
//
|
||||
// false
|
||||
hasBullishTrend &&
|
||||
isNewPeakOverLast &&
|
||||
isBullishFiboPassed &&
|
||||
helperCBar.IsBullish() &&
|
||||
conditions.pivot.upper < peak &&
|
||||
conditions.pivot.upper < helperCBar.GetUp() &&
|
||||
conditions.pivot.upper > helperCBar.GetDown()
|
||||
analyseCBar.IsBullish() &&
|
||||
isNewAnalysePeakOverLast &&
|
||||
conditions.pivot.upper < analysePeak &&
|
||||
conditions.pivot.upper < analyseCBar.GetUp() &&
|
||||
conditions.pivot.upper > analyseCBar.GetDown()
|
||||
//
|
||||
;
|
||||
if (bullishConditions1)
|
||||
@@ -1094,12 +1107,12 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
//
|
||||
// false
|
||||
hasBearishTrend &&
|
||||
isNewValeUnderLast &&
|
||||
isBearishFiboPassed &&
|
||||
helperCBar.IsBearish() &&
|
||||
conditions.pivot.lower > vale &&
|
||||
conditions.pivot.lower < helperCBar.GetUp() &&
|
||||
conditions.pivot.lower > helperCBar.GetDown()
|
||||
analyseCBar.IsBearish() &&
|
||||
isNewAnalyseValeUnderLast &&
|
||||
conditions.pivot.lower > analyseVale &&
|
||||
conditions.pivot.lower < analyseCBar.GetUp() &&
|
||||
conditions.pivot.lower > analyseCBar.GetDown()
|
||||
//
|
||||
;
|
||||
if (bearishConditions1)
|
||||
@@ -1126,7 +1139,7 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
if (bullishConditions2)
|
||||
{
|
||||
//
|
||||
conditions.point = vale;
|
||||
conditions.point = analyseVale;
|
||||
conditions.method = ToString(X_X121SMC_XTWPV_METHOD_2);
|
||||
}
|
||||
|
||||
@@ -1144,7 +1157,7 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
if (bearishConditions2)
|
||||
{
|
||||
//
|
||||
conditions.point = peak;
|
||||
conditions.point = analysePeak;
|
||||
conditions.method = ToString(X_X121SMC_XTWPV_METHOD_2);
|
||||
}
|
||||
|
||||
@@ -1161,7 +1174,7 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
if (bullishConditions3)
|
||||
{
|
||||
//
|
||||
conditions.point = vale;
|
||||
conditions.point = analyseVale;
|
||||
conditions.method = ToString(X_X121SMC_XTWPV_METHOD_3);
|
||||
}
|
||||
|
||||
@@ -1175,7 +1188,7 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
if (bearishConditions3)
|
||||
{
|
||||
//
|
||||
conditions.point = peak;
|
||||
conditions.point = analysePeak;
|
||||
conditions.method = ToString(X_X121SMC_XTWPV_METHOD_3);
|
||||
}
|
||||
|
||||
@@ -1306,22 +1319,30 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
result = pBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
pIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double ask = GetAsk(symbol);
|
||||
double bid = GetBid(symbol);
|
||||
datetime cTime = TimeCurrent();
|
||||
double points = GetPoints(symbol);
|
||||
|
||||
//
|
||||
double ll = cBar.FindLowest(9, MODE_LOW);
|
||||
double hh = cBar.FindHighest(9, MODE_HIGH);
|
||||
|
||||
//
|
||||
int zoneValidationDivider = 10;
|
||||
int validPivotRepetition = triggerCycleHelper.mX121Helper
|
||||
.GetDonChainLength();
|
||||
|
||||
//
|
||||
double selectedSL = 0;
|
||||
int swingLoopback = 9;
|
||||
double ll = cBar.FindLowest(swingLoopback, MODE_LOW);
|
||||
double hh = cBar.FindHighest(swingLoopback, MODE_HIGH);
|
||||
double llDown = cBar.FindLowesttDown(swingLoopback);
|
||||
double hhUp = cBar.FindHighestUp(swingLoopback);
|
||||
|
||||
//
|
||||
// Cycles Conditions ...
|
||||
@@ -1471,21 +1492,30 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
||||
|
||||
//
|
||||
// Detect Consolidation ...
|
||||
XConsolidationZone consolidationZone;
|
||||
bool hasConsolidationZone = triggerCycleHelper
|
||||
.GetLastConsolidationZone(consolidationZone);
|
||||
bool hasConsolidationZone = conditions.HasConsolidationZone();
|
||||
if (hasConsolidationZone)
|
||||
{
|
||||
//
|
||||
hasConsolidationZone =
|
||||
isBullish
|
||||
? consolidationZone.upper <= conditions.point
|
||||
: consolidationZone.lower >= conditions.point;
|
||||
hasConsolidationZone = triggerCycleHelper
|
||||
.GetLastConsolidationZone(conditions.consolidationZone);
|
||||
|
||||
//
|
||||
if (!hasConsolidationZone)
|
||||
if (hasConsolidationZone)
|
||||
{
|
||||
consolidationZone.Clean();
|
||||
//
|
||||
hasConsolidationZone =
|
||||
isBullish
|
||||
? conditions.consolidationZone.upper <= conditions.point
|
||||
: conditions.consolidationZone.lower >= conditions.point;
|
||||
|
||||
//
|
||||
if (!hasConsolidationZone)
|
||||
{
|
||||
//
|
||||
conditions
|
||||
.consolidationZone
|
||||
.Clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1551,9 +1581,6 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
||||
Opposit(setupDir) //
|
||||
);
|
||||
|
||||
//
|
||||
double points = GetPoints(conditions.symbol);
|
||||
|
||||
//
|
||||
double entry = GetEntry(
|
||||
conditions.symbol,
|
||||
@@ -1569,14 +1596,14 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
||||
if (isBullish)
|
||||
{
|
||||
Add(
|
||||
consolidationZone.lower,
|
||||
conditions.consolidationZone.lower,
|
||||
sls //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Add(
|
||||
consolidationZone.upper,
|
||||
conditions.consolidationZone.upper,
|
||||
sls //
|
||||
);
|
||||
}
|
||||
|
||||
@@ -281,6 +281,16 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
result = PrepareSignal(signal);
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// TODO: Remove this ...
|
||||
XCSignalObject *iObj;
|
||||
mPOIDrawer.DrawSignal(signal, iObj);
|
||||
Print("");
|
||||
}
|
||||
|
||||
//
|
||||
hasLong = false;
|
||||
hasShort = false;
|
||||
@@ -712,56 +722,74 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
// Handle Required Drawings ...
|
||||
bool hasPivot = mXTWPVConditions.HasPivot();
|
||||
bool hasPriceInsideZone = mXTWPVConditions.HasPriceInsideZones();
|
||||
bool hasConsolidationZone = mXTWPVConditions.HasConsolidationZone();
|
||||
bool canDraw = hasPivot ||
|
||||
hasPriceInsideZone;
|
||||
hasPriceInsideZone ||
|
||||
hasConsolidationZone;
|
||||
if (canDraw)
|
||||
{
|
||||
// //
|
||||
// ClearDraws();
|
||||
//
|
||||
ClearDraws();
|
||||
|
||||
// //
|
||||
// // Draw Pivot Zone ...
|
||||
// if (hasPivot)
|
||||
// {
|
||||
// //
|
||||
// XCBaseObject *drawnObjects[];
|
||||
// int drawnObjectsCount = DrawXTWPVPivotZone(
|
||||
// mXTWPVConditions,
|
||||
// mPOIDrawer,
|
||||
// drawnObjects,
|
||||
// true, // Draw State ...
|
||||
// true, // Draw Ticks Zone ...
|
||||
// true, // Ignore SwingHighs ...
|
||||
// true, // Ignore SwingLows ...
|
||||
// true, // Ignore SupportZones ...
|
||||
// true, // Ignore ResistanceZones ...
|
||||
// true, // Ignore SupplyZones ...
|
||||
// true, // Ignore DemandZones ...
|
||||
// true, // Ignore BullishOrderBlocks ...
|
||||
// true, // Ignore BearishOrderBlocks ...
|
||||
// true, // Ignore BullishFairValueGaps ...
|
||||
// true, // Ignore BearishFairValueGaps ...
|
||||
// true, // Ignore BullishRejectionBars ...
|
||||
// true, // Ignore BearishRejectionBars ...
|
||||
// true, // Ignore BullishMomentumBars ...
|
||||
// true // Ignore BearishMomentumBars ...
|
||||
// );
|
||||
// AddObjectsIfNotExists(drawnObjects);
|
||||
// }
|
||||
//
|
||||
// Draw Consolidation Zone ...
|
||||
if (hasConsolidationZone)
|
||||
{
|
||||
//
|
||||
XCConsolidationZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer.CreateConsolidationZone(
|
||||
mXTWPVConditions.consolidationZone,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
AddObjectIfNotExists(iObj);
|
||||
}
|
||||
}
|
||||
|
||||
// //
|
||||
// // Draw Price Inside Zones ...
|
||||
// if (hasPriceInsideZone)
|
||||
// {
|
||||
// //
|
||||
// XCBaseObject *drawnObjects[];
|
||||
// int drawnObjectsCount = DrawTWPVPriceInsideZones(
|
||||
// mXTWPVConditions,
|
||||
// mPOIDrawer,
|
||||
// drawnObjects //
|
||||
// );
|
||||
// AddObjectsIfNotExists(drawnObjects);
|
||||
// }
|
||||
//
|
||||
// Draw Pivot Zone ...
|
||||
if (hasPivot)
|
||||
{
|
||||
//
|
||||
XCBaseObject *drawnObjects[];
|
||||
int drawnObjectsCount = DrawXTWPVPivotZone(
|
||||
mXTWPVConditions,
|
||||
mPOIDrawer,
|
||||
drawnObjects,
|
||||
false, // Draw State ...
|
||||
false, // Draw Ticks Zone ...
|
||||
true, // Ignore SwingHighs ...
|
||||
true, // Ignore SwingLows ...
|
||||
true, // Ignore SupportZones ...
|
||||
true, // Ignore ResistanceZones ...
|
||||
true, // Ignore SupplyZones ...
|
||||
true, // Ignore DemandZones ...
|
||||
true, // Ignore BullishOrderBlocks ...
|
||||
true, // Ignore BearishOrderBlocks ...
|
||||
true, // Ignore BullishFairValueGaps ...
|
||||
true, // Ignore BearishFairValueGaps ...
|
||||
true, // Ignore BullishRejectionBars ...
|
||||
true, // Ignore BearishRejectionBars ...
|
||||
true, // Ignore BullishMomentumBars ...
|
||||
true // Ignore BearishMomentumBars ...
|
||||
);
|
||||
AddObjectsIfNotExists(drawnObjects);
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Price Inside Zones ...
|
||||
if (hasPriceInsideZone)
|
||||
{
|
||||
//
|
||||
XCBaseObject *drawnObjects[];
|
||||
int drawnObjectsCount = DrawTWPVPriceInsideZones(
|
||||
mXTWPVConditions,
|
||||
mPOIDrawer,
|
||||
drawnObjects //
|
||||
);
|
||||
AddObjectsIfNotExists(drawnObjects);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user