Last Works ...
This commit is contained in:
@@ -174,50 +174,6 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
conditions.symbol = _symbol;
|
||||
conditions.period = _period;
|
||||
conditions.time = TimeCurrent();
|
||||
|
||||
//
|
||||
int conditionsLoopback = 7;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
result = xpvHelper.GetConditions(
|
||||
conditions.xpvConditions,
|
||||
cIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// X3MA ...
|
||||
result = x3maHelper.GetConditions(
|
||||
conditions.x3maConditions,
|
||||
cIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// X3VWAP ...
|
||||
result = x3vwapHelper.GetConditions(
|
||||
conditions.x3vwapConditions,
|
||||
cIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to Implement SMC Based Conditions ...
|
||||
result = DetectConditions(conditions);
|
||||
@@ -371,6 +327,137 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
int zIndex = 0;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
conditions.symbol = symbol;
|
||||
conditions.period = period;
|
||||
conditions.time = TimeCurrent();
|
||||
|
||||
//
|
||||
int conditionsLoopback = 7;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
result = xpvHelper.GetConditions(
|
||||
conditions.xpvConditions,
|
||||
cIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// X3MA ...
|
||||
result = x3maHelper.GetConditions(
|
||||
conditions.x3maConditions,
|
||||
cIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// X3VWAP ...
|
||||
result = x3vwapHelper.GetConditions(
|
||||
conditions.x3vwapConditions,
|
||||
cIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Swing Highs and Lows Based On XPV ...
|
||||
|
||||
//
|
||||
int samePivots = 40;
|
||||
int requiredPivots = 10;
|
||||
|
||||
//
|
||||
DetectPVPivots(
|
||||
cIndex,
|
||||
samePivots,
|
||||
requiredPivots,
|
||||
conditions.orderFlow //
|
||||
);
|
||||
|
||||
//
|
||||
int orderFlowCount = ArraySize(conditions.orderFlow);
|
||||
if (IsValidSize(orderFlowCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < orderFlowCount; i++)
|
||||
{
|
||||
//
|
||||
XPVPivot iPivot = conditions.orderFlow[i];
|
||||
|
||||
//
|
||||
XCXPVPivotObject *iObj;
|
||||
iObj = new XCXPVPivotObject();
|
||||
bool isCreated = iObj.Create(
|
||||
mPOIDrawer.ChartIdentification(),
|
||||
mPOIDrawer.SubWindowIdentification(),
|
||||
iPivot //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
if (iPivot.IsPeak())
|
||||
{
|
||||
//
|
||||
iObj.PivotWidth(1);
|
||||
iObj.PivotFill(false);
|
||||
iObj.PivotColor(clrAqua);
|
||||
iObj.PivotStyle(STYLE_SOLID);
|
||||
}
|
||||
|
||||
//
|
||||
if (iPivot.IsVale())
|
||||
{
|
||||
//
|
||||
iObj.PivotWidth(1);
|
||||
iObj.PivotFill(false);
|
||||
iObj.PivotStyle(STYLE_SOLID);
|
||||
iObj.PivotColor(clrMagenta);
|
||||
}
|
||||
|
||||
//
|
||||
AddObjectIfNotExists(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidSize(ArraySize(conditions.orderFlow));
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Filter Peaks and Vales ...
|
||||
|
||||
if (result)
|
||||
{
|
||||
Print("Result: ", result);
|
||||
}
|
||||
return false;
|
||||
|
||||
//
|
||||
// Detect Market Structures ...
|
||||
|
||||
@@ -820,6 +907,298 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect XPV Based POI(s) ...
|
||||
*
|
||||
* @param barIndex: Start Bar Index ...
|
||||
* @param minRepetition: minimum Repeate of POI for Validation ...
|
||||
* @param requiredPivots: Number of Min Requirement POI(s) ...
|
||||
* @param peaks: XPVPivot instance Array Reference ...
|
||||
* @param vales: XPVPivot instance Array Reference ...
|
||||
* @param maxAllowedLoopbackBars: Integer, Max Allowed Loopback Bars ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectPVPivots(
|
||||
int barIndex,
|
||||
int minRepetition,
|
||||
int requiredPivots,
|
||||
XPVPivot &orderFlow[], // OrderFlows ...
|
||||
int maxAllowedLoopbackBars = 576 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (maxAllowedLoopbackBars <= 0)
|
||||
{
|
||||
maxAllowedLoopbackBars = 1000;
|
||||
}
|
||||
|
||||
//
|
||||
int start = barIndex;
|
||||
int end = start + maxAllowedLoopbackBars;
|
||||
|
||||
//
|
||||
Clean(orderFlow);
|
||||
|
||||
//
|
||||
result = minRepetition > 0 &&
|
||||
requiredPivots > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
double peak = 0;
|
||||
XPVPivot peaks[];
|
||||
int peakRepeate = 0;
|
||||
int peakToBarIndex = 0;
|
||||
int peakFromBarIndex = 0;
|
||||
|
||||
//
|
||||
double vale = 0;
|
||||
XPVPivot vales[];
|
||||
int valeRepeate = 0;
|
||||
int valeToBarIndex = 0;
|
||||
int valeFromBarIndex = 0;
|
||||
|
||||
//
|
||||
bool canLookupPeak = true;
|
||||
bool canLookupVale = true;
|
||||
bool canLookup = true;
|
||||
while (canLookup)
|
||||
{
|
||||
//
|
||||
// Check Peak ...
|
||||
double iPeak = xpvHelper.GetPeak(barIndex);
|
||||
if (iPeak != peak)
|
||||
{
|
||||
//
|
||||
if (peak != 0 &&
|
||||
peakRepeate >= minRepetition)
|
||||
{
|
||||
//
|
||||
bool isExists = false;
|
||||
int count = ArraySize(peaks);
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPVPivot iPivot = peaks[i];
|
||||
|
||||
//
|
||||
if (iPivot.upper == iPeak)
|
||||
{
|
||||
//
|
||||
isExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isExists)
|
||||
{
|
||||
//
|
||||
XPVPivot iPivot;
|
||||
|
||||
//
|
||||
iPivot.lower = 0;
|
||||
iPivot.upper = peak;
|
||||
iPivot.symbol = symbol;
|
||||
iPivot.period = period;
|
||||
iPivot.type = XPV_PEAK;
|
||||
iPivot.repetition = peakRepeate;
|
||||
iPivot.to = iTime(
|
||||
symbol,
|
||||
period,
|
||||
peakToBarIndex //
|
||||
);
|
||||
iPivot.from = iTime(
|
||||
symbol,
|
||||
period,
|
||||
peakFromBarIndex //
|
||||
);
|
||||
|
||||
//
|
||||
iPivot.lower = iPivot.CalculateLower();
|
||||
|
||||
//
|
||||
bool isValid = iPivot.IsValid();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
peaks //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
peak = iPeak;
|
||||
peakRepeate = 0;
|
||||
peakFromBarIndex = 0;
|
||||
peakToBarIndex = barIndex;
|
||||
}
|
||||
else if (iPeak == peak)
|
||||
{
|
||||
//
|
||||
peakRepeate++;
|
||||
peakFromBarIndex = barIndex;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Vale ...
|
||||
double iVale = xpvHelper.GetVale(barIndex);
|
||||
if (iVale != vale)
|
||||
{
|
||||
//
|
||||
if (vale != 0 &&
|
||||
valeRepeate >= minRepetition)
|
||||
{
|
||||
//
|
||||
bool isExists = false;
|
||||
int count = ArraySize(vales);
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPVPivot iPivot = vales[i];
|
||||
|
||||
//
|
||||
if (iPivot.lower == iVale)
|
||||
{
|
||||
//
|
||||
isExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isExists)
|
||||
{
|
||||
//
|
||||
XPVPivot iPivot;
|
||||
|
||||
//
|
||||
iPivot.upper = 0;
|
||||
iPivot.lower = vale;
|
||||
iPivot.symbol = symbol;
|
||||
iPivot.period = period;
|
||||
iPivot.type = XPV_VALE;
|
||||
iPivot.repetition = valeRepeate;
|
||||
iPivot.to = iTime(
|
||||
symbol,
|
||||
period,
|
||||
valeToBarIndex //
|
||||
);
|
||||
iPivot.from = iTime(
|
||||
symbol,
|
||||
period,
|
||||
valeFromBarIndex //
|
||||
);
|
||||
|
||||
//
|
||||
iPivot.upper = iPivot.CalculateUpper();
|
||||
|
||||
//
|
||||
bool isValid = iPivot.IsValid();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
vales //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
vale = iVale;
|
||||
valeRepeate = 0;
|
||||
valeFromBarIndex = 0;
|
||||
valeToBarIndex = barIndex;
|
||||
}
|
||||
else if (iVale == vale)
|
||||
{
|
||||
//
|
||||
valeRepeate++;
|
||||
valeFromBarIndex = barIndex;
|
||||
}
|
||||
|
||||
//
|
||||
canLookupPeak = ArraySize(peaks) < requiredPivots;
|
||||
canLookupVale = ArraySize(vales) < requiredPivots;
|
||||
canLookup = barIndex < end &&
|
||||
(canLookupPeak ||
|
||||
canLookupVale);
|
||||
if (canLookup)
|
||||
{
|
||||
barIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidSize(ArraySize(peaks)) ||
|
||||
IsValidSize(ArraySize(vales));
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Order Flow ...
|
||||
Copy(
|
||||
peaks,
|
||||
orderFlow,
|
||||
false //
|
||||
);
|
||||
Copy(
|
||||
vales,
|
||||
orderFlow,
|
||||
false //
|
||||
);
|
||||
int count = ArraySize(orderFlow);
|
||||
result = IsValidSize(orderFlow);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Sort Pivots ...
|
||||
SortPivots(orderFlow);
|
||||
|
||||
//
|
||||
// Filter Broken Order Flows ...
|
||||
FilterBrokenPivots(orderFlow);
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION orderFlowDirection;
|
||||
result = DetectPivotDirection(
|
||||
orderFlow,
|
||||
orderFlowDirection //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Specified States Market Structure ...
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user