7731 lines
187 KiB
Plaintext
7731 lines
187 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Indicator
|
|
// -------------------------------------------------
|
|
// Name: XCXCAEAPOIDetector ...
|
|
// Description: Class for XCAEA POI Detector ...
|
|
//
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property library
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://saherelm.ir"
|
|
#property version "1.00"
|
|
#property description "SaherElm Class for XCAEA POI Detector"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5"
|
|
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
|
#include "../Helpers/xcaea.helper.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
enum ENUM_XCA_PIVOTS
|
|
{
|
|
XCA_NONE, // None
|
|
XCA_LL, // LowestLow
|
|
XCA_HH, // HighestHigh
|
|
XCA_KI, // KI
|
|
XCA_SWL, // SWL
|
|
XCA_SWH, // SWH
|
|
XCA_VALE, // VALE
|
|
XCA_PEAK, // PEAK
|
|
XCA_FVG_BULL, // FVGBull
|
|
XCA_FVG_BEAR, // FVGBear
|
|
XCA_RSI_COOS, // RSICOOS
|
|
XCA_RSI_CUOB, // RSICUOB
|
|
XCA_RSI_PEAK, // RSIPeak
|
|
XCA_RSI_VALE, // RSIVale
|
|
XCA_CCI_COOS, // CCICOOS
|
|
XCA_CCI_CUOB, // CCICUOB
|
|
XCA_CCI_PEAK, // CCIPeak
|
|
XCA_CCI_VALE, // CCIVale
|
|
XCA_KI_BULL, // KIBull
|
|
XCA_KI_BEAR, // KIBear
|
|
XCA_TKI_BULL, // TKIBull
|
|
XCA_TKI_BEAR, // TKIBear
|
|
XCA_PEAKSWHRES, // PeakSWHRes
|
|
XCA_VALESWLSUP, // ValeSWLSup
|
|
XCA_TREND_BULL, // TrendBull
|
|
XCA_TREND_BEAR, // TrendBear
|
|
XCA_TKITRND_BULL, // TKITRNDBull
|
|
XCA_TKITRND_BEAR, // TKITRNDBear
|
|
};
|
|
|
|
//
|
|
bool IsValid(ENUM_XCA_PIVOTS value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = value != XCA_NONE;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string ToString(ENUM_XCA_PIVOTS value)
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
result = EnumToString(value);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
struct XCAPivot
|
|
{
|
|
//
|
|
// Props ...
|
|
datetime to;
|
|
double value;
|
|
string symbol;
|
|
datetime from;
|
|
double reserve;
|
|
ENUM_XCA_PIVOTS type;
|
|
ENUM_TIMEFRAMES period;
|
|
|
|
//
|
|
double values[];
|
|
|
|
//
|
|
// Constructor ...
|
|
XCAPivot()
|
|
{
|
|
Default();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
/**
|
|
* Cleanup ...
|
|
*/
|
|
void Clean()
|
|
{
|
|
//
|
|
value = 0;
|
|
to = NULL;
|
|
reserve = 0;
|
|
from = NULL;
|
|
symbol = NULL;
|
|
period = NULL;
|
|
type = XCA_NONE;
|
|
|
|
//
|
|
Clean(values);
|
|
|
|
//
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
/**
|
|
* Default ...
|
|
*/
|
|
void Default()
|
|
{
|
|
//
|
|
value = 0;
|
|
to = NULL;
|
|
reserve = 0;
|
|
from = NULL;
|
|
symbol = NULL;
|
|
period = NULL;
|
|
type = XCA_NONE;
|
|
|
|
//
|
|
Clean(values);
|
|
|
|
//
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
/**
|
|
* Validate ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
from < to &&
|
|
value != 0 &&
|
|
IsValid(to) &&
|
|
IsValid(from) &&
|
|
IsValid(type) &&
|
|
IsValid(symbol) &&
|
|
IsValid(period);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Check a Model is Same as this or not ...
|
|
*
|
|
* @param pivot: XCAPivot ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool IsSameAs(XCAPivot &pivot)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
IsValid() &&
|
|
pivot.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
to == pivot.to &&
|
|
from == pivot.from &&
|
|
type == pivot.type &&
|
|
value == pivot.value &&
|
|
symbol == pivot.symbol &&
|
|
period == pivot.period;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieve To Index ...
|
|
*
|
|
* @param forPeriod: ENUM_TIMEFRAMES, Specified Period ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int ToIndex(
|
|
ENUM_TIMEFRAMES forPeriod = NULL //
|
|
)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (!IsValid(forPeriod))
|
|
{
|
|
forPeriod = period;
|
|
}
|
|
|
|
//
|
|
result = GetBarIndex(
|
|
symbol,
|
|
forPeriod,
|
|
to //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieve From Index ...
|
|
*
|
|
* @param forPeriod: ENUM_TIMEFRAMES, Specified Period ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int FromIndex(
|
|
ENUM_TIMEFRAMES forPeriod = NULL //
|
|
)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (!IsValid(forPeriod))
|
|
{
|
|
forPeriod = period;
|
|
}
|
|
|
|
//
|
|
result = GetBarIndex(
|
|
symbol,
|
|
forPeriod,
|
|
from //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieve Age of Pivot ...
|
|
*
|
|
* @param forPeriod: ENUM_TIMEFRAMES, Specified Period ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int GetAge(
|
|
ENUM_TIMEFRAMES forPeriod = NULL //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (!IsValid(forPeriod))
|
|
{
|
|
forPeriod = period;
|
|
}
|
|
|
|
//
|
|
int toIDX = ToIndex(forPeriod);
|
|
int fromIDX = FromIndex(forPeriod);
|
|
|
|
//
|
|
result = fromIDX - toIDX;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Converts Pivot to Box ...
|
|
*
|
|
* @param box: XBoxZone instance reference ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AsBox(
|
|
XBoxZone &box //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
box.Clean();
|
|
|
|
//
|
|
result = IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
|
switch (type)
|
|
{
|
|
//
|
|
case XCA_LL:
|
|
case XCA_SWL:
|
|
case XCA_VALE:
|
|
case XCA_KI_BULL:
|
|
case XCA_FVG_BULL:
|
|
case XCA_RSI_COOS:
|
|
case XCA_RSI_VALE:
|
|
case XCA_CCI_COOS:
|
|
case XCA_CCI_VALE:
|
|
case XCA_TKI_BULL:
|
|
case XCA_TREND_BULL:
|
|
case XCA_VALESWLSUP:
|
|
case XCA_TKITRND_BULL:
|
|
iDir = X_DIRECTION_BULLISH;
|
|
break;
|
|
|
|
//
|
|
case XCA_HH:
|
|
case XCA_SWH:
|
|
case XCA_PEAK:
|
|
case XCA_KI_BEAR:
|
|
case XCA_FVG_BEAR:
|
|
case XCA_RSI_CUOB:
|
|
case XCA_RSI_PEAK:
|
|
case XCA_CCI_CUOB:
|
|
case XCA_CCI_PEAK:
|
|
case XCA_TKI_BEAR:
|
|
case XCA_TREND_BEAR:
|
|
case XCA_PEAKSWHRES:
|
|
case XCA_TKITRND_BEAR:
|
|
iDir = X_DIRECTION_BEARISH;
|
|
break;
|
|
}
|
|
|
|
//
|
|
result = HasDirection(iDir);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool isBullish =
|
|
IsBullish(iDir) &&
|
|
value < reserve;
|
|
|
|
//
|
|
bool isBearish =
|
|
IsBearish(iDir) &&
|
|
value > reserve;
|
|
|
|
//
|
|
result = isBullish ||
|
|
isBearish;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
box.to = to;
|
|
box.dir = iDir;
|
|
box.from = from;
|
|
box.symbol = symbol;
|
|
box.period = period;
|
|
|
|
//
|
|
string typeStr = ToString(type);
|
|
if (type == XCA_KI_BULL ||
|
|
type == XCA_KI_BEAR)
|
|
{
|
|
//
|
|
typeStr = "XCA_KI";
|
|
}
|
|
else if (type == XCA_FVG_BULL ||
|
|
type == XCA_FVG_BEAR)
|
|
{
|
|
//
|
|
typeStr = "XCA_FVG";
|
|
}
|
|
else if (type == XCA_RSI_COOS ||
|
|
type == XCA_RSI_CUOB)
|
|
{
|
|
//
|
|
typeStr = "XCA_RSI";
|
|
}
|
|
else if (type == XCA_CCI_COOS ||
|
|
type == XCA_CCI_CUOB)
|
|
{
|
|
//
|
|
typeStr = "XCA_CCI";
|
|
}
|
|
else if (type == XCA_TKI_BULL ||
|
|
type == XCA_TKI_BEAR)
|
|
{
|
|
//
|
|
typeStr = "XCA_TKI";
|
|
}
|
|
else if (type == XCA_TREND_BULL ||
|
|
type == XCA_TREND_BEAR)
|
|
{
|
|
//
|
|
typeStr = "XCA_TREND";
|
|
}
|
|
else if (type == XCA_TKITRND_BULL ||
|
|
type == XCA_TKITRND_BEAR)
|
|
{
|
|
//
|
|
typeStr = "XCA_TKITRND";
|
|
}
|
|
box.type = typeStr;
|
|
|
|
//
|
|
box.upper =
|
|
isBullish
|
|
? reserve
|
|
: value;
|
|
box.lower =
|
|
isBullish
|
|
? value
|
|
: reserve;
|
|
|
|
//
|
|
result = box.IsValid();
|
|
if (!result)
|
|
{
|
|
box.Clean();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
struct XCAPVPivot
|
|
{
|
|
//
|
|
// Props ...
|
|
double value;
|
|
XCAPivot pivots[];
|
|
ENUM_X_DIRECTION dir;
|
|
|
|
//
|
|
// Constructor ...
|
|
XCAPVPivot()
|
|
{
|
|
Default();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
void Clean()
|
|
{
|
|
//
|
|
value = 0;
|
|
Clean(pivots);
|
|
dir = X_DIRECTION_NONE;
|
|
|
|
//
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
//
|
|
void Default()
|
|
{
|
|
//
|
|
value = 0;
|
|
Clean(pivots);
|
|
dir = X_DIRECTION_NONE;
|
|
}
|
|
|
|
//
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = value != 0 &&
|
|
HasDirection(dir);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void AddPivot(XCAPivot &pivot)
|
|
{
|
|
//
|
|
if (!IsValid() ||
|
|
!pivot.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int idx = -1;
|
|
bool has = FindPivotIndex(
|
|
idx,
|
|
pivot,
|
|
pivots //
|
|
);
|
|
if (has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
AddRef(
|
|
pivot,
|
|
pivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
int GetPivots(XBoxZone &pivotBoxes[])
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
Clean(pivotBoxes);
|
|
|
|
//
|
|
bool has = false;
|
|
|
|
//
|
|
has = IsValid() &&
|
|
HasChild(pivots);
|
|
if (!has)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(pivots);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = pivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
pivotBoxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
|
|
//
|
|
result = ArraySize(pivotBoxes);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
struct XCAPVTick
|
|
{
|
|
//
|
|
XCAPivot pivot;
|
|
XCTicksZone *zone;
|
|
|
|
//
|
|
XCAPVTick()
|
|
{
|
|
Default();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
void Clean()
|
|
{
|
|
//
|
|
pivot.Clean();
|
|
|
|
//
|
|
ZeroMemory(zone);
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
//
|
|
void Default()
|
|
{
|
|
//
|
|
pivot.Clean();
|
|
|
|
//
|
|
ZeroMemory(zone);
|
|
}
|
|
|
|
//
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = pivot.IsValid() &&
|
|
zone != NULL;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool Init(XCAPivot &_pivot)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = _pivot.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int toIDX = _pivot.ToIndex();
|
|
int fromIDX = _pivot.FromIndex();
|
|
int rangeLength = fromIDX - toIDX;
|
|
result = IsValidIndex(fromIDX) &&
|
|
IsValidIndex(toIDX);
|
|
if (!result)
|
|
{
|
|
//
|
|
Clean();
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL toBar;
|
|
XOHCL fromBar;
|
|
result = toBar.Init(
|
|
_pivot.symbol,
|
|
_pivot.period,
|
|
toIDX //
|
|
);
|
|
result = result &&
|
|
fromBar.Init(
|
|
_pivot.symbol,
|
|
_pivot.period,
|
|
fromIDX //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
toBar.Clean();
|
|
fromBar.Clean();
|
|
|
|
//
|
|
Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double rangeDivider = 10 * GetPoints(_pivot.symbol);
|
|
double rangeL = toBar.FindLowest(rangeLength, MODE_LOW);
|
|
double rangeH = toBar.FindHighest(rangeLength, MODE_HIGH);
|
|
double rangeDiff = (rangeH - rangeL);
|
|
int zoneLevels = (int)(rangeDiff / rangeDivider);
|
|
|
|
//
|
|
XCTicksZone *_zone;
|
|
_zone = new XCTicksZone();
|
|
_zone.Levels(zoneLevels);
|
|
result = _zone.Init(
|
|
fromBar,
|
|
toBar //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
toBar.Clean();
|
|
fromBar.Clean();
|
|
ZeroMemory(_zone);
|
|
|
|
//
|
|
Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
pivot = _pivot;
|
|
zone = _zone;
|
|
|
|
//
|
|
result = IsValid();
|
|
if (!result)
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
toBar.Clean();
|
|
fromBar.Clean();
|
|
ZeroMemory(_zone);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool GetMaxVolumeBox(XBoxZone &box)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
box.Clean();
|
|
|
|
//
|
|
result = IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Select MAX Volume Zone ...
|
|
XCTickZone *selectedZone = NULL;
|
|
int zonesCount = zone.Count();
|
|
for (int j = 0; j < zonesCount; j++)
|
|
{
|
|
//
|
|
XCTickZone *jZone = zone.GetZone(j);
|
|
|
|
//
|
|
bool canSet =
|
|
selectedZone == NULL
|
|
? true
|
|
: selectedZone.volume < jZone.volume;
|
|
if (canSet)
|
|
{
|
|
selectedZone = jZone;
|
|
}
|
|
|
|
//
|
|
ZeroMemory(jZone);
|
|
}
|
|
|
|
//
|
|
result = selectedZone != NULL;
|
|
if (!result)
|
|
{
|
|
//
|
|
box.Clean();
|
|
ZeroMemory(selectedZone);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = pivot.AsBox(box);
|
|
if (!result)
|
|
{
|
|
//
|
|
box.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
box.upper = selectedZone.high;
|
|
box.lower = selectedZone.low;
|
|
box.type =
|
|
pivot.type == XCA_PEAKSWHRES
|
|
? "PEAKTICK"
|
|
: pivot.type == XCA_VALESWLSUP
|
|
? "VALETICK"
|
|
: box.type;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
/**
|
|
* Find Specified Pivot Index inside a Collection of Pivots ...
|
|
*
|
|
* @param pivot: XCAPivot instance Reference ...
|
|
* @param pivots: XCAPivot instance Reference Collection ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
bool FindPivotIndex(
|
|
int &index,
|
|
XCAPivot &pivot,
|
|
XCAPivot &pivots[] //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
index = -1;
|
|
|
|
//
|
|
int count = ArraySize(pivots);
|
|
result = pivot.IsValid() &&
|
|
IsValidSize(count);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCAPivot iPivot = pivots[i];
|
|
|
|
//
|
|
bool isSame = pivot.IsSameAs(iPivot);
|
|
if (isSame)
|
|
{
|
|
//
|
|
index = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
result = IsValidIndex(index);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Add or Update Specified Pivot to Specified Collection ...
|
|
*
|
|
* @param pivot: XCAPivot instance reference, Specified Item ...
|
|
* @param pivots: XCAPivot instance reference Collection ...
|
|
* @param maxAllowedPivots: int, Max Allowed Pivots number of Collection ...
|
|
*/
|
|
void AddPivot(
|
|
XCAPivot &pivot,
|
|
XCAPivot &pivots[],
|
|
int maxAllowedPivots = 50 //
|
|
)
|
|
{
|
|
//
|
|
bool has = pivot.IsValid();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int idx = -1;
|
|
has = FindPivotIndex(
|
|
idx,
|
|
pivot,
|
|
pivots //
|
|
);
|
|
if (has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int updateIDX = -1;
|
|
int count = ArraySize(pivots);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCAPivot iPivot = pivots[i];
|
|
|
|
//
|
|
has =
|
|
iPivot.to > pivot.to &&
|
|
iPivot.from == pivot.from &&
|
|
iPivot.value == pivot.value &&
|
|
iPivot.symbol == pivot.symbol &&
|
|
iPivot.period == pivot.period;
|
|
if (has)
|
|
{
|
|
//
|
|
updateIDX = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
has = IsValidIndex(updateIDX);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
pivot,
|
|
pivots //
|
|
);
|
|
}
|
|
else
|
|
{
|
|
pivots[updateIDX].to = pivot.to;
|
|
}
|
|
|
|
//
|
|
// Apply Max Allowed ...
|
|
CleanupArray(
|
|
pivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Add or Update PV FVG item to Specified Collection ...
|
|
*
|
|
* @param value: double, Peak or Vale Value ...
|
|
* @param fvg: XCAPivot instance reference, Specified Pivot ...
|
|
* @param collection: XCAPVPivot instance Collection ...
|
|
*/
|
|
void AddOrUpdatePVFVG(
|
|
double value,
|
|
XCAPivot &fvg,
|
|
XCAPVPivot &collection[] //
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (value < 0 &&
|
|
!fvg.IsValid() &&
|
|
(fvg.type == XCA_FVG_BULL ||
|
|
fvg.type == XCA_FVG_BEAR))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Check Pivot is Exists or not ...
|
|
ENUM_X_DIRECTION dir =
|
|
fvg.type == XCA_FVG_BULL
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
|
|
//
|
|
bool isBullish = IsBullish(dir);
|
|
bool isBearish = IsBearish(dir);
|
|
|
|
//
|
|
// Try to Findout Pivot Value in Collection ...
|
|
int idx = -1;
|
|
int count = ArraySize(collection);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCAPVPivot iTem = collection[i];
|
|
|
|
//
|
|
bool isSameValue = iTem.value == value;
|
|
bool isSameDirection = iTem.dir == dir;
|
|
|
|
//
|
|
bool isValid = isSameValue &&
|
|
isSameDirection;
|
|
if (isValid)
|
|
{
|
|
//
|
|
idx = i;
|
|
iTem.Clean();
|
|
break;
|
|
}
|
|
|
|
//
|
|
iTem.Clean();
|
|
}
|
|
|
|
//
|
|
// Try to Add Or Update Pivots ...
|
|
bool hasIndex = IsValidIndex(idx);
|
|
if (!hasIndex)
|
|
{
|
|
//
|
|
// New Item ...
|
|
XCAPVPivot iPVFVG;
|
|
|
|
//
|
|
iPVFVG.dir = dir;
|
|
iPVFVG.value = value;
|
|
|
|
//
|
|
AddRef(
|
|
fvg,
|
|
iPVFVG.pivots //
|
|
);
|
|
|
|
//
|
|
AddRef(
|
|
iPVFVG,
|
|
collection //
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
// Add Pivot to Existing Item ...
|
|
collection[idx].AddPivot(fvg);
|
|
}
|
|
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Add Specified PVTick to Collection ...
|
|
*
|
|
* @param pvTick: XCAPVTick instance Reference ...
|
|
* @param pvTicks: XCAPVTickinstance Reference Collection ...
|
|
*/
|
|
void AddPVTick(
|
|
XCAPVTick &pvTick,
|
|
XCAPVTick &pvTicks[] //
|
|
)
|
|
{
|
|
//
|
|
bool has = pvTick.IsValid();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = false;
|
|
int count = ArraySize(pvTicks);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
has = pvTicks[i].pivot.IsSameAs(pvTick.pivot);
|
|
if (has)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
AddRef(
|
|
pvTick,
|
|
pvTicks //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Implementations ...
|
|
class XCXCAEAPOIDetector : public XCBase
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Pivot Verifications and Max Allowed Holding Items ...
|
|
int pivotVerifications; // Pivots Verifications ...
|
|
int maxAllowedPivots; // Max Allowed Holding Pibots ...
|
|
|
|
//
|
|
// Detector Pivots State Properties ...
|
|
|
|
//
|
|
// PEAK / VALES ...
|
|
bool detectPeakPivot;
|
|
bool detectValePivot;
|
|
|
|
//
|
|
// PEAK SWH RES / VALE SWL SUP ...
|
|
bool detectPeakSWHResPivot;
|
|
bool detectValeSWLSupPivot;
|
|
|
|
//
|
|
// SWING HIGH / LOW ...
|
|
bool detectSWHPivot;
|
|
bool detectSWLPivot;
|
|
|
|
//
|
|
// KI ...
|
|
bool detectKIBullishPivot;
|
|
bool detectKIBearishPivot;
|
|
|
|
//
|
|
// TKI ...
|
|
bool detectTKIBullishPivot;
|
|
bool detectTKIBearishPivot;
|
|
|
|
//
|
|
// FVG ...
|
|
bool detectFVGBullishPivot;
|
|
bool detectFVGBearishPivot;
|
|
|
|
//
|
|
// SAME Cycles HH / LL ...
|
|
bool detectCycleSameLLPivot;
|
|
bool detectCycleSameHHPivot;
|
|
|
|
//
|
|
// TREND ...
|
|
bool detectTrendBullishPivot;
|
|
bool detectTrendBearishPivot;
|
|
|
|
//
|
|
// TKITRND ...
|
|
bool detectTKITRNDBullishPivot;
|
|
bool detectTKITRNDBearishPivot;
|
|
|
|
//
|
|
// OSCS ...
|
|
|
|
//
|
|
// RSI ...
|
|
bool detectRSIPeakPivot;
|
|
bool detectRSIValePivot;
|
|
bool detectRSICrossedOverOSPivot;
|
|
bool detectRSICrossedUnderOBPivot;
|
|
|
|
//
|
|
// CCI ...
|
|
bool detectCCIPeakPivot;
|
|
bool detectCCIValePivot;
|
|
bool detectCCICrossedOverOSPivot;
|
|
bool detectCCICrossedUnderOBPivot;
|
|
|
|
//
|
|
// Active Pivots ...
|
|
XCAPivot swhPivot;
|
|
XCAPivot swlPivot;
|
|
XCAPivot peakPivot;
|
|
XCAPivot valePivot;
|
|
XCAPivot sSameHHPivot;
|
|
XCAPivot mSameHHPivot;
|
|
XCAPivot lSameHHPivot;
|
|
XCAPivot hSameHHPivot;
|
|
XCAPivot sSameLLPivot;
|
|
XCAPivot mSameLLPivot;
|
|
XCAPivot lSameLLPivot;
|
|
XCAPivot hSameLLPivot;
|
|
XCAPivot kiBullishPivot;
|
|
XCAPivot kiBearishPivot;
|
|
XCAPivot tkiBullishPivot;
|
|
XCAPivot tkiBearishPivot;
|
|
XCAPivot peakSWHResPivot;
|
|
XCAPivot valeSWLSupPivot;
|
|
XCAPivot trendBullishPivot;
|
|
XCAPivot trendBearishPivot;
|
|
XCAPivot tkitrndBullishPivot;
|
|
XCAPivot tkitrndBearishPivot;
|
|
|
|
//
|
|
// UnActive Pivots ...
|
|
XCAPivot swhPivots[];
|
|
XCAPivot swlPivots[];
|
|
XCAPivot peakPivots[];
|
|
XCAPivot valePivots[];
|
|
XCAPivot rsiPeakPivots[];
|
|
XCAPivot rsiValePivots[];
|
|
XCAPivot cciPeakPivots[];
|
|
XCAPivot cciValePivots[];
|
|
XCAPivot sSameHHPivots[];
|
|
XCAPivot mSameHHPivots[];
|
|
XCAPivot lSameHHPivots[];
|
|
XCAPivot hSameHHPivots[];
|
|
XCAPivot sSameLLPivots[];
|
|
XCAPivot mSameLLPivots[];
|
|
XCAPivot lSameLLPivots[];
|
|
XCAPivot hSameLLPivots[];
|
|
XCAPivot kiBullishPivots[];
|
|
XCAPivot kiBearishPivots[];
|
|
XCAPivot fvgBullishPivots[];
|
|
XCAPivot fvgBearishPivots[];
|
|
XCAPivot tkiBullishPivots[];
|
|
XCAPivot tkiBearishPivots[];
|
|
XCAPivot peakSWHResPivots[];
|
|
XCAPivot valeSWLSupPivots[];
|
|
XCAPivot trendBullishPivots[];
|
|
XCAPivot trendBearishPivots[];
|
|
XCAPivot tkitrndBullishPivots[];
|
|
XCAPivot tkitrndBearishPivots[];
|
|
XCAPivot rsiCrossedOverOSPivots[];
|
|
XCAPivot cciCrossedOverOSPivots[];
|
|
XCAPivot rsiCrossedUnderOBPivots[];
|
|
XCAPivot cciCrossedUnderOBPivots[];
|
|
|
|
//
|
|
XCAPVTick peakTicks[];
|
|
XCAPVTick valeTicks[];
|
|
|
|
//
|
|
XCAPVPivot pvFVGBullishPivots[];
|
|
XCAPVPivot pvFVGBearishPivots[];
|
|
|
|
//
|
|
// Constructors ...
|
|
XCXCAEAPOIDetector(
|
|
XCXCAEAHelper *_helper //
|
|
)
|
|
{
|
|
//
|
|
helper = _helper;
|
|
drawer = new XCPOIDrawer();
|
|
barAnalyser = new XCBarAnalyser();
|
|
|
|
//
|
|
Default();
|
|
}
|
|
|
|
//
|
|
// De Constructors ...
|
|
~XCXCAEAPOIDetector()
|
|
{
|
|
//
|
|
swhPivot.Clean();
|
|
swlPivot.Clean();
|
|
peakPivot.Clean();
|
|
valePivot.Clean();
|
|
sSameHHPivot.Clean();
|
|
mSameHHPivot.Clean();
|
|
lSameHHPivot.Clean();
|
|
hSameHHPivot.Clean();
|
|
sSameLLPivot.Clean();
|
|
mSameLLPivot.Clean();
|
|
lSameLLPivot.Clean();
|
|
hSameLLPivot.Clean();
|
|
kiBullishPivot.Clean();
|
|
kiBearishPivot.Clean();
|
|
tkiBullishPivot.Clean();
|
|
tkiBearishPivot.Clean();
|
|
peakSWHResPivot.Clean();
|
|
valeSWLSupPivot.Clean();
|
|
trendBullishPivot.Clean();
|
|
trendBearishPivot.Clean();
|
|
tkitrndBullishPivot.Clean();
|
|
tkitrndBearishPivot.Clean();
|
|
|
|
//
|
|
Clean(swhPivots);
|
|
Clean(swlPivots);
|
|
Clean(peakPivots);
|
|
Clean(valePivots);
|
|
Clean(rsiPeakPivots);
|
|
Clean(rsiValePivots);
|
|
Clean(cciPeakPivots);
|
|
Clean(cciValePivots);
|
|
Clean(sSameHHPivots);
|
|
Clean(mSameHHPivots);
|
|
Clean(lSameHHPivots);
|
|
Clean(hSameHHPivots);
|
|
Clean(sSameLLPivots);
|
|
Clean(mSameLLPivots);
|
|
Clean(lSameLLPivots);
|
|
Clean(hSameLLPivots);
|
|
Clean(kiBullishPivots);
|
|
Clean(kiBearishPivots);
|
|
Clean(fvgBullishPivots);
|
|
Clean(fvgBearishPivots);
|
|
Clean(tkiBullishPivots);
|
|
Clean(tkiBearishPivots);
|
|
Clean(peakSWHResPivots);
|
|
Clean(valeSWLSupPivots);
|
|
Clean(trendBullishPivots);
|
|
Clean(trendBearishPivots);
|
|
Clean(tkitrndBullishPivots);
|
|
Clean(tkitrndBearishPivots);
|
|
Clean(rsiCrossedOverOSPivots);
|
|
Clean(cciCrossedOverOSPivots);
|
|
Clean(rsiCrossedUnderOBPivots);
|
|
Clean(cciCrossedUnderOBPivots);
|
|
|
|
//
|
|
ZeroMemory(helper);
|
|
ZeroMemory(drawer);
|
|
ZeroMemory(barAnalyser);
|
|
}
|
|
|
|
//
|
|
// Properties ...
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
virtual void Default()
|
|
{
|
|
//
|
|
maxAllowedPivots = 50;
|
|
pivotVerifications = 5;
|
|
|
|
//
|
|
detectSWHPivot = true;
|
|
detectSWLPivot = true;
|
|
detectPeakPivot = true;
|
|
detectValePivot = true;
|
|
detectRSIPeakPivot = true;
|
|
detectRSIValePivot = true;
|
|
detectCCIPeakPivot = true;
|
|
detectCCIValePivot = true;
|
|
detectKIBullishPivot = true;
|
|
detectKIBearishPivot = true;
|
|
detectFVGBullishPivot = true;
|
|
detectFVGBearishPivot = true;
|
|
detectTKIBullishPivot = true;
|
|
detectTKIBearishPivot = true;
|
|
detectPeakSWHResPivot = true;
|
|
detectValeSWLSupPivot = true;
|
|
detectCycleSameLLPivot = true;
|
|
detectCycleSameHHPivot = true;
|
|
detectTrendBullishPivot = true;
|
|
detectTrendBearishPivot = true;
|
|
detectTKITRNDBullishPivot = true;
|
|
detectTKITRNDBearishPivot = true;
|
|
detectCCICrossedOverOSPivot = true;
|
|
detectCCICrossedUnderOBPivot = true;
|
|
}
|
|
|
|
//
|
|
void Update(
|
|
int barIndex = 0,
|
|
int loopback = 400 //
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
loopback = NormalizeInt(loopback, 400);
|
|
|
|
//
|
|
int count = 0;
|
|
bool has = false;
|
|
|
|
//
|
|
int zIDX = 0;
|
|
int cIDX = zIDX + 1;
|
|
int pIDX = cIDX + 1;
|
|
int p2IDX = pIDX + 1;
|
|
int p3IDX = p2IDX + 1;
|
|
|
|
//
|
|
int index = barIndex;
|
|
int start = index;
|
|
int end = index + loopback;
|
|
while (start < end)
|
|
{
|
|
//
|
|
// Retrieve Conditions ...
|
|
XCAEAConditions iConditions;
|
|
has = helper.GetConditions(
|
|
iConditions,
|
|
start,
|
|
5 //
|
|
);
|
|
|
|
//
|
|
// Retrieve Bars ...
|
|
XOHCL zBar;
|
|
XOHCL cBar;
|
|
XOHCL pBar;
|
|
XOHCL p2Bar;
|
|
has = zBar.Init(
|
|
iConditions.symbol,
|
|
iConditions.period,
|
|
start //
|
|
);
|
|
has =
|
|
has &&
|
|
zBar.GetPreviousBar(cBar);
|
|
has =
|
|
has &&
|
|
cBar.GetPreviousBar(pBar);
|
|
has =
|
|
has &&
|
|
pBar.GetPreviousBar(p2Bar);
|
|
if (!has)
|
|
{
|
|
//
|
|
zBar.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
p2Bar.Clean();
|
|
iConditions.Clean();
|
|
|
|
//
|
|
continue;
|
|
}
|
|
|
|
//
|
|
XBoxZone fvgBox;
|
|
bool isFVG = barAnalyser.IsFVG(
|
|
cBar,
|
|
fvgBox //
|
|
);
|
|
|
|
//
|
|
bool isBullishFVG =
|
|
isFVG &&
|
|
fvgBox.IsBullish();
|
|
|
|
//
|
|
bool isBearishFVG =
|
|
isFVG &&
|
|
fvgBox.IsBearish();
|
|
|
|
//
|
|
// Provide Some Conditions ...
|
|
|
|
//
|
|
double points = GetPoints(zBar.symbol);
|
|
|
|
//
|
|
// PEAK ...
|
|
|
|
//
|
|
double cPeak = iConditions.peakBuffer[cIDX];
|
|
double pPeak = iConditions.peakBuffer[pIDX];
|
|
double p2Peak = iConditions.peakBuffer[p2IDX];
|
|
|
|
//
|
|
bool isPeakStartSameLast =
|
|
cPeak == pPeak &&
|
|
pPeak != p2Peak;
|
|
|
|
//
|
|
bool isPeakFinishedSameLast =
|
|
cPeak != pPeak &&
|
|
pPeak == p2Peak;
|
|
|
|
//
|
|
// VALE ...
|
|
|
|
//
|
|
double cVale = iConditions.valeBuffer[cIDX];
|
|
double pVale = iConditions.valeBuffer[pIDX];
|
|
double p2Vale = iConditions.valeBuffer[p2IDX];
|
|
|
|
//
|
|
bool isValeStartSameLast =
|
|
cVale == pVale &&
|
|
pVale != p2Vale;
|
|
|
|
//
|
|
bool isValeFinishedSameLast =
|
|
cVale != pVale &&
|
|
pVale == p2Vale;
|
|
|
|
//
|
|
// SWH ...
|
|
|
|
//
|
|
double cSWH = iConditions.swingHighBuffer[cIDX];
|
|
double pSWH = iConditions.swingHighBuffer[pIDX];
|
|
double p2SWH = iConditions.swingHighBuffer[p2IDX];
|
|
|
|
//
|
|
bool isSWHStartSameLast =
|
|
cSWH == pSWH &&
|
|
pSWH != p2SWH;
|
|
|
|
//
|
|
bool isSWHFinishedSameLast =
|
|
cSWH != pSWH &&
|
|
pSWH == p2SWH;
|
|
|
|
//
|
|
// SWL ...
|
|
|
|
//
|
|
double pSWL = iConditions.swingLowBuffer[pIDX];
|
|
double cSWL = iConditions.swingLowBuffer[cIDX];
|
|
double p2SWL = iConditions.swingLowBuffer[p2IDX];
|
|
|
|
//
|
|
bool isSWLStartSameLast =
|
|
cSWL == pSWL &&
|
|
pSWL != p2SWL;
|
|
|
|
//
|
|
bool isSWLFinishedSameLast =
|
|
cSWL != pSWL &&
|
|
pSWL == p2SWL;
|
|
|
|
//
|
|
// SUPPORT ...
|
|
|
|
//
|
|
double cSupport = iConditions.supportBuffer[cIDX];
|
|
double pSupport = iConditions.supportBuffer[pIDX];
|
|
double p2Support = iConditions.supportBuffer[p2IDX];
|
|
|
|
//
|
|
bool isSupportStartSameLast =
|
|
cSupport == pSupport &&
|
|
pSupport != p2Support;
|
|
|
|
//
|
|
bool isSupportFinishedSameLast =
|
|
cSupport != pSupport &&
|
|
pSupport == p2Support;
|
|
|
|
//
|
|
// RESISTANCE ...
|
|
|
|
//
|
|
double pResistance = iConditions.resistanceBuffer[pIDX];
|
|
double cResistance = iConditions.resistanceBuffer[cIDX];
|
|
double p2Resistance = iConditions.resistanceBuffer[p2IDX];
|
|
|
|
//
|
|
bool isResistanceStartSameLast =
|
|
cResistance == pResistance &&
|
|
pResistance != p2Resistance;
|
|
|
|
//
|
|
bool isResistanceFinishedSameLast =
|
|
cResistance != pResistance &&
|
|
pResistance == p2Resistance;
|
|
|
|
//
|
|
// PEAK SWH RES ...
|
|
|
|
//
|
|
bool isCPeakIsPivot =
|
|
cPeak == cSWH &&
|
|
cSWH == cResistance;
|
|
|
|
//
|
|
bool isPPeakIsPivot =
|
|
pPeak == pSWH &&
|
|
pSWH == pResistance;
|
|
|
|
//
|
|
bool isStartPeakIsPivot =
|
|
isCPeakIsPivot &&
|
|
!isPPeakIsPivot;
|
|
|
|
//
|
|
bool isFinishedPeakIsPivot =
|
|
!isCPeakIsPivot &&
|
|
isPPeakIsPivot;
|
|
|
|
//
|
|
// VALE SWL SUP ...
|
|
|
|
//
|
|
bool isCValeIsPivot =
|
|
cVale == cSWL &&
|
|
cSWL == cSupport;
|
|
|
|
//
|
|
bool isPValeIsPivot =
|
|
pVale == pSWL &&
|
|
pSWL == pSupport;
|
|
|
|
//
|
|
bool isStartValeIsPivot =
|
|
isCValeIsPivot &&
|
|
!isPValeIsPivot;
|
|
|
|
//
|
|
bool isFinishedValeIsPivot =
|
|
!isCValeIsPivot &&
|
|
isPValeIsPivot;
|
|
|
|
//
|
|
// TKITRND ...
|
|
|
|
//
|
|
double cKI = iConditions.kiBuffer[cIDX];
|
|
double pKI = iConditions.kiBuffer[pIDX];
|
|
double p2KI = iConditions.kiBuffer[p2IDX];
|
|
|
|
//
|
|
double cKIState = iConditions.kiStateBuffer[cIDX];
|
|
double pKIState = iConditions.kiStateBuffer[pIDX];
|
|
double p2KIState = iConditions.kiStateBuffer[p2IDX];
|
|
|
|
//
|
|
double cTKI = iConditions.tkiBuffer[cIDX];
|
|
double pTKI = iConditions.tkiBuffer[pIDX];
|
|
double p2TKI = iConditions.tkiBuffer[p2IDX];
|
|
|
|
//
|
|
double cTKIState = iConditions.tkiStateBuffer[cIDX];
|
|
double pTKIState = iConditions.tkiStateBuffer[pIDX];
|
|
double p2TKIState = iConditions.tkiStateBuffer[p2IDX];
|
|
|
|
//
|
|
double cTrend = iConditions.trendBuffer[cIDX];
|
|
double pTrend = iConditions.trendBuffer[pIDX];
|
|
double p2Trend = iConditions.trendBuffer[p2IDX];
|
|
|
|
//
|
|
double cTrendState = iConditions.trendStateBuffer[cIDX];
|
|
double pTrendState = iConditions.trendStateBuffer[pIDX];
|
|
double p2TrendState = iConditions.trendStateBuffer[p2IDX];
|
|
|
|
//
|
|
double cTKITRNDs[] = {
|
|
cKI,
|
|
cTKI,
|
|
cTrend //
|
|
};
|
|
|
|
//
|
|
double cTKITRNDMin = GetMin(cTKITRNDs);
|
|
double cTKITRNDMax = GetMax(cTKITRNDs);
|
|
|
|
//
|
|
double pTKITRNDs[] = {
|
|
pKI,
|
|
pTKI,
|
|
pTrend //
|
|
};
|
|
|
|
//
|
|
double pTKITRNDMin = GetMin(pTKITRNDs);
|
|
double pTKITRNDMax = GetMax(pTKITRNDs);
|
|
|
|
//
|
|
bool isCTKITRNDBullish =
|
|
cKIState > 0 &&
|
|
cTKIState > 0 &&
|
|
cTrendState > 0;
|
|
|
|
//
|
|
bool isPTKITRNDBullish =
|
|
pKIState > 0 &&
|
|
pTKIState > 0 &&
|
|
pTrendState > 0;
|
|
|
|
//
|
|
bool isTKITRNDSwitchedBullish =
|
|
isCTKITRNDBullish &&
|
|
!isPTKITRNDBullish;
|
|
|
|
//
|
|
bool isCTKITRNDBearish =
|
|
cKIState < 0 &&
|
|
cTKIState < 0 &&
|
|
cTrendState < 0;
|
|
|
|
//
|
|
bool isPTKITRNDBearish =
|
|
pKIState < 0 &&
|
|
pTKIState < 0 &&
|
|
pTrendState < 0;
|
|
|
|
//
|
|
bool isTKITRNDSwitchedBearish =
|
|
isCTKITRNDBearish &&
|
|
!isPTKITRNDBearish;
|
|
|
|
//
|
|
// CYCLES ...
|
|
|
|
//
|
|
double cSLL = iConditions.sLLBuffer[cIDX];
|
|
double pSLL = iConditions.sLLBuffer[pIDX];
|
|
double p2SLL = iConditions.sLLBuffer[p2IDX];
|
|
|
|
//
|
|
double cSHH = iConditions.sHHBuffer[cIDX];
|
|
double pSHH = iConditions.sHHBuffer[pIDX];
|
|
double p2SHH = iConditions.sHHBuffer[p2IDX];
|
|
|
|
//
|
|
double cMLL = iConditions.mLLBuffer[cIDX];
|
|
double pMLL = iConditions.mLLBuffer[pIDX];
|
|
double p2MLL = iConditions.mLLBuffer[p2IDX];
|
|
|
|
//
|
|
double cMHH = iConditions.mHHBuffer[cIDX];
|
|
double pMHH = iConditions.mHHBuffer[pIDX];
|
|
double p2MHH = iConditions.mHHBuffer[p2IDX];
|
|
|
|
//
|
|
double cLLL = iConditions.lLLBuffer[cIDX];
|
|
double pLLL = iConditions.lLLBuffer[pIDX];
|
|
double p2LLL = iConditions.lLLBuffer[p2IDX];
|
|
|
|
//
|
|
double cLHH = iConditions.lHHBuffer[cIDX];
|
|
double pLHH = iConditions.lHHBuffer[pIDX];
|
|
double p2LHH = iConditions.lHHBuffer[p2IDX];
|
|
|
|
//
|
|
double cHLL = iConditions.hLLBuffer[cIDX];
|
|
double pHLL = iConditions.hLLBuffer[pIDX];
|
|
double p2HLL = iConditions.hLLBuffer[p2IDX];
|
|
|
|
//
|
|
double cHHH = iConditions.hHHBuffer[cIDX];
|
|
double pHHH = iConditions.hHHBuffer[pIDX];
|
|
double p2HHH = iConditions.hHHBuffer[p2IDX];
|
|
|
|
//
|
|
// Short Cycle ...
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
bool isCSLLSame =
|
|
cSLL == pSLL;
|
|
|
|
//
|
|
bool isPSLLSame =
|
|
pSLL == p2SLL;
|
|
|
|
//
|
|
bool isSLLStartSame =
|
|
isCSLLSame &&
|
|
!isPSLLSame;
|
|
|
|
//
|
|
bool isSLLFinishedSame =
|
|
!isCSLLSame &&
|
|
isPSLLSame;
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
bool isCSHHSame =
|
|
cSHH == pSHH;
|
|
|
|
//
|
|
bool isPSHHSame =
|
|
pSHH == p2SHH;
|
|
|
|
//
|
|
bool isSHHStartSame =
|
|
isCSHHSame &&
|
|
!isPSHHSame;
|
|
|
|
//
|
|
bool isSHHFinishedSame =
|
|
!isCSHHSame &&
|
|
isPSHHSame;
|
|
|
|
//
|
|
// Mediu Cycle ...
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
bool isCMLLSame =
|
|
cMLL == pMLL;
|
|
|
|
//
|
|
bool isPMLLSame =
|
|
pMLL == p2MLL;
|
|
|
|
//
|
|
bool isMLLStartSame =
|
|
isCMLLSame &&
|
|
!isPMLLSame;
|
|
|
|
//
|
|
bool isMLLFinishedSame =
|
|
!isCMLLSame &&
|
|
isPMLLSame;
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
bool isCMHHSame =
|
|
cMHH == pMHH;
|
|
|
|
//
|
|
bool isPMHHSame =
|
|
pMHH == p2MHH;
|
|
|
|
//
|
|
bool isMHHStartSame =
|
|
isCMHHSame &&
|
|
!isPMHHSame;
|
|
|
|
//
|
|
bool isMHHFinishedSame =
|
|
!isCMHHSame &&
|
|
isPMHHSame;
|
|
|
|
//
|
|
// Long Cycle ...
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
bool isCLLLSame =
|
|
cLLL == pLLL;
|
|
|
|
//
|
|
bool isPLLLSame =
|
|
pLLL == p2LLL;
|
|
|
|
//
|
|
bool isLLLStartSame =
|
|
isCLLLSame &&
|
|
!isPLLLSame;
|
|
|
|
//
|
|
bool isLLLFinishedSame =
|
|
!isCLLLSame &&
|
|
isPLLLSame;
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
bool isCLHHSame =
|
|
cLHH == pLHH;
|
|
|
|
//
|
|
bool isPLHHSame =
|
|
pLHH == p2LHH;
|
|
|
|
//
|
|
bool isLHHStartSame =
|
|
isCLHHSame &&
|
|
!isPLHHSame;
|
|
|
|
//
|
|
bool isLHHFinishedSame =
|
|
!isCLHHSame &&
|
|
isPLHHSame;
|
|
|
|
//
|
|
// Hind Cycle ...
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
bool isCHLLSame =
|
|
cHLL == pHLL;
|
|
|
|
//
|
|
bool isPHLLSame =
|
|
pHLL == p2HLL;
|
|
|
|
//
|
|
bool isHLLStartSame =
|
|
isCHLLSame &&
|
|
!isPHLLSame;
|
|
|
|
//
|
|
bool isHLLFinishedSame =
|
|
!isCHLLSame &&
|
|
isPHLLSame;
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
bool isCHHHSame =
|
|
cHHH == pHHH;
|
|
|
|
//
|
|
bool isPHHHSame =
|
|
pHHH == p2HHH;
|
|
|
|
//
|
|
bool isHHHStartSame =
|
|
isCHHHSame &&
|
|
!isPHHHSame;
|
|
|
|
//
|
|
bool isHHHFinishedSame =
|
|
!isCHHHSame &&
|
|
isPHHHSame;
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
bool isCKISame =
|
|
cKI == pKI;
|
|
|
|
//
|
|
bool isPKISame =
|
|
pKI == p2KI;
|
|
|
|
//
|
|
bool isKIStartSame =
|
|
isCKISame &&
|
|
!isPKISame;
|
|
|
|
//
|
|
bool isKIFinishedSame =
|
|
!isCKISame &&
|
|
isPKISame;
|
|
|
|
//
|
|
// RSI ...
|
|
|
|
//
|
|
double zRSI = iConditions.rsiBuffer[zIDX];
|
|
double cRSI = iConditions.rsiBuffer[cIDX];
|
|
double pRSI = iConditions.rsiBuffer[pIDX];
|
|
double p2RSI = iConditions.rsiBuffer[p2IDX];
|
|
|
|
//
|
|
bool isRSIPeak =
|
|
pRSI > cRSI &&
|
|
pRSI > p2RSI &&
|
|
pRSI > zRSI;
|
|
|
|
//
|
|
bool isRSIVale =
|
|
pRSI < cRSI &&
|
|
pRSI < p2RSI &&
|
|
pRSI < zRSI;
|
|
|
|
//
|
|
bool isRSIBullishVPattern =
|
|
cRSI > pRSI &&
|
|
p2RSI > pRSI &&
|
|
cRSI > iConditions.rsiOSLevel &&
|
|
pRSI < iConditions.rsiOSLevel;
|
|
|
|
//
|
|
bool isRSIBearishVPattern =
|
|
cRSI < pRSI &&
|
|
p2RSI < pRSI &&
|
|
cRSI < iConditions.rsiOBLevel &&
|
|
pRSI > iConditions.rsiOBLevel;
|
|
|
|
//
|
|
// CCI ...
|
|
|
|
//
|
|
double zCCI = iConditions.cciBuffer[zIDX];
|
|
double cCCI = iConditions.cciBuffer[cIDX];
|
|
double pCCI = iConditions.cciBuffer[pIDX];
|
|
double p2CCI = iConditions.cciBuffer[p2IDX];
|
|
|
|
//
|
|
bool isCCIPeak =
|
|
pCCI > cCCI &&
|
|
pCCI > p2CCI &&
|
|
pCCI > zCCI;
|
|
|
|
//
|
|
bool isCCIVale =
|
|
pCCI < cCCI &&
|
|
pCCI < p2CCI &&
|
|
pCCI < zCCI;
|
|
|
|
//
|
|
bool isCCIBullishVPattern =
|
|
cCCI > pCCI &&
|
|
p2CCI > pCCI &&
|
|
cCCI > iConditions.cciOSLevel &&
|
|
pCCI < iConditions.cciOSLevel;
|
|
|
|
//
|
|
bool isCCIBearishVPattern =
|
|
cCCI < pCCI &&
|
|
p2CCI < pCCI &&
|
|
cCCI < iConditions.cciOBLevel &&
|
|
pCCI > iConditions.cciOBLevel;
|
|
|
|
//
|
|
// Checking Pivots ...
|
|
|
|
//
|
|
// Peak Pivot ...
|
|
if (detectPeakPivot)
|
|
{
|
|
//
|
|
if (!peakPivot.IsValid())
|
|
{
|
|
//
|
|
peakPivot.type = XCA_PEAK;
|
|
peakPivot.symbol = iConditions.symbol;
|
|
peakPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isPeakFinishedSameLast)
|
|
{
|
|
//
|
|
peakPivot.Clean();
|
|
|
|
//
|
|
peakPivot.type = XCA_PEAK;
|
|
peakPivot.symbol = iConditions.symbol;
|
|
peakPivot.period = iConditions.period;
|
|
|
|
//
|
|
peakPivot.to = pBar.time;
|
|
peakPivot.from = pBar.time;
|
|
peakPivot.value = iConditions.peakBuffer[pIDX];
|
|
peakPivot.reserve = iConditions.peakGoldenBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isPeakSameLast)
|
|
{
|
|
//
|
|
peakPivot.from = pBar.time;
|
|
|
|
//
|
|
peakPivot.reserve =
|
|
peakPivot.reserve == 0
|
|
? iConditions.peakGoldenBuffer[cIDX]
|
|
: MathMax(peakPivot.reserve, iConditions.peakGoldenBuffer[cIDX]);
|
|
}
|
|
|
|
//
|
|
if (isPeakStartSameLast)
|
|
{
|
|
//
|
|
has =
|
|
peakPivot.IsValid() &&
|
|
peakPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
peakPivot,
|
|
peakPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
peakPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// Vale Pivot ...
|
|
if (detectValePivot)
|
|
{
|
|
//
|
|
if (!valePivot.IsValid())
|
|
{
|
|
//
|
|
valePivot.type = XCA_VALE;
|
|
valePivot.symbol = iConditions.symbol;
|
|
valePivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isValeFinishedSameLast)
|
|
{
|
|
//
|
|
valePivot.Clean();
|
|
|
|
//
|
|
valePivot.type = XCA_VALE;
|
|
valePivot.symbol = iConditions.symbol;
|
|
valePivot.period = iConditions.period;
|
|
|
|
//
|
|
valePivot.to = pBar.time;
|
|
valePivot.from = pBar.time;
|
|
valePivot.value = iConditions.valeBuffer[pIDX];
|
|
valePivot.reserve = iConditions.valeGoldenBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isValeSameLast)
|
|
{
|
|
//
|
|
valePivot.from = pBar.time;
|
|
|
|
//
|
|
valePivot.reserve =
|
|
valePivot.reserve == 0
|
|
? iConditions.valeGoldenBuffer[cIDX]
|
|
: MathMin(valePivot.reserve, iConditions.valeGoldenBuffer[cIDX]);
|
|
}
|
|
|
|
//
|
|
if (isValeStartSameLast)
|
|
{
|
|
//
|
|
has = valePivot.IsValid() &&
|
|
valePivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
valePivot,
|
|
valePivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
valePivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// SWH Pivot ...
|
|
if (detectSWHPivot)
|
|
{
|
|
//
|
|
if (!swhPivot.IsValid())
|
|
{
|
|
//
|
|
swhPivot.type = XCA_SWH;
|
|
swhPivot.symbol = iConditions.symbol;
|
|
swhPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isSWHFinishedSameLast)
|
|
{
|
|
//
|
|
swhPivot.Clean();
|
|
|
|
//
|
|
swhPivot.type = XCA_SWH;
|
|
swhPivot.symbol = iConditions.symbol;
|
|
swhPivot.period = iConditions.period;
|
|
|
|
//
|
|
swhPivot.to = pBar.time;
|
|
swhPivot.from = pBar.time;
|
|
swhPivot.value = iConditions.swingHighBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isSwingHighSameLast)
|
|
{
|
|
//
|
|
swhPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = swhPivot.reserve;
|
|
if (pBar.high == pSWH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
swhPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isSWHStartSameLast)
|
|
{
|
|
//
|
|
double reserve = swhPivot.reserve;
|
|
if (cBar.high == cSWH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetUp()
|
|
: MathMin(reserve, cBar.GetUp());
|
|
}
|
|
if (pBar.high == pSWH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
if (reserve == 0 || reserve == swhPivot.value)
|
|
{
|
|
reserve = swhPivot.value - (5 * points);
|
|
}
|
|
swhPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
swhPivot.IsValid() &&
|
|
swhPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
swhPivot,
|
|
swhPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
swhPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// SWL Pivot ...
|
|
if (detectSWLPivot)
|
|
{
|
|
//
|
|
if (!swlPivot.IsValid())
|
|
{
|
|
//
|
|
swlPivot.type = XCA_SWL;
|
|
swlPivot.symbol = iConditions.symbol;
|
|
swlPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isSWLFinishedSameLast)
|
|
{
|
|
//
|
|
swlPivot.Clean();
|
|
|
|
//
|
|
swlPivot.type = XCA_SWL;
|
|
swlPivot.symbol = iConditions.symbol;
|
|
swlPivot.period = iConditions.period;
|
|
|
|
//
|
|
swlPivot.to = cBar.time;
|
|
swlPivot.from = pBar.time;
|
|
swlPivot.value = iConditions.swingLowBuffer[cIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isSwingLowSameLast)
|
|
{
|
|
//
|
|
swlPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = swlPivot.reserve;
|
|
if (pBar.low == pSWL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
swlPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isSWLStartSameLast)
|
|
{
|
|
//
|
|
double reserve = swlPivot.reserve;
|
|
if (cBar.low == cSWL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetDown()
|
|
: MathMax(reserve, cBar.GetDown());
|
|
}
|
|
if (pBar.low == pSWL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
if (reserve == 0 || reserve == swlPivot.value)
|
|
{
|
|
reserve = swlPivot.value + (5 * points);
|
|
}
|
|
swlPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
swlPivot.IsValid() &&
|
|
swlPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
swlPivot,
|
|
swlPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
swlPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// Peak SWH Res Pivot ...
|
|
if (detectPeakSWHResPivot)
|
|
{
|
|
//
|
|
if (!peakSWHResPivot.IsValid())
|
|
{
|
|
//
|
|
peakSWHResPivot.type = XCA_PEAKSWHRES;
|
|
peakSWHResPivot.symbol = iConditions.symbol;
|
|
peakSWHResPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isFinishedPeakIsPivot)
|
|
{
|
|
//
|
|
peakSWHResPivot.Clean();
|
|
|
|
//
|
|
peakSWHResPivot.type = XCA_PEAKSWHRES;
|
|
peakSWHResPivot.symbol = iConditions.symbol;
|
|
peakSWHResPivot.period = iConditions.period;
|
|
|
|
//
|
|
peakSWHResPivot.to = pBar.time;
|
|
peakSWHResPivot.from = pBar.time;
|
|
peakSWHResPivot.value = iConditions.peakBuffer[pIDX];
|
|
peakSWHResPivot.reserve = iConditions.peakGoldenBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isPeakIsPivot)
|
|
{
|
|
//
|
|
peakSWHResPivot.from = pBar.time;
|
|
|
|
//
|
|
peakSWHResPivot.reserve =
|
|
peakSWHResPivot.reserve == 0
|
|
? iConditions.peakGoldenBuffer[pIDX]
|
|
: MathMax(peakSWHResPivot.reserve, iConditions.peakGoldenBuffer[pIDX]);
|
|
}
|
|
|
|
//
|
|
if (isStartPeakIsPivot)
|
|
{
|
|
//
|
|
has = peakSWHResPivot.IsValid() &&
|
|
peakSWHResPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
peakSWHResPivot,
|
|
peakSWHResPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
XCAPVTick peakTick;
|
|
has = peakTick.Init(peakSWHResPivot);
|
|
if (has)
|
|
{
|
|
//
|
|
AddPVTick(
|
|
peakTick,
|
|
peakTicks //
|
|
);
|
|
}
|
|
|
|
//
|
|
peakTick.Clean();
|
|
}
|
|
|
|
//
|
|
peakSWHResPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// Vale SWL Sup Pivot ...
|
|
if (detectValeSWLSupPivot)
|
|
{
|
|
//
|
|
if (!valeSWLSupPivot.IsValid())
|
|
{
|
|
//
|
|
valeSWLSupPivot.type = XCA_VALESWLSUP;
|
|
valeSWLSupPivot.symbol = iConditions.symbol;
|
|
valeSWLSupPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isFinishedValeIsPivot)
|
|
{
|
|
//
|
|
valeSWLSupPivot.Clean();
|
|
|
|
//
|
|
valeSWLSupPivot.type = XCA_VALESWLSUP;
|
|
valeSWLSupPivot.symbol = iConditions.symbol;
|
|
valeSWLSupPivot.period = iConditions.period;
|
|
|
|
//
|
|
valeSWLSupPivot.to = pBar.time;
|
|
valeSWLSupPivot.from = pBar.time;
|
|
valeSWLSupPivot.value = iConditions.valeBuffer[pIDX];
|
|
valeSWLSupPivot.reserve = iConditions.valeGoldenBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isValeIsPivot)
|
|
{
|
|
//
|
|
valeSWLSupPivot.from = pBar.time;
|
|
|
|
//
|
|
valeSWLSupPivot.reserve =
|
|
valeSWLSupPivot.reserve == 0
|
|
? iConditions.valeGoldenBuffer[pIDX]
|
|
: MathMin(valeSWLSupPivot.reserve, iConditions.valeGoldenBuffer[pIDX]);
|
|
}
|
|
|
|
//
|
|
if (isStartValeIsPivot)
|
|
{
|
|
//
|
|
has = valeSWLSupPivot.IsValid() &&
|
|
valeSWLSupPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
valeSWLSupPivot,
|
|
valeSWLSupPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
XCAPVTick valeTick;
|
|
has = valeTick.Init(valeSWLSupPivot);
|
|
if (has)
|
|
{
|
|
//
|
|
AddPVTick(
|
|
valeTick,
|
|
valeTicks //
|
|
);
|
|
}
|
|
|
|
//
|
|
valeTick.Clean();
|
|
}
|
|
|
|
//
|
|
valeSWLSupPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// KI Bullish ...
|
|
if (detectKIBullishPivot)
|
|
{
|
|
//
|
|
if (!kiBullishPivot.IsValid())
|
|
{
|
|
//
|
|
kiBullishPivot.type = XCA_KI_BULL;
|
|
kiBullishPivot.symbol = iConditions.symbol;
|
|
kiBullishPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (iConditions.isKISwitchedToBearish)
|
|
{
|
|
//
|
|
kiBullishPivot.Clean();
|
|
|
|
//
|
|
kiBullishPivot.type = XCA_KI_BULL;
|
|
kiBullishPivot.symbol = iConditions.symbol;
|
|
kiBullishPivot.period = iConditions.period;
|
|
|
|
//
|
|
kiBullishPivot.to = pBar.time;
|
|
kiBullishPivot.from = pBar.time;
|
|
kiBullishPivot.value = iConditions.kiBuffer[pIDX];
|
|
kiBullishPivot.reserve = iConditions.kiBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isKIBullish)
|
|
{
|
|
//
|
|
kiBullishPivot.from = cBar.time;
|
|
|
|
//
|
|
Add(
|
|
iConditions.kiBuffer[cIDX],
|
|
kiBullishPivot.values //
|
|
);
|
|
|
|
//
|
|
kiBullishPivot.value =
|
|
kiBullishPivot.value == 0
|
|
? iConditions.kiBuffer[cIDX]
|
|
: MathMin(iConditions.kiBuffer[cIDX], kiBullishPivot.value);
|
|
|
|
//
|
|
kiBullishPivot.reserve =
|
|
kiBullishPivot.reserve == 0
|
|
? iConditions.kiBuffer[cIDX]
|
|
: MathMax(iConditions.kiBuffer[cIDX], kiBullishPivot.reserve);
|
|
}
|
|
|
|
//
|
|
if (iConditions.isKISwitchedToBullish)
|
|
{
|
|
//
|
|
has =
|
|
kiBullishPivot.IsValid() &&
|
|
kiBullishPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
kiBullishPivot,
|
|
kiBullishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
kiBullishPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// KI Bearish ...
|
|
if (detectKIBearishPivot)
|
|
{
|
|
//
|
|
if (!kiBearishPivot.IsValid())
|
|
{
|
|
//
|
|
kiBearishPivot.type = XCA_KI_BEAR;
|
|
kiBearishPivot.symbol = iConditions.symbol;
|
|
kiBearishPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (iConditions.isKISwitchedToBullish)
|
|
{
|
|
//
|
|
kiBearishPivot.Clean();
|
|
|
|
//
|
|
kiBearishPivot.type = XCA_KI_BEAR;
|
|
kiBearishPivot.symbol = iConditions.symbol;
|
|
kiBearishPivot.period = iConditions.period;
|
|
|
|
//
|
|
kiBearishPivot.to = pBar.time;
|
|
kiBearishPivot.from = pBar.time;
|
|
kiBearishPivot.value = iConditions.kiBuffer[pIDX];
|
|
kiBearishPivot.reserve = iConditions.kiBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isKIBearish)
|
|
{
|
|
//
|
|
kiBearishPivot.from = cBar.time;
|
|
|
|
//
|
|
Add(
|
|
iConditions.kiBuffer[cIDX],
|
|
kiBearishPivot.values //
|
|
);
|
|
|
|
//
|
|
kiBearishPivot.value =
|
|
kiBearishPivot.value == 0
|
|
? iConditions.kiBuffer[cIDX]
|
|
: MathMax(iConditions.kiBuffer[cIDX], kiBearishPivot.value);
|
|
|
|
//
|
|
kiBearishPivot.reserve =
|
|
kiBearishPivot.reserve == 0
|
|
? iConditions.kiBuffer[cIDX]
|
|
: MathMin(iConditions.kiBuffer[cIDX], kiBearishPivot.reserve);
|
|
}
|
|
|
|
//
|
|
if (iConditions.isKISwitchedToBearish)
|
|
{
|
|
//
|
|
has =
|
|
kiBearishPivot.IsValid() &&
|
|
kiBearishPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
kiBearishPivot,
|
|
kiBearishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
kiBearishPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// FVG Bullish ...
|
|
if (detectFVGBullishPivot)
|
|
{
|
|
//
|
|
if (isBullishFVG)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = fvgBox.to;
|
|
iPivot.from = fvgBox.from;
|
|
iPivot.type = XCA_FVG_BULL;
|
|
iPivot.value = fvgBox.lower;
|
|
iPivot.reserve = fvgBox.upper;
|
|
iPivot.symbol = fvgBox.symbol;
|
|
iPivot.period = fvgBox.period;
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
fvgBullishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
double fValue =
|
|
fvgBox.IsBullish()
|
|
? cVale
|
|
: cPeak;
|
|
|
|
//
|
|
// XPVFVG Handling ...
|
|
AddOrUpdatePVFVG(
|
|
fValue,
|
|
iPivot,
|
|
pvFVGBullishPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// FVG Bearish ...
|
|
if (detectFVGBearishPivot)
|
|
{
|
|
//
|
|
if (isBearishFVG)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = fvgBox.to;
|
|
iPivot.from = fvgBox.from;
|
|
iPivot.type = XCA_FVG_BEAR;
|
|
iPivot.value = fvgBox.upper;
|
|
iPivot.reserve = fvgBox.lower;
|
|
iPivot.symbol = fvgBox.symbol;
|
|
iPivot.period = fvgBox.period;
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
fvgBearishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
double fValue =
|
|
fvgBox.IsBullish()
|
|
? cVale
|
|
: cPeak;
|
|
|
|
//
|
|
// XPVFVG Handling ...
|
|
AddOrUpdatePVFVG(
|
|
fValue,
|
|
iPivot,
|
|
pvFVGBearishPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// TKI Bullish ...
|
|
if (detectTKIBullishPivot)
|
|
{
|
|
//
|
|
if (!tkiBullishPivot.IsValid())
|
|
{
|
|
//
|
|
tkiBullishPivot.type = XCA_TKI_BULL;
|
|
tkiBullishPivot.symbol = iConditions.symbol;
|
|
tkiBullishPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (iConditions.isTKISwitchedToBearish)
|
|
{
|
|
//
|
|
tkiBullishPivot.Clean();
|
|
|
|
//
|
|
tkiBullishPivot.type = XCA_TKI_BULL;
|
|
tkiBullishPivot.symbol = iConditions.symbol;
|
|
tkiBullishPivot.period = iConditions.period;
|
|
|
|
//
|
|
tkiBullishPivot.to = pBar.time;
|
|
tkiBullishPivot.from = pBar.time;
|
|
tkiBullishPivot.value = iConditions.tkiBuffer[pIDX];
|
|
tkiBullishPivot.reserve = iConditions.tkiBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isTKIBullish)
|
|
{
|
|
//
|
|
tkiBullishPivot.from = cBar.time;
|
|
|
|
//
|
|
Add(
|
|
iConditions.tkiBuffer[cIDX],
|
|
tkiBullishPivot.values //
|
|
);
|
|
|
|
//
|
|
tkiBullishPivot.value =
|
|
tkiBullishPivot.value == 0
|
|
? iConditions.tkiBuffer[cIDX]
|
|
: MathMin(iConditions.tkiBuffer[cIDX], tkiBullishPivot.value);
|
|
|
|
//
|
|
tkiBullishPivot.reserve =
|
|
tkiBullishPivot.reserve == 0
|
|
? iConditions.tkiBuffer[cIDX]
|
|
: MathMax(iConditions.tkiBuffer[cIDX], tkiBullishPivot.reserve);
|
|
}
|
|
|
|
//
|
|
if (iConditions.isTKISwitchedToBullish)
|
|
{
|
|
//
|
|
has =
|
|
tkiBullishPivot.IsValid() &&
|
|
tkiBullishPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
tkiBullishPivot,
|
|
tkiBullishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
tkiBullishPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// TKI Bearish ...
|
|
if (detectTKIBearishPivot)
|
|
{
|
|
//
|
|
if (!tkiBearishPivot.IsValid())
|
|
{
|
|
//
|
|
tkiBearishPivot.type = XCA_TKI_BEAR;
|
|
tkiBearishPivot.symbol = iConditions.symbol;
|
|
tkiBearishPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (iConditions.isTKISwitchedToBullish)
|
|
{
|
|
//
|
|
tkiBearishPivot.Clean();
|
|
|
|
//
|
|
tkiBearishPivot.type = XCA_TKI_BEAR;
|
|
tkiBearishPivot.symbol = iConditions.symbol;
|
|
tkiBearishPivot.period = iConditions.period;
|
|
|
|
//
|
|
tkiBearishPivot.to = pBar.time;
|
|
tkiBearishPivot.from = pBar.time;
|
|
tkiBearishPivot.value = iConditions.tkiBuffer[pIDX];
|
|
tkiBearishPivot.reserve = iConditions.tkiBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isTKIBearish)
|
|
{
|
|
//
|
|
tkiBearishPivot.from = cBar.time;
|
|
|
|
//
|
|
Add(
|
|
iConditions.tkiBuffer[cIDX],
|
|
tkiBearishPivot.values //
|
|
);
|
|
|
|
//
|
|
tkiBearishPivot.value =
|
|
tkiBearishPivot.value == 0
|
|
? iConditions.tkiBuffer[cIDX]
|
|
: MathMax(iConditions.tkiBuffer[cIDX], tkiBearishPivot.value);
|
|
|
|
//
|
|
tkiBearishPivot.reserve =
|
|
tkiBearishPivot.reserve == 0
|
|
? iConditions.tkiBuffer[cIDX]
|
|
: MathMin(iConditions.tkiBuffer[cIDX], tkiBearishPivot.reserve);
|
|
}
|
|
|
|
//
|
|
if (iConditions.isTKISwitchedToBearish)
|
|
{
|
|
//
|
|
has =
|
|
tkiBearishPivot.IsValid() &&
|
|
tkiBearishPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
tkiBearishPivot,
|
|
tkiBearishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
tkiBearishPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// TREND Bullish ...
|
|
if (detectTrendBullishPivot)
|
|
{
|
|
//
|
|
if (!trendBullishPivot.IsValid())
|
|
{
|
|
//
|
|
trendBullishPivot.type = XCA_TREND_BULL;
|
|
trendBullishPivot.symbol = iConditions.symbol;
|
|
trendBullishPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (iConditions.isTrendSwitchedToBearish)
|
|
{
|
|
//
|
|
trendBullishPivot.Clean();
|
|
|
|
//
|
|
trendBullishPivot.type = XCA_TREND_BULL;
|
|
trendBullishPivot.symbol = iConditions.symbol;
|
|
trendBullishPivot.period = iConditions.period;
|
|
|
|
//
|
|
trendBullishPivot.to = pBar.time;
|
|
trendBullishPivot.from = pBar.time;
|
|
trendBullishPivot.value = iConditions.trendBuffer[pIDX];
|
|
trendBullishPivot.reserve = iConditions.trendBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isTrendBullish)
|
|
{
|
|
//
|
|
trendBullishPivot.from = cBar.time;
|
|
|
|
//
|
|
Add(
|
|
iConditions.trendBuffer[cIDX],
|
|
trendBullishPivot.values //
|
|
);
|
|
|
|
//
|
|
trendBullishPivot.value =
|
|
trendBullishPivot.value == 0
|
|
? iConditions.trendBuffer[cIDX]
|
|
: MathMin(iConditions.trendBuffer[cIDX], trendBullishPivot.value);
|
|
|
|
//
|
|
trendBullishPivot.reserve =
|
|
trendBullishPivot.reserve == 0
|
|
? iConditions.trendBuffer[cIDX]
|
|
: MathMax(iConditions.trendBuffer[cIDX], trendBullishPivot.reserve);
|
|
}
|
|
|
|
//
|
|
if (iConditions.isTrendSwitchedToBullish)
|
|
{
|
|
//
|
|
has =
|
|
trendBullishPivot.IsValid() &&
|
|
trendBullishPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
trendBullishPivot,
|
|
trendBullishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
trendBullishPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// TREND Bearish ...
|
|
if (detectTrendBearishPivot)
|
|
{
|
|
//
|
|
if (!trendBearishPivot.IsValid())
|
|
{
|
|
//
|
|
trendBearishPivot.type = XCA_TREND_BEAR;
|
|
trendBearishPivot.symbol = iConditions.symbol;
|
|
trendBearishPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (iConditions.isTrendSwitchedToBullish)
|
|
{
|
|
//
|
|
trendBearishPivot.Clean();
|
|
|
|
//
|
|
trendBearishPivot.type = XCA_TREND_BEAR;
|
|
trendBearishPivot.symbol = iConditions.symbol;
|
|
trendBearishPivot.period = iConditions.period;
|
|
|
|
//
|
|
trendBearishPivot.to = pBar.time;
|
|
trendBearishPivot.from = pBar.time;
|
|
trendBearishPivot.value = iConditions.trendBuffer[pIDX];
|
|
trendBearishPivot.reserve = iConditions.trendBuffer[pIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iConditions.isTrendBearish)
|
|
{
|
|
//
|
|
trendBearishPivot.from = cBar.time;
|
|
|
|
//
|
|
Add(
|
|
iConditions.trendBuffer[cIDX],
|
|
trendBearishPivot.values //
|
|
);
|
|
|
|
//
|
|
trendBearishPivot.value =
|
|
trendBearishPivot.value == 0
|
|
? iConditions.trendBuffer[cIDX]
|
|
: MathMax(iConditions.trendBuffer[cIDX], trendBearishPivot.value);
|
|
|
|
//
|
|
trendBearishPivot.reserve =
|
|
trendBearishPivot.reserve == 0
|
|
? iConditions.trendBuffer[cIDX]
|
|
: MathMin(iConditions.trendBuffer[cIDX], trendBearishPivot.reserve);
|
|
}
|
|
|
|
//
|
|
if (iConditions.isTrendSwitchedToBearish)
|
|
{
|
|
//
|
|
has =
|
|
trendBearishPivot.IsValid() &&
|
|
trendBearishPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
trendBearishPivot,
|
|
trendBearishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
trendBearishPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// TKITRND Bullish ...
|
|
if (detectTKITRNDBullishPivot)
|
|
{
|
|
//
|
|
if (!tkitrndBullishPivot.IsValid())
|
|
{
|
|
//
|
|
tkitrndBullishPivot.type = XCA_TKITRND_BULL;
|
|
tkitrndBullishPivot.symbol = iConditions.symbol;
|
|
tkitrndBullishPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (!isCTKITRNDBullish && isPTKITRNDBullish)
|
|
{
|
|
//
|
|
tkitrndBullishPivot.Clean();
|
|
|
|
//
|
|
tkitrndBullishPivot.type = XCA_TKITRND_BULL;
|
|
tkitrndBullishPivot.symbol = iConditions.symbol;
|
|
tkitrndBullishPivot.period = iConditions.period;
|
|
|
|
//
|
|
tkitrndBullishPivot.to = pBar.time;
|
|
tkitrndBullishPivot.from = pBar.time;
|
|
tkitrndBullishPivot.value = pTKITRNDMin;
|
|
tkitrndBullishPivot.reserve = pTKITRNDMax;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCTKITRNDBullish)
|
|
{
|
|
//
|
|
tkitrndBullishPivot.from = cBar.time;
|
|
|
|
//
|
|
Add(
|
|
cTKITRNDMin,
|
|
tkitrndBullishPivot.values //
|
|
);
|
|
|
|
//
|
|
Add(
|
|
cTKITRNDMax,
|
|
tkitrndBullishPivot.values //
|
|
);
|
|
|
|
//
|
|
tkitrndBullishPivot.value =
|
|
tkitrndBullishPivot.value == 0
|
|
? cTKITRNDMin
|
|
: MathMin(cTKITRNDMin, tkitrndBullishPivot.value);
|
|
|
|
//
|
|
tkitrndBullishPivot.reserve =
|
|
tkitrndBullishPivot.reserve == 0
|
|
? cTKITRNDMax
|
|
: MathMax(cTKITRNDMax, tkitrndBullishPivot.reserve);
|
|
}
|
|
|
|
//
|
|
if (!isCTKITRNDBullish)
|
|
{
|
|
//
|
|
has =
|
|
tkitrndBullishPivot.IsValid() &&
|
|
tkitrndBullishPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
tkitrndBullishPivot,
|
|
tkitrndBullishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
trendBullishPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// TKITRND Bearish ...
|
|
if (detectTKITRNDBearishPivot)
|
|
{
|
|
//
|
|
if (!tkitrndBearishPivot.IsValid())
|
|
{
|
|
//
|
|
tkitrndBearishPivot.type = XCA_TKITRND_BEAR;
|
|
tkitrndBearishPivot.symbol = iConditions.symbol;
|
|
tkitrndBearishPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (!isCTKITRNDBearish && isPTKITRNDBearish)
|
|
{
|
|
//
|
|
tkitrndBearishPivot.Clean();
|
|
|
|
//
|
|
tkitrndBearishPivot.type = XCA_TKITRND_BEAR;
|
|
tkitrndBearishPivot.symbol = iConditions.symbol;
|
|
tkitrndBearishPivot.period = iConditions.period;
|
|
|
|
//
|
|
tkitrndBearishPivot.to = pBar.time;
|
|
tkitrndBearishPivot.from = pBar.time;
|
|
tkitrndBearishPivot.value = pTKITRNDMax;
|
|
tkitrndBearishPivot.reserve = pTKITRNDMin;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCTKITRNDBearish)
|
|
{
|
|
//
|
|
tkitrndBearishPivot.from = cBar.time;
|
|
|
|
//
|
|
Add(
|
|
cTKITRNDMin,
|
|
tkitrndBearishPivot.values //
|
|
);
|
|
|
|
//
|
|
Add(
|
|
cTKITRNDMax,
|
|
tkitrndBearishPivot.values //
|
|
);
|
|
|
|
//
|
|
tkitrndBearishPivot.value =
|
|
tkitrndBearishPivot.value == 0
|
|
? cTKITRNDMax
|
|
: MathMax(cTKITRNDMax, tkitrndBearishPivot.value);
|
|
|
|
//
|
|
tkitrndBearishPivot.reserve =
|
|
tkitrndBearishPivot.reserve == 0
|
|
? cTKITRNDMin
|
|
: MathMin(cTKITRNDMin, tkitrndBearishPivot.reserve);
|
|
}
|
|
|
|
//
|
|
if (!isCTKITRNDBearish)
|
|
{
|
|
//
|
|
has =
|
|
tkitrndBearishPivot.IsValid() &&
|
|
tkitrndBearishPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
tkitrndBearishPivot,
|
|
tkitrndBearishPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
trendBearishPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// Cycles LL ...
|
|
if (detectCycleSameLLPivot)
|
|
{
|
|
//
|
|
// Short Cycle ...
|
|
if (!sSameLLPivot.IsValid())
|
|
{
|
|
//
|
|
sSameLLPivot.type = XCA_LL;
|
|
sSameLLPivot.symbol = iConditions.symbol;
|
|
sSameLLPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isSLLFinishedSame)
|
|
{
|
|
//
|
|
sSameLLPivot.Clean();
|
|
|
|
//
|
|
sSameLLPivot.type = XCA_LL;
|
|
sSameLLPivot.symbol = iConditions.symbol;
|
|
sSameLLPivot.period = iConditions.period;
|
|
|
|
//
|
|
sSameLLPivot.to = pBar.time;
|
|
sSameLLPivot.from = pBar.time;
|
|
sSameLLPivot.value = pSLL;
|
|
sSameLLPivot.reserve = pSLL;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCSLLSame)
|
|
{
|
|
//
|
|
sSameLLPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = sSameLLPivot.reserve;
|
|
if (pBar.low == pSLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
sSameLLPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isSLLStartSame)
|
|
{
|
|
//
|
|
double reserve = sSameLLPivot.reserve;
|
|
if (cBar.low == cSLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetDown()
|
|
: MathMax(reserve, cBar.GetDown());
|
|
}
|
|
if (pBar.low == pSLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
if (reserve == 0 || reserve == sSameLLPivot.value)
|
|
{
|
|
reserve = sSameLLPivot.value + (5 * points);
|
|
}
|
|
sSameLLPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
sSameLLPivot.IsValid() &&
|
|
sSameLLPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
sSameLLPivot,
|
|
sSameLLPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
sSameLLPivot.Clean();
|
|
}
|
|
|
|
//
|
|
// Medium Cycle ...
|
|
if (!mSameLLPivot.IsValid())
|
|
{
|
|
//
|
|
mSameLLPivot.type = XCA_LL;
|
|
mSameLLPivot.symbol = iConditions.symbol;
|
|
mSameLLPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isMLLFinishedSame)
|
|
{
|
|
//
|
|
mSameLLPivot.Clean();
|
|
|
|
//
|
|
mSameLLPivot.type = XCA_LL;
|
|
mSameLLPivot.symbol = iConditions.symbol;
|
|
mSameLLPivot.period = iConditions.period;
|
|
|
|
//
|
|
mSameLLPivot.to = pBar.time;
|
|
mSameLLPivot.from = pBar.time;
|
|
mSameLLPivot.value = pMLL;
|
|
mSameLLPivot.reserve = pMLL;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCMLLSame)
|
|
{
|
|
//
|
|
mSameLLPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = mSameLLPivot.reserve;
|
|
if (pBar.low == pMLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
mSameLLPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isMLLStartSame)
|
|
{
|
|
//
|
|
double reserve = mSameLLPivot.reserve;
|
|
if (cBar.low == cMLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetDown()
|
|
: MathMax(reserve, cBar.GetDown());
|
|
}
|
|
if (pBar.low == pMLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
if (reserve == 0 || reserve == mSameLLPivot.value)
|
|
{
|
|
reserve = mSameLLPivot.value + (5 * points);
|
|
}
|
|
mSameLLPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
mSameLLPivot.IsValid() &&
|
|
mSameLLPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
mSameLLPivot,
|
|
mSameLLPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
mSameLLPivot.Clean();
|
|
}
|
|
|
|
//
|
|
// Long Cycle ...
|
|
if (!lSameLLPivot.IsValid())
|
|
{
|
|
//
|
|
lSameLLPivot.type = XCA_LL;
|
|
lSameLLPivot.symbol = iConditions.symbol;
|
|
lSameLLPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isLLLFinishedSame)
|
|
{
|
|
//
|
|
lSameLLPivot.Clean();
|
|
|
|
//
|
|
lSameLLPivot.type = XCA_LL;
|
|
lSameLLPivot.symbol = iConditions.symbol;
|
|
lSameLLPivot.period = iConditions.period;
|
|
|
|
//
|
|
lSameLLPivot.to = pBar.time;
|
|
lSameLLPivot.from = pBar.time;
|
|
lSameLLPivot.value = pLLL;
|
|
lSameLLPivot.reserve = pLLL;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCLLLSame)
|
|
{
|
|
//
|
|
lSameLLPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = lSameLLPivot.reserve;
|
|
if (pBar.low == pLLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
lSameLLPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isLLLStartSame)
|
|
{
|
|
//
|
|
double reserve = lSameLLPivot.reserve;
|
|
if (cBar.low == cLLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetDown()
|
|
: MathMax(reserve, cBar.GetDown());
|
|
}
|
|
if (pBar.low == pLLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
if (reserve == 0 || reserve == lSameLLPivot.value)
|
|
{
|
|
reserve = lSameLLPivot.value + (5 * points);
|
|
}
|
|
lSameLLPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
lSameLLPivot.IsValid() &&
|
|
lSameLLPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
lSameLLPivot,
|
|
lSameLLPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
lSameLLPivot.Clean();
|
|
}
|
|
|
|
//
|
|
// Hind Cycle ...
|
|
if (!hSameLLPivot.IsValid())
|
|
{
|
|
//
|
|
hSameLLPivot.type = XCA_LL;
|
|
hSameLLPivot.symbol = iConditions.symbol;
|
|
hSameLLPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isHLLFinishedSame)
|
|
{
|
|
//
|
|
hSameLLPivot.Clean();
|
|
|
|
//
|
|
hSameLLPivot.type = XCA_LL;
|
|
hSameLLPivot.symbol = iConditions.symbol;
|
|
hSameLLPivot.period = iConditions.period;
|
|
|
|
//
|
|
hSameLLPivot.to = pBar.time;
|
|
hSameLLPivot.from = pBar.time;
|
|
hSameLLPivot.value = pHLL;
|
|
hSameLLPivot.reserve = pHLL;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCHLLSame)
|
|
{
|
|
//
|
|
hSameLLPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = hSameLLPivot.reserve;
|
|
if (pBar.low == pHLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
hSameLLPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isHLLStartSame)
|
|
{
|
|
//
|
|
double reserve = hSameLLPivot.reserve;
|
|
if (cBar.low == cHLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetDown()
|
|
: MathMax(reserve, cBar.GetDown());
|
|
}
|
|
if (pBar.low == pHLL)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetDown()
|
|
: MathMax(reserve, pBar.GetDown());
|
|
}
|
|
if (reserve == 0 || reserve == hSameLLPivot.value)
|
|
{
|
|
reserve = hSameLLPivot.value + (5 * points);
|
|
}
|
|
hSameLLPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
hSameLLPivot.IsValid() &&
|
|
hSameLLPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
hSameLLPivot,
|
|
hSameLLPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
hSameLLPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// Cycles HH ...
|
|
if (detectCycleSameHHPivot)
|
|
{
|
|
//
|
|
// Short Cycle ...
|
|
if (!sSameHHPivot.IsValid())
|
|
{
|
|
//
|
|
sSameHHPivot.type = XCA_HH;
|
|
sSameHHPivot.symbol = iConditions.symbol;
|
|
sSameHHPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isSHHFinishedSame)
|
|
{
|
|
//
|
|
sSameHHPivot.Clean();
|
|
|
|
//
|
|
sSameHHPivot.type = XCA_HH;
|
|
sSameHHPivot.symbol = iConditions.symbol;
|
|
sSameHHPivot.period = iConditions.period;
|
|
|
|
//
|
|
sSameHHPivot.to = pBar.time;
|
|
sSameHHPivot.from = pBar.time;
|
|
sSameHHPivot.value = pSHH;
|
|
sSameHHPivot.reserve = pSHH;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCSHHSame)
|
|
{
|
|
//
|
|
sSameHHPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = sSameHHPivot.reserve;
|
|
if (pBar.high == pSHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
sSameHHPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isSHHStartSame)
|
|
{
|
|
//
|
|
double reserve = sSameHHPivot.reserve;
|
|
if (cBar.high == cSHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetUp()
|
|
: MathMin(reserve, cBar.GetUp());
|
|
}
|
|
if (pBar.high == pSHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
if (reserve == 0 || reserve == sSameHHPivot.value)
|
|
{
|
|
reserve = sSameHHPivot.value + (5 * points);
|
|
}
|
|
sSameHHPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
sSameHHPivot.IsValid() &&
|
|
sSameHHPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
sSameHHPivot,
|
|
sSameHHPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
sSameHHPivot.Clean();
|
|
}
|
|
|
|
//
|
|
// Medium Cycle ...
|
|
if (!mSameHHPivot.IsValid())
|
|
{
|
|
//
|
|
mSameHHPivot.type = XCA_HH;
|
|
mSameHHPivot.symbol = iConditions.symbol;
|
|
mSameHHPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isMHHFinishedSame)
|
|
{
|
|
//
|
|
mSameHHPivot.Clean();
|
|
|
|
//
|
|
mSameHHPivot.type = XCA_HH;
|
|
mSameHHPivot.symbol = iConditions.symbol;
|
|
mSameHHPivot.period = iConditions.period;
|
|
|
|
//
|
|
mSameHHPivot.to = pBar.time;
|
|
mSameHHPivot.from = pBar.time;
|
|
mSameHHPivot.value = pMHH;
|
|
mSameHHPivot.reserve = pMHH;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCMHHSame)
|
|
{
|
|
//
|
|
mSameHHPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = mSameHHPivot.reserve;
|
|
if (pBar.high == pMHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
mSameHHPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isMHHStartSame)
|
|
{
|
|
//
|
|
double reserve = mSameHHPivot.reserve;
|
|
if (cBar.high == cMHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetUp()
|
|
: MathMin(reserve, cBar.GetUp());
|
|
}
|
|
if (pBar.high == pMHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
if (reserve == 0 || reserve == mSameHHPivot.value)
|
|
{
|
|
reserve = mSameHHPivot.value + (5 * points);
|
|
}
|
|
mSameHHPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
mSameHHPivot.IsValid() &&
|
|
mSameHHPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
mSameHHPivot,
|
|
mSameHHPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
mSameHHPivot.Clean();
|
|
}
|
|
|
|
//
|
|
// Long Cycle ...
|
|
if (!lSameHHPivot.IsValid())
|
|
{
|
|
//
|
|
lSameHHPivot.type = XCA_HH;
|
|
lSameHHPivot.symbol = iConditions.symbol;
|
|
lSameHHPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isLHHFinishedSame)
|
|
{
|
|
//
|
|
lSameHHPivot.Clean();
|
|
|
|
//
|
|
lSameHHPivot.type = XCA_HH;
|
|
lSameHHPivot.symbol = iConditions.symbol;
|
|
lSameHHPivot.period = iConditions.period;
|
|
|
|
//
|
|
lSameHHPivot.to = pBar.time;
|
|
lSameHHPivot.from = pBar.time;
|
|
lSameHHPivot.value = pLHH;
|
|
lSameHHPivot.reserve = pLHH;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCLHHSame)
|
|
{
|
|
//
|
|
lSameHHPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = lSameHHPivot.reserve;
|
|
if (pBar.high == pLHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
lSameHHPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isLHHStartSame)
|
|
{
|
|
//
|
|
double reserve = lSameHHPivot.reserve;
|
|
if (cBar.high == cLHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetUp()
|
|
: MathMin(reserve, cBar.GetUp());
|
|
}
|
|
if (pBar.high == pLHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
if (reserve == 0 || reserve == lSameHHPivot.value)
|
|
{
|
|
reserve = lSameHHPivot.value + (5 * points);
|
|
}
|
|
lSameHHPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
lSameHHPivot.IsValid() &&
|
|
lSameHHPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
lSameHHPivot,
|
|
lSameHHPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
lSameHHPivot.Clean();
|
|
}
|
|
|
|
//
|
|
// Hind Cycle ...
|
|
if (!hSameHHPivot.IsValid())
|
|
{
|
|
//
|
|
hSameHHPivot.type = XCA_HH;
|
|
hSameHHPivot.symbol = iConditions.symbol;
|
|
hSameHHPivot.period = iConditions.period;
|
|
|
|
//
|
|
if (isHHHFinishedSame)
|
|
{
|
|
//
|
|
hSameHHPivot.Clean();
|
|
|
|
//
|
|
hSameHHPivot.type = XCA_HH;
|
|
hSameHHPivot.symbol = iConditions.symbol;
|
|
hSameHHPivot.period = iConditions.period;
|
|
|
|
//
|
|
hSameHHPivot.to = pBar.time;
|
|
hSameHHPivot.from = pBar.time;
|
|
hSameHHPivot.value = pHHH;
|
|
hSameHHPivot.reserve = pHHH;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCHHHSame)
|
|
{
|
|
//
|
|
hSameHHPivot.from = pBar.time;
|
|
|
|
//
|
|
double reserve = hSameHHPivot.reserve;
|
|
if (pBar.high == pHHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
hSameHHPivot.reserve = reserve;
|
|
}
|
|
|
|
//
|
|
if (isHHHStartSame)
|
|
{
|
|
//
|
|
double reserve = hSameHHPivot.reserve;
|
|
if (cBar.high == cHHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? cBar.GetUp()
|
|
: MathMin(reserve, cBar.GetUp());
|
|
}
|
|
if (pBar.high == pHHH)
|
|
{
|
|
//
|
|
reserve =
|
|
reserve == 0
|
|
? pBar.GetUp()
|
|
: MathMin(reserve, pBar.GetUp());
|
|
}
|
|
if (reserve == 0 || reserve == hSameHHPivot.value)
|
|
{
|
|
reserve = hSameHHPivot.value + (5 * points);
|
|
}
|
|
hSameHHPivot.reserve = reserve;
|
|
|
|
//
|
|
has =
|
|
hSameHHPivot.IsValid() &&
|
|
hSameHHPivot.GetAge() >= pivotVerifications;
|
|
if (has)
|
|
{
|
|
//
|
|
AddPivot(
|
|
hSameHHPivot,
|
|
hSameHHPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
}
|
|
|
|
//
|
|
hSameHHPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// RSI Peak ...
|
|
if (detectRSIPeakPivot)
|
|
{
|
|
//
|
|
if (isRSIPeak)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = cBar.time;
|
|
iPivot.from = p2Bar.time;
|
|
iPivot.value = pBar.high;
|
|
iPivot.type = XCA_RSI_PEAK;
|
|
iPivot.symbol = cBar.symbol;
|
|
iPivot.period = cBar.period;
|
|
|
|
//
|
|
Add(
|
|
cBar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
cBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.close,
|
|
iPivot.values //
|
|
);
|
|
|
|
//
|
|
iPivot.reserve = GetMin(iPivot.values);
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
rsiPeakPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// RSI Vale ...
|
|
if (detectRSIValePivot)
|
|
{
|
|
//
|
|
if (isRSIVale)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = cBar.time;
|
|
iPivot.from = p2Bar.time;
|
|
iPivot.value = pBar.low;
|
|
iPivot.type = XCA_RSI_VALE;
|
|
iPivot.symbol = cBar.symbol;
|
|
iPivot.period = cBar.period;
|
|
|
|
//
|
|
Add(
|
|
cBar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
cBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.close,
|
|
iPivot.values //
|
|
);
|
|
|
|
//
|
|
iPivot.reserve = GetMax(iPivot.values);
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
rsiValePivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// RSI Crossed Over OS ...
|
|
if (detectRSICrossedOverOSPivot)
|
|
{
|
|
//
|
|
if (isRSIBullishVPattern)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = cBar.time;
|
|
iPivot.from = p2Bar.time;
|
|
iPivot.value = pBar.low;
|
|
iPivot.type = XCA_RSI_COOS;
|
|
iPivot.symbol = cBar.symbol;
|
|
iPivot.period = cBar.period;
|
|
|
|
//
|
|
Add(
|
|
cBar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
cBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.close,
|
|
iPivot.values //
|
|
);
|
|
|
|
//
|
|
iPivot.reserve = GetMax(iPivot.values);
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
rsiCrossedOverOSPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// RSI Crossed Under OS ...
|
|
if (detectRSICrossedUnderOBPivot)
|
|
{
|
|
//
|
|
if (isRSIBearishVPattern)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = cBar.time;
|
|
iPivot.from = p2Bar.time;
|
|
iPivot.value = pBar.high;
|
|
iPivot.type = XCA_RSI_CUOB;
|
|
iPivot.symbol = cBar.symbol;
|
|
iPivot.period = cBar.period;
|
|
|
|
//
|
|
Add(
|
|
cBar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
cBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.close,
|
|
iPivot.values //
|
|
);
|
|
|
|
//
|
|
iPivot.reserve = GetMin(iPivot.values);
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
rsiCrossedUnderOBPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// CCI Peak ...
|
|
if (detectCCIPeakPivot)
|
|
{
|
|
//
|
|
if (isCCIPeak)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = cBar.time;
|
|
iPivot.from = p2Bar.time;
|
|
iPivot.value = pBar.high;
|
|
iPivot.type = XCA_CCI_PEAK;
|
|
iPivot.symbol = cBar.symbol;
|
|
iPivot.period = cBar.period;
|
|
|
|
//
|
|
Add(
|
|
cBar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
cBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.close,
|
|
iPivot.values //
|
|
);
|
|
|
|
//
|
|
iPivot.reserve = GetMin(iPivot.values);
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
cciPeakPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// CCI Vale ...
|
|
if (detectCCIValePivot)
|
|
{
|
|
//
|
|
if (isCCIVale)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = cBar.time;
|
|
iPivot.from = p2Bar.time;
|
|
iPivot.value = pBar.low;
|
|
iPivot.type = XCA_CCI_VALE;
|
|
iPivot.symbol = cBar.symbol;
|
|
iPivot.period = cBar.period;
|
|
|
|
//
|
|
Add(
|
|
cBar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
cBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.close,
|
|
iPivot.values //
|
|
);
|
|
|
|
//
|
|
iPivot.reserve = GetMax(iPivot.values);
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
cciValePivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// CCI Crossed Over OS ...
|
|
if (detectCCICrossedOverOSPivot)
|
|
{
|
|
//
|
|
if (isCCIBullishVPattern)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = cBar.time;
|
|
iPivot.from = p2Bar.time;
|
|
iPivot.value = pBar.low;
|
|
iPivot.type = XCA_CCI_COOS;
|
|
iPivot.symbol = cBar.symbol;
|
|
iPivot.period = cBar.period;
|
|
|
|
//
|
|
Add(
|
|
cBar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.low,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
cBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.close,
|
|
iPivot.values //
|
|
);
|
|
|
|
//
|
|
iPivot.reserve = GetMax(iPivot.values);
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
cciCrossedOverOSPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// CCI Crossed Under OS ...
|
|
if (detectCCICrossedUnderOBPivot)
|
|
{
|
|
//
|
|
if (isCCIBearishVPattern)
|
|
{
|
|
//
|
|
XCAPivot iPivot;
|
|
|
|
//
|
|
iPivot.to = cBar.time;
|
|
iPivot.from = p2Bar.time;
|
|
iPivot.value = pBar.high;
|
|
iPivot.type = XCA_CCI_CUOB;
|
|
iPivot.symbol = cBar.symbol;
|
|
iPivot.period = cBar.period;
|
|
|
|
//
|
|
Add(
|
|
cBar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.high,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
cBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
pBar.close,
|
|
iPivot.values //
|
|
);
|
|
Add(
|
|
p2Bar.close,
|
|
iPivot.values //
|
|
);
|
|
|
|
//
|
|
iPivot.reserve = GetMin(iPivot.values);
|
|
|
|
//
|
|
AddPivot(
|
|
iPivot,
|
|
cciCrossedUnderOBPivots,
|
|
maxAllowedPivots //
|
|
);
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
start++;
|
|
|
|
//
|
|
zBar.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
p2Bar.Clean();
|
|
fvgBox.Clean();
|
|
iConditions.Clean();
|
|
}
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
void Validate(
|
|
XBoxZone &unAvailableBoxes[],
|
|
int barIndex = 0 //
|
|
)
|
|
{
|
|
//
|
|
// Do All Pivots Validation ...
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
XCAPivot tmp[];
|
|
bool has = false;
|
|
|
|
//
|
|
int zIDX = 0;
|
|
int cIDX = zIDX + 1;
|
|
int pIDX = cIDX + 1;
|
|
int p2IDX = pIDX + 1;
|
|
|
|
//
|
|
// Implement Validation Senarios ...
|
|
|
|
//
|
|
// PEAKS ...
|
|
|
|
//
|
|
has = HasPeakPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
peakPivots,
|
|
tmp //
|
|
);
|
|
Clean(peakPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
peakPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// VALES ...
|
|
|
|
//
|
|
has = HasValePivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
valePivots,
|
|
tmp //
|
|
);
|
|
Clean(valePivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
valePivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// PEAK SWH RES ...
|
|
|
|
//
|
|
has = HasPeakSWHResPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
peakSWHResPivots,
|
|
tmp //
|
|
);
|
|
Clean(peakSWHResPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
peakSWHResPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// VALE SWL SUP ...
|
|
|
|
//
|
|
has = HasValeSWLSupPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
valeSWLSupPivots,
|
|
tmp //
|
|
);
|
|
Clean(valeSWLSupPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
valeSWLSupPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// SWING HIGH ...
|
|
|
|
//
|
|
has = HasSWHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
swhPivots,
|
|
tmp //
|
|
);
|
|
Clean(swhPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
swhPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// SWING LOW ...
|
|
|
|
//
|
|
has = HasSWLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
swlPivots,
|
|
tmp //
|
|
);
|
|
Clean(swlPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
swlPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
has = HasKIBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
kiBullishPivots,
|
|
tmp //
|
|
);
|
|
Clean(kiBullishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
kiBullishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasKIBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
kiBearishPivots,
|
|
tmp //
|
|
);
|
|
Clean(kiBearishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
kiBearishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// TKI ...
|
|
|
|
//
|
|
has = HasTKIBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
tkiBullishPivots,
|
|
tmp //
|
|
);
|
|
Clean(tkiBullishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
tkiBullishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasTKIBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
tkiBearishPivots,
|
|
tmp //
|
|
);
|
|
Clean(tkiBearishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
tkiBearishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// FVG ...
|
|
|
|
//
|
|
has = HasFVGBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
fvgBullishPivots,
|
|
tmp //
|
|
);
|
|
Clean(fvgBullishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
fvgBullishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasFVGBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
fvgBearishPivots,
|
|
tmp //
|
|
);
|
|
Clean(fvgBearishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
fvgBearishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// PVFVG ...
|
|
XCAPVPivot tmpPVFVG[];
|
|
|
|
//
|
|
has = HasPVFVGBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
pvFVGBullishPivots,
|
|
tmpPVFVG //
|
|
);
|
|
Clean(pvFVGBullishPivots);
|
|
while (HasChild(tmpPVFVG))
|
|
{
|
|
//
|
|
XCAPVPivot iPVFVG = tmpPVFVG[0];
|
|
ArrayRemove(
|
|
tmpPVFVG,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
XCAPivot tmpFVGs[];
|
|
Copy(
|
|
iPVFVG.pivots,
|
|
tmpFVGs //
|
|
);
|
|
Clean(iPVFVG.pivots);
|
|
while (HasChild(tmpFVGs))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmpFVGs[0];
|
|
ArrayRemove(
|
|
tmpFVGs,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
iPVFVG.pivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmpFVGs);
|
|
|
|
//
|
|
if (HasChild(iPVFVG.pivots))
|
|
{
|
|
//
|
|
AddRef(
|
|
iPVFVG,
|
|
pvFVGBullishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
Clean(tmpPVFVG);
|
|
}
|
|
|
|
//
|
|
has = HasPVFVGBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
pvFVGBearishPivots,
|
|
tmpPVFVG //
|
|
);
|
|
Clean(pvFVGBearishPivots);
|
|
while (HasChild(tmpPVFVG))
|
|
{
|
|
//
|
|
XCAPVPivot iPVFVG = tmpPVFVG[0];
|
|
ArrayRemove(
|
|
tmpPVFVG,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
XCAPivot tmpFVGs[];
|
|
Copy(
|
|
iPVFVG.pivots,
|
|
tmpFVGs //
|
|
);
|
|
Clean(iPVFVG.pivots);
|
|
while (HasChild(tmpFVGs))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmpFVGs[0];
|
|
ArrayRemove(
|
|
tmpFVGs,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
iPVFVG.pivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmpFVGs);
|
|
|
|
//
|
|
if (HasChild(iPVFVG.pivots))
|
|
{
|
|
//
|
|
AddRef(
|
|
iPVFVG,
|
|
pvFVGBearishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
Clean(tmpPVFVG);
|
|
}
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
has = HasTrendBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
trendBullishPivots,
|
|
tmp //
|
|
);
|
|
Clean(trendBullishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
trendBullishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasTrendBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
trendBearishPivots,
|
|
tmp //
|
|
);
|
|
Clean(trendBearishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
trendBearishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// TKITRND ...
|
|
|
|
//
|
|
has = HasTKITRNDBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
tkitrndBullishPivots,
|
|
tmp //
|
|
);
|
|
Clean(tkitrndBullishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
tkitrndBullishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasTKITRNDBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
tkitrndBearishPivots,
|
|
tmp //
|
|
);
|
|
Clean(tkitrndBearishPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
tkitrndBearishPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// SAME CYCLES HH / LL ...
|
|
|
|
//
|
|
has = HasSSameLLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
sSameLLPivots,
|
|
tmp //
|
|
);
|
|
Clean(sSameLLPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
sSameLLPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasSSameHHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
sSameHHPivots,
|
|
tmp //
|
|
);
|
|
Clean(sSameHHPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
sSameHHPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasMSameLLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
mSameLLPivots,
|
|
tmp //
|
|
);
|
|
Clean(mSameLLPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
mSameLLPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasMSameHHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
mSameHHPivots,
|
|
tmp //
|
|
);
|
|
Clean(mSameHHPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
mSameHHPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasLSameLLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
lSameLLPivots,
|
|
tmp //
|
|
);
|
|
Clean(lSameLLPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
lSameLLPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasLSameHHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
lSameHHPivots,
|
|
tmp //
|
|
);
|
|
Clean(lSameHHPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
lSameHHPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasHSameLLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
hSameLLPivots,
|
|
tmp //
|
|
);
|
|
Clean(hSameLLPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
hSameLLPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasHSameHHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
hSameHHPivots,
|
|
tmp //
|
|
);
|
|
Clean(hSameHHPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
hSameHHPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// OSCS ...
|
|
|
|
//
|
|
// RSI ...
|
|
|
|
//
|
|
has = HasRSIPeakPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
rsiPeakPivots,
|
|
tmp //
|
|
);
|
|
Clean(rsiPeakPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
rsiPeakPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasRSIValePivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
rsiValePivots,
|
|
tmp //
|
|
);
|
|
Clean(rsiValePivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
rsiValePivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasRSICrossedOverOSPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
rsiCrossedOverOSPivots,
|
|
tmp //
|
|
);
|
|
Clean(rsiCrossedOverOSPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
rsiCrossedOverOSPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasRSICrossedUnderOBPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
rsiCrossedUnderOBPivots,
|
|
tmp //
|
|
);
|
|
Clean(rsiCrossedUnderOBPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
rsiCrossedUnderOBPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// CCI ...
|
|
|
|
//
|
|
has = HasCCIPeakPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
cciPeakPivots,
|
|
tmp //
|
|
);
|
|
Clean(cciPeakPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
cciPeakPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasCCIValePivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
cciValePivots,
|
|
tmp //
|
|
);
|
|
Clean(cciValePivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
cciValePivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasCCICrossedOverOSPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
cciCrossedOverOSPivots,
|
|
tmp //
|
|
);
|
|
Clean(cciCrossedOverOSPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
cciCrossedOverOSPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
has = HasCCICrossedUnderOBPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
cciCrossedUnderOBPivots,
|
|
tmp //
|
|
);
|
|
Clean(cciCrossedUnderOBPivots);
|
|
while (HasChild(tmp))
|
|
{
|
|
//
|
|
XCAPivot iPivot = tmp[0];
|
|
ArrayRemove(
|
|
tmp,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
cciCrossedUnderOBPivots //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmp);
|
|
}
|
|
|
|
//
|
|
// PVTICKS ...
|
|
|
|
//
|
|
XCAPVTick tmpTicks[];
|
|
|
|
//
|
|
has = HasPeakTicks();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
peakTicks,
|
|
tmpTicks //
|
|
);
|
|
Clean(peakTicks);
|
|
while (HasChild(tmpTicks))
|
|
{
|
|
//
|
|
XCAPVTick iPVTick = tmpTicks[0];
|
|
ArrayRemove(
|
|
tmpTicks,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
XBoxZone iBox;
|
|
bool isBoxBreaked = false;
|
|
has = iPVTick.GetMaxVolumeBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
isBoxBreaked = IsBoxBreaked(
|
|
iBox,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPVTick.pivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has && !isBoxBreaked)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPVTick,
|
|
peakTicks //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmpTicks);
|
|
}
|
|
|
|
//
|
|
has = HasValeTicks();
|
|
if (has)
|
|
{
|
|
//
|
|
Copy(
|
|
valeTicks,
|
|
tmpTicks //
|
|
);
|
|
Clean(valeTicks);
|
|
while (HasChild(tmpTicks))
|
|
{
|
|
//
|
|
XCAPVTick iPVTick = tmpTicks[0];
|
|
ArrayRemove(
|
|
tmpTicks,
|
|
0,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
XBoxZone iBox;
|
|
bool isBoxBreaked = false;
|
|
has = iPVTick.GetMaxVolumeBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
isBoxBreaked = IsBoxBreaked(
|
|
iBox,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
has = IsPivotBreaked(
|
|
iPVTick.pivot,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!has && !isBoxBreaked)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPVTick,
|
|
valeTicks //
|
|
);
|
|
}
|
|
}
|
|
Clean(tmpTicks);
|
|
}
|
|
|
|
//
|
|
Clean(tmp);
|
|
Clean(tmpPVFVG);
|
|
Clean(tmpTicks);
|
|
}
|
|
|
|
//
|
|
int FillBullishBoxes(
|
|
XBoxZone &boxes[] //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
int count = 0;
|
|
bool has = false;
|
|
|
|
//
|
|
Clean(boxes);
|
|
|
|
//
|
|
has = HasSWLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountSWLPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = swlPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasValePivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountValePivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = valePivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasSSameLLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountSSameLLPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = sSameLLPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasMSameLLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountMSameLLPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = mSameLLPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasLSameLLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountLSameLLPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = lSameLLPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasHSameLLPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountHSameLLPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = hSameLLPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasKIBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountKIBullishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = kiBullishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasFVGBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountFVGBullishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = fvgBullishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasValeSWLSupPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountValeSWLSupPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = valeSWLSupPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasTKIBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountTKIBullishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = tkiBullishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasTrendBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountTrendBullishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = trendBullishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasTKITRNDBullishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountTKITRNDBullishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = tkitrndBullishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasRSIValePivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountRSIValePivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = rsiValePivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasRSICrossedOverOSPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountRSICrossedOverOSPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = rsiCrossedOverOSPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasCCIValePivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountCCIValePivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = cciValePivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasCCICrossedOverOSPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountCCICrossedOverOSPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = cciCrossedOverOSPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
result = ArraySize(boxes);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int FillBearishBoxes(
|
|
XBoxZone &boxes[] //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
int count = 0;
|
|
bool has = false;
|
|
|
|
//
|
|
Clean(boxes);
|
|
|
|
//
|
|
has = HasSWHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountSWHPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = swhPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasPeakPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountPeakPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = peakPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasSSameHHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountSSameHHPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = sSameHHPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasMSameHHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountMSameHHPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = mSameHHPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasLSameHHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountLSameHHPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = lSameHHPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasHSameHHPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountHSameHHPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = hSameHHPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasKIBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountKIBearishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = kiBearishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasFVGBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountFVGBearishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = fvgBearishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasPeakSWHResPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountPeakSWHResPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = peakSWHResPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasTKIBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountTKIBearishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = tkiBearishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasTrendBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountTrendBearishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = trendBearishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasTKITRNDBearishPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountTKITRNDBearishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = tkitrndBearishPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasRSIPeakPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountRSIPeakPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = rsiPeakPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasRSICrossedUnderOBPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountRSICrossedUnderOBPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = rsiCrossedUnderOBPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasCCIPeakPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountCCIPeakPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = cciPeakPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
has = HasCCICrossedUnderOBPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountCCICrossedUnderOBPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
has = cciCrossedUnderOBPivots[i].AsBox(iBox);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
boxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
result = ArraySize(boxes);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// POI Handlers ...
|
|
|
|
//
|
|
// PEAK ...
|
|
|
|
//
|
|
bool HasPeakPivots()
|
|
{
|
|
return HasChild(peakPivots);
|
|
}
|
|
|
|
//
|
|
int CountPeakPivots()
|
|
{
|
|
return ArraySize(peakPivots);
|
|
}
|
|
|
|
//
|
|
// VALE ...
|
|
|
|
//
|
|
bool HasValePivots()
|
|
{
|
|
return HasChild(valePivots);
|
|
}
|
|
|
|
//
|
|
int CountValePivots()
|
|
{
|
|
return ArraySize(valePivots);
|
|
}
|
|
|
|
//
|
|
// PEAK SWH Res ...
|
|
|
|
//
|
|
bool HasPeakSWHResPivots()
|
|
{
|
|
return HasChild(peakSWHResPivots);
|
|
}
|
|
|
|
//
|
|
int CountPeakSWHResPivots()
|
|
{
|
|
return ArraySize(peakSWHResPivots);
|
|
}
|
|
|
|
//
|
|
// VALE SWL Sup ...
|
|
|
|
//
|
|
bool HasValeSWLSupPivots()
|
|
{
|
|
return HasChild(valeSWLSupPivots);
|
|
}
|
|
|
|
//
|
|
int CountValeSWLSupPivots()
|
|
{
|
|
return ArraySize(valeSWLSupPivots);
|
|
}
|
|
|
|
//
|
|
// SWING High ...
|
|
|
|
//
|
|
bool HasSWHPivots()
|
|
{
|
|
return HasChild(swhPivots);
|
|
}
|
|
|
|
//
|
|
int CountSWHPivots()
|
|
{
|
|
return ArraySize(swhPivots);
|
|
}
|
|
|
|
//
|
|
// SWING Low ...
|
|
|
|
//
|
|
bool HasSWLPivots()
|
|
{
|
|
return HasChild(swlPivots);
|
|
}
|
|
|
|
//
|
|
int CountSWLPivots()
|
|
{
|
|
return ArraySize(swlPivots);
|
|
}
|
|
|
|
//
|
|
// KI ...
|
|
|
|
//
|
|
bool HasKIBullishPivots()
|
|
{
|
|
return HasChild(kiBullishPivots);
|
|
}
|
|
|
|
//
|
|
int CountKIBullishPivots()
|
|
{
|
|
return ArraySize(kiBullishPivots);
|
|
}
|
|
|
|
//
|
|
bool HasKIBearishPivots()
|
|
{
|
|
return HasChild(kiBearishPivots);
|
|
}
|
|
|
|
//
|
|
int CountKIBearishPivots()
|
|
{
|
|
return ArraySize(kiBearishPivots);
|
|
}
|
|
|
|
//
|
|
// TKI ...
|
|
|
|
//
|
|
bool HasTKIBullishPivots()
|
|
{
|
|
return HasChild(tkiBullishPivots);
|
|
}
|
|
|
|
//
|
|
int CountTKIBullishPivots()
|
|
{
|
|
return ArraySize(tkiBullishPivots);
|
|
}
|
|
|
|
//
|
|
bool HasTKIBearishPivots()
|
|
{
|
|
return HasChild(tkiBearishPivots);
|
|
}
|
|
|
|
//
|
|
int CountTKIBearishPivots()
|
|
{
|
|
return ArraySize(tkiBearishPivots);
|
|
}
|
|
|
|
//
|
|
// FVG ...
|
|
|
|
//
|
|
bool HasFVGBullishPivots()
|
|
{
|
|
return HasChild(fvgBullishPivots);
|
|
}
|
|
|
|
//
|
|
int CountFVGBullishPivots()
|
|
{
|
|
return ArraySize(fvgBullishPivots);
|
|
}
|
|
|
|
//
|
|
bool HasFVGBearishPivots()
|
|
{
|
|
return HasChild(fvgBearishPivots);
|
|
}
|
|
|
|
//
|
|
int CountFVGBearishPivots()
|
|
{
|
|
return ArraySize(fvgBearishPivots);
|
|
}
|
|
|
|
//
|
|
// PVFVG ...
|
|
|
|
//
|
|
bool HasPVFVGBullishPivots()
|
|
{
|
|
return HasChild(pvFVGBullishPivots);
|
|
}
|
|
|
|
//
|
|
int CountPVFVGBullishPivots()
|
|
{
|
|
return ArraySize(pvFVGBullishPivots);
|
|
}
|
|
|
|
//
|
|
bool HasPVFVGBearishPivots()
|
|
{
|
|
return HasChild(pvFVGBearishPivots);
|
|
}
|
|
|
|
//
|
|
int CountPVFVGBearishPivots()
|
|
{
|
|
return ArraySize(pvFVGBearishPivots);
|
|
}
|
|
|
|
//
|
|
// TREND ...
|
|
|
|
//
|
|
bool HasTrendBullishPivots()
|
|
{
|
|
return HasChild(trendBullishPivots);
|
|
}
|
|
|
|
//
|
|
int CountTrendBullishPivots()
|
|
{
|
|
return ArraySize(trendBullishPivots);
|
|
}
|
|
|
|
//
|
|
bool HasTrendBearishPivots()
|
|
{
|
|
return HasChild(trendBearishPivots);
|
|
}
|
|
|
|
//
|
|
int CountTrendBearishPivots()
|
|
{
|
|
return ArraySize(trendBearishPivots);
|
|
}
|
|
|
|
//
|
|
// TKITRND ...
|
|
|
|
//
|
|
bool HasTKITRNDBullishPivots()
|
|
{
|
|
return HasChild(tkitrndBullishPivots);
|
|
}
|
|
|
|
//
|
|
int CountTKITRNDBullishPivots()
|
|
{
|
|
return ArraySize(tkitrndBullishPivots);
|
|
}
|
|
|
|
//
|
|
bool HasTKITRNDBearishPivots()
|
|
{
|
|
return HasChild(tkitrndBearishPivots);
|
|
}
|
|
|
|
//
|
|
int CountTKITRNDBearishPivots()
|
|
{
|
|
return ArraySize(tkitrndBearishPivots);
|
|
}
|
|
|
|
//
|
|
// SAME CYCLES HH / LL ...
|
|
|
|
//
|
|
bool HasSSameLLPivots()
|
|
{
|
|
return HasChild(sSameLLPivots);
|
|
}
|
|
|
|
//
|
|
int CountSSameLLPivots()
|
|
{
|
|
return ArraySize(sSameLLPivots);
|
|
}
|
|
|
|
//
|
|
bool HasMSameLLPivots()
|
|
{
|
|
return HasChild(mSameLLPivots);
|
|
}
|
|
|
|
//
|
|
int CountMSameLLPivots()
|
|
{
|
|
return ArraySize(mSameLLPivots);
|
|
}
|
|
|
|
//
|
|
bool HasLSameLLPivots()
|
|
{
|
|
return HasChild(lSameLLPivots);
|
|
}
|
|
|
|
//
|
|
int CountLSameLLPivots()
|
|
{
|
|
return ArraySize(lSameLLPivots);
|
|
}
|
|
|
|
//
|
|
bool HasHSameLLPivots()
|
|
{
|
|
return HasChild(hSameLLPivots);
|
|
}
|
|
|
|
//
|
|
int CountHSameLLPivots()
|
|
{
|
|
return ArraySize(hSameLLPivots);
|
|
}
|
|
|
|
//
|
|
bool HasSSameHHPivots()
|
|
{
|
|
return HasChild(sSameHHPivots);
|
|
}
|
|
|
|
//
|
|
int CountSSameHHPivots()
|
|
{
|
|
return ArraySize(sSameHHPivots);
|
|
}
|
|
|
|
//
|
|
bool HasMSameHHPivots()
|
|
{
|
|
return HasChild(mSameHHPivots);
|
|
}
|
|
|
|
//
|
|
int CountMSameHHPivots()
|
|
{
|
|
return ArraySize(mSameHHPivots);
|
|
}
|
|
|
|
//
|
|
bool HasLSameHHPivots()
|
|
{
|
|
return HasChild(lSameHHPivots);
|
|
}
|
|
|
|
//
|
|
int CountLSameHHPivots()
|
|
{
|
|
return ArraySize(lSameHHPivots);
|
|
}
|
|
|
|
//
|
|
bool HasHSameHHPivots()
|
|
{
|
|
return HasChild(hSameHHPivots);
|
|
}
|
|
|
|
//
|
|
int CountHSameHHPivots()
|
|
{
|
|
return ArraySize(hSameHHPivots);
|
|
}
|
|
|
|
//
|
|
// OSCS ...
|
|
|
|
//
|
|
// RSI ...
|
|
|
|
//
|
|
bool HasRSIPeakPivots()
|
|
{
|
|
return HasChild(rsiPeakPivots);
|
|
}
|
|
|
|
//
|
|
int CountRSIPeakPivots()
|
|
{
|
|
return ArraySize(rsiPeakPivots);
|
|
}
|
|
|
|
//
|
|
bool HasRSIValePivots()
|
|
{
|
|
return HasChild(rsiValePivots);
|
|
}
|
|
|
|
//
|
|
int CountRSIValePivots()
|
|
{
|
|
return ArraySize(rsiValePivots);
|
|
}
|
|
|
|
//
|
|
bool HasRSICrossedOverOSPivots()
|
|
{
|
|
return HasChild(rsiCrossedOverOSPivots);
|
|
}
|
|
|
|
//
|
|
int CountRSICrossedOverOSPivots()
|
|
{
|
|
return ArraySize(rsiCrossedOverOSPivots);
|
|
}
|
|
|
|
//
|
|
bool HasRSICrossedUnderOBPivots()
|
|
{
|
|
return HasChild(rsiCrossedUnderOBPivots);
|
|
}
|
|
|
|
//
|
|
int CountRSICrossedUnderOBPivots()
|
|
{
|
|
return ArraySize(rsiCrossedUnderOBPivots);
|
|
}
|
|
|
|
//
|
|
// CCI ...
|
|
|
|
//
|
|
bool HasCCIPeakPivots()
|
|
{
|
|
return HasChild(cciPeakPivots);
|
|
}
|
|
|
|
//
|
|
int CountCCIPeakPivots()
|
|
{
|
|
return ArraySize(cciPeakPivots);
|
|
}
|
|
|
|
//
|
|
bool HasCCIValePivots()
|
|
{
|
|
return HasChild(cciValePivots);
|
|
}
|
|
|
|
//
|
|
int CountCCIValePivots()
|
|
{
|
|
return ArraySize(cciValePivots);
|
|
}
|
|
|
|
//
|
|
bool HasCCICrossedOverOSPivots()
|
|
{
|
|
return HasChild(cciCrossedOverOSPivots);
|
|
}
|
|
|
|
//
|
|
int CountCCICrossedOverOSPivots()
|
|
{
|
|
return ArraySize(cciCrossedOverOSPivots);
|
|
}
|
|
|
|
//
|
|
bool HasCCICrossedUnderOBPivots()
|
|
{
|
|
return HasChild(cciCrossedUnderOBPivots);
|
|
}
|
|
|
|
//
|
|
int CountCCICrossedUnderOBPivots()
|
|
{
|
|
return ArraySize(cciCrossedUnderOBPivots);
|
|
}
|
|
|
|
//
|
|
// PVTICKS ...
|
|
|
|
//
|
|
bool HasPeakTicks()
|
|
{
|
|
return HasChild(peakTicks);
|
|
}
|
|
|
|
//
|
|
int CountPeakTicks()
|
|
{
|
|
return ArraySize(peakTicks);
|
|
}
|
|
|
|
//
|
|
bool HasValeTicks()
|
|
{
|
|
return HasChild(valeTicks);
|
|
}
|
|
|
|
//
|
|
int CountValeTicks()
|
|
{
|
|
return ArraySize(valeTicks);
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Prrivate ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
XCPOIDrawer *drawer;
|
|
XCXCAEAHelper *helper;
|
|
XCBarAnalyser *barAnalyser;
|
|
|
|
//
|
|
bool CheckPivotCommons(
|
|
XCAPivot &pivot,
|
|
XBoxZone &box,
|
|
XBoxZone &unAvailableBoxes[],
|
|
int barIndex = 0 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
box.Clean();
|
|
|
|
//
|
|
barIndex = NormalizeInt(barIndex, 0);
|
|
|
|
//
|
|
result = pivot.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int pivotToIDX = pivot.ToIndex();
|
|
|
|
//
|
|
result = pivotToIDX > barIndex;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = pivot.AsBox(box);
|
|
if (!result)
|
|
{
|
|
//
|
|
box.Clean();
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool CheckPivotIsAvailable(
|
|
XBoxZone &pivotBox,
|
|
XBoxZone &unAvailableBoxes[] //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = pivotBox.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int idx = -1;
|
|
bool isExists = FindBoxIndex(
|
|
idx,
|
|
pivotBox,
|
|
unAvailableBoxes //
|
|
);
|
|
result = !isExists;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsPivotBreaked(
|
|
XCAPivot &pivot,
|
|
XBoxZone &unAvailableBoxes[],
|
|
int barIndex = 0 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
XBoxZone iBox;
|
|
result = CheckPivotCommons(
|
|
pivot,
|
|
iBox,
|
|
unAvailableBoxes,
|
|
barIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
iBox.Clean();
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Box is Available Or Not ...
|
|
bool isAvailable = CheckPivotIsAvailable(
|
|
iBox,
|
|
unAvailableBoxes //
|
|
);
|
|
if (!isAvailable)
|
|
{
|
|
//
|
|
iBox.Clean();
|
|
|
|
//
|
|
// Assume UnAvailable Boes as Breaked ...
|
|
result = true;
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool isBullish = iBox.IsBullish();
|
|
double boundary =
|
|
isBullish
|
|
? iBox.lower
|
|
: iBox.upper;
|
|
|
|
//
|
|
int toIDX = iBox.ToIndex();
|
|
|
|
//
|
|
// for validating Box Break we have to wait At Least 3 Bars Close
|
|
// out of Box Boundary ...
|
|
int barsLength = 3;
|
|
|
|
//
|
|
int startCheckBreaktionBarIndex = toIDX - barsLength;
|
|
result = startCheckBreaktionBarIndex > 0 &&
|
|
barIndex < startCheckBreaktionBarIndex;
|
|
if (!result)
|
|
{
|
|
//
|
|
iBox.Clean();
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL cBar;
|
|
XOHCL pBar;
|
|
XOHCL p2Bar;
|
|
for (int i = barIndex; i < startCheckBreaktionBarIndex; i++)
|
|
{
|
|
//
|
|
result = cBar.Init(
|
|
iBox.symbol,
|
|
iBox.period,
|
|
i + 1 //
|
|
);
|
|
result =
|
|
result &&
|
|
cBar.GetPreviousBar(pBar);
|
|
result =
|
|
result &&
|
|
pBar.GetPreviousBar(p2Bar);
|
|
if (!result)
|
|
{
|
|
//
|
|
iBox.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
p2Bar.Clean();
|
|
|
|
//
|
|
break;
|
|
}
|
|
|
|
//
|
|
bool isBullishBreaked =
|
|
isBullish &&
|
|
cBar.close < boundary &&
|
|
pBar.close < boundary &&
|
|
p2Bar.close < boundary;
|
|
|
|
//
|
|
bool isBearishBreaked =
|
|
!isBullish &&
|
|
cBar.close > boundary &&
|
|
pBar.close > boundary &&
|
|
p2Bar.close > boundary;
|
|
|
|
//
|
|
result = isBullishBreaked ||
|
|
isBearishBreaked;
|
|
if (result)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
p2Bar.Clean();
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
p2Bar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsBoxBreaked(
|
|
XBoxZone &box,
|
|
XBoxZone &unAvailableBoxes[],
|
|
int barIndex = 0 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
barIndex = NormalizeInt(barIndex, 0);
|
|
|
|
//
|
|
result = box.IsValid();
|
|
if (!result)
|
|
{
|
|
//
|
|
// Assume Invalid Boxes as Broken ...
|
|
return true;
|
|
}
|
|
|
|
//
|
|
int idx = -1;
|
|
result = FindBoxIndex(
|
|
idx,
|
|
box,
|
|
unAvailableBoxes //
|
|
);
|
|
if (result)
|
|
{
|
|
//
|
|
// Assume UnAvailable Boxes as Broken ...
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int toIDX = box.ToIndex();
|
|
result = toIDX > barIndex;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool isBullish = box.IsBullish();
|
|
double boundary =
|
|
isBullish
|
|
? box.lower
|
|
: box.upper;
|
|
|
|
//
|
|
// for validating Box Break we have to wait At Least 3 Bars Close
|
|
// out of Box Boundary ...
|
|
int barsLength = 3;
|
|
|
|
//
|
|
int startCheckBreaktionBarIndex = toIDX - barsLength;
|
|
result = startCheckBreaktionBarIndex > 0 &&
|
|
barIndex < startCheckBreaktionBarIndex;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL cBar;
|
|
XOHCL pBar;
|
|
XOHCL p2Bar;
|
|
for (int i = barIndex; i < startCheckBreaktionBarIndex; i++)
|
|
{
|
|
//
|
|
result = cBar.Init(
|
|
box.symbol,
|
|
box.period,
|
|
i + 1 //
|
|
);
|
|
result =
|
|
result &&
|
|
cBar.GetPreviousBar(pBar);
|
|
result =
|
|
result &&
|
|
pBar.GetPreviousBar(p2Bar);
|
|
if (!result)
|
|
{
|
|
//
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
p2Bar.Clean();
|
|
|
|
//
|
|
break;
|
|
}
|
|
|
|
//
|
|
bool isBullishBreaked =
|
|
isBullish &&
|
|
cBar.close < boundary &&
|
|
pBar.close < boundary &&
|
|
p2Bar.close < boundary;
|
|
|
|
//
|
|
bool isBearishBreaked =
|
|
!isBullish &&
|
|
cBar.close > boundary &&
|
|
pBar.close > boundary &&
|
|
p2Bar.close > boundary;
|
|
|
|
//
|
|
result = isBullishBreaked ||
|
|
isBearishBreaked;
|
|
if (result)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
p2Bar.Clean();
|
|
}
|
|
|
|
//
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
p2Bar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
// |