432 lines
11 KiB
Plaintext
432 lines
11 KiB
Plaintext
//
|
|
bool isPeakPivot = conditions.isPeakIsPivot;
|
|
bool isValePivot = conditions.isValeIsPivot;
|
|
|
|
//
|
|
bool isPivotBullish = isValePivot &&
|
|
isCBarValidForBullish;
|
|
|
|
//
|
|
bool isPivotBearish = isPeakPivot &&
|
|
isCBarValidForBearish;
|
|
|
|
//
|
|
bool isPivotBullishReversal =
|
|
//
|
|
isPivotBullish &&
|
|
conditions.isKIBearish &&
|
|
conditions.isSarBearish &&
|
|
conditions.isTrendBearish &&
|
|
conditions.isLastSupportRejected
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isPivotBearishReversal =
|
|
//
|
|
isPivotBearish &&
|
|
conditions.isKIBullish &&
|
|
conditions.isSarBullish &&
|
|
conditions.isTrendBullish &&
|
|
conditions.isLastResistanceRejected
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isPivot = isPivotBullishReversal ||
|
|
isPivotBearishReversal;
|
|
|
|
if (isPivot)
|
|
{
|
|
Print("Pivot: ");
|
|
|
|
//
|
|
if (isPivotBullish)
|
|
{
|
|
Print("Bullish: ", isPivotBullish);
|
|
}
|
|
|
|
//
|
|
if (isPivotBearish)
|
|
{
|
|
Print("Bearish: ", isPivotBearish);
|
|
}
|
|
|
|
//
|
|
Print("Bullish Score: ", bullishScore);
|
|
Print("Bearish Score: ", bearishScore);
|
|
}
|
|
|
|
//
|
|
bool isOverFib2 = pBar.low > conditions.fiboLevel2Buffer[cIDX];
|
|
bool isUnderFib2 = pBar.high < conditions.fiboLevel2Buffer[cIDX];
|
|
|
|
//
|
|
bool isTrendBasedBullish =
|
|
isUnderFib2 &&
|
|
isCBarValidForBullish &&
|
|
conditions.isTrendRejectUp;
|
|
|
|
//
|
|
bool isTrendBasedBearish =
|
|
isOverFib2 &&
|
|
isCBarValidForBearish &&
|
|
conditions.isTrendRejectDown;
|
|
|
|
//
|
|
bool isTrend =
|
|
isTrendBasedBullish ||
|
|
isTrendBasedBearish;
|
|
|
|
//
|
|
if (isTrend)
|
|
{
|
|
Print("Trend Based ...");
|
|
}
|
|
|
|
//
|
|
bool isBarBreakedKITrendBullish =
|
|
cBar.IsBullish() &&
|
|
isCBarBullishMomentum &&
|
|
cBar.open < conditions.kiBuffer[cIDX] &&
|
|
cBar.close > conditions.kiBuffer[cIDX] &&
|
|
cBar.open < conditions.trendBuffer[cIDX] &&
|
|
cBar.close > conditions.trendBuffer[cIDX];
|
|
|
|
//
|
|
bool isBarBreakedKITrendBearish =
|
|
cBar.IsBearish() &&
|
|
isCBarBearishMomentum &&
|
|
cBar.open > conditions.kiBuffer[cIDX] &&
|
|
cBar.close < conditions.kiBuffer[cIDX] &&
|
|
cBar.open > conditions.trendBuffer[cIDX] &&
|
|
cBar.close > conditions.trendBuffer[cIDX];
|
|
|
|
//
|
|
bool isKITrendBreaked =
|
|
isBarBreakedKITrendBullish ||
|
|
isBarBreakedKITrendBearish;
|
|
|
|
//
|
|
if (isKITrendBreaked)
|
|
{
|
|
Print("KI Trend Breaked ...");
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
|
|
// while (index <= end)
|
|
// {
|
|
// //
|
|
// XCAEAConditions iConditions;
|
|
// bool has = helper.GetConditions(
|
|
// iConditions,
|
|
// index,
|
|
// 5 //
|
|
// );
|
|
// if (!has)
|
|
// {
|
|
// //
|
|
// iConditions.Clean();
|
|
// continue;
|
|
// }
|
|
|
|
// //
|
|
// zIDX = 0;
|
|
// cIDX = zIDX + 1;
|
|
// pIDX = cIDX + 1;
|
|
// p2IDX = pIDX + 1;
|
|
|
|
// //
|
|
// XOHCL cBar;
|
|
// has = cBar.Init(
|
|
// iConditions.symbol,
|
|
// iConditions.period,
|
|
// index + 1 //
|
|
// );
|
|
// if (!has)
|
|
// {
|
|
// //
|
|
// cBar.Clean();
|
|
// iConditions.Clean();
|
|
// continue;
|
|
// }
|
|
|
|
// //
|
|
// // Read Reuired Data ...
|
|
|
|
// //
|
|
// // KI ...
|
|
|
|
// //
|
|
// 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];
|
|
|
|
// //
|
|
// // TKI ...
|
|
|
|
// //
|
|
// 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];
|
|
|
|
// //
|
|
// // TREND ...
|
|
|
|
// //
|
|
// 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];
|
|
|
|
// //
|
|
// // SWING Low ...
|
|
|
|
// //
|
|
// double cSWL = iConditions.swingLowBuffer[cIDX];
|
|
// double pSWL = iConditions.swingLowBuffer[pIDX];
|
|
// double p2SWL = iConditions.swingLowBuffer[p2IDX];
|
|
|
|
// //
|
|
// // SWING High ...
|
|
|
|
// //
|
|
// double cSWH = iConditions.swingHighBuffer[cIDX];
|
|
// double pSWH = iConditions.swingHighBuffer[pIDX];
|
|
// double p2SWH = iConditions.swingHighBuffer[p2IDX];
|
|
|
|
// //
|
|
// // PEAK ...
|
|
|
|
// //
|
|
// double cPeak = iConditions.peakBuffer[cIDX];
|
|
// double pPeak = iConditions.peakBuffer[pIDX];
|
|
// double p2Peak = iConditions.peakBuffer[p2IDX];
|
|
|
|
// //
|
|
// // VALE ...
|
|
|
|
// //
|
|
// double cVale = iConditions.valeBuffer[cIDX];
|
|
// double pVale = iConditions.valeBuffer[pIDX];
|
|
// double p2Vale = iConditions.valeBuffer[p2IDX];
|
|
|
|
// //
|
|
// // Required Condirions ...
|
|
|
|
// //
|
|
// bool isTKITRNDBullish =
|
|
// iConditions.isKIBullish &&
|
|
// iConditions.isTKIBullish &&
|
|
// iConditions.isTrendBullish;
|
|
|
|
// //
|
|
// bool isTKITRNDBearish =
|
|
// iConditions.isKIBearish &&
|
|
// iConditions.isTKIBearish &&
|
|
// iConditions.isTrendBearish;
|
|
|
|
// //
|
|
// XBoxZone iBox;
|
|
|
|
// //
|
|
// // Check FVG ...
|
|
// bool isFVG = barAnalyser.IsFVG(
|
|
// cBar,
|
|
// iBox,
|
|
// false // Force Same Bars ...
|
|
// );
|
|
// if (isFVG)
|
|
// {
|
|
// //
|
|
// // Validate FVG ...
|
|
// bool isFVGBullish = iBox.IsBullish();
|
|
|
|
// // //
|
|
// // isFVG =
|
|
// // isFVGBullish
|
|
// // ? isTKITRNDBullish
|
|
// // : isTKITRNDBearish;
|
|
|
|
// //
|
|
// if (isFVG)
|
|
// {
|
|
// //
|
|
// XCBoxObject *iObj;
|
|
// has = drawer.DrawBox(
|
|
// iBox,
|
|
// iObj //
|
|
// );
|
|
// if (has)
|
|
// {
|
|
// iObj.BoxWidth(2);
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// //
|
|
// index++;
|
|
// cBar.Clean();
|
|
// iConditions.Clean();
|
|
// }
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
XBoxZone tmpFVGBoxes[];
|
|
|
|
//
|
|
int index = barIndex;
|
|
int end = index + loopback;
|
|
while (index <= end)
|
|
{
|
|
//
|
|
XOHCL cBar;
|
|
bool has = cBar.Init(
|
|
helper.GetSymbol(),
|
|
helper.GetPeriod(),
|
|
index + 1 //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
cBar.Clean();
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check FVG ...
|
|
XBoxZone iBox;
|
|
bool isFVG = barAnalyser.IsFVG(
|
|
cBar,
|
|
iBox,
|
|
false // Force Same Bars ...
|
|
);
|
|
if (isFVG)
|
|
{
|
|
//
|
|
AddBox(
|
|
iBox,
|
|
tmpFVGBoxes //
|
|
);
|
|
}
|
|
|
|
//
|
|
index++;
|
|
cBar.Clean();
|
|
}
|
|
|
|
//
|
|
int idx = -1;
|
|
bool has = false;
|
|
if (HasChild(tmpFVGBoxes))
|
|
{
|
|
//
|
|
while (HasChild(tmpFVGBoxes))
|
|
{
|
|
//
|
|
idx = GetYoungest(tmpFVGBoxes);
|
|
has = IsValidIndex(idx);
|
|
if (!has)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
XBoxZone iBox = tmpFVGBoxes[idx];
|
|
ArrayRemove(
|
|
tmpFVGBoxes,
|
|
idx,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
// Here We Have to Validate FVG ...
|
|
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = drawer.DrawBox(
|
|
iBox,
|
|
iObj //
|
|
);
|
|
|
|
//
|
|
}
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
has = HasPeakPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = CountPeakPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCAPivot iPivot = peakPivots[i];
|
|
|
|
//
|
|
int toIDX = iPivot.ToIndex();
|
|
int fromIDX = iPivot.FromIndex();
|
|
has = IsValidIndex(toIDX) &&
|
|
IsValidIndex(fromIDX);
|
|
if (!has)
|
|
{
|
|
//
|
|
iPivot.Clean();
|
|
continue;
|
|
}
|
|
|
|
//
|
|
for (int j = toIDX; j <= fromIDX; j++) {
|
|
//
|
|
XCAEAConditions jConditions;
|
|
has = helper.GetConditions(
|
|
jConditions,
|
|
j,
|
|
5 //
|
|
);
|
|
if (!has) {
|
|
//
|
|
jConditions.Clean();
|
|
continue;
|
|
}
|
|
|
|
//
|
|
datetime jTime = GetBarTime(
|
|
jConditions.symbol,
|
|
jConditions.period,
|
|
j //
|
|
);
|
|
|
|
//
|
|
|
|
}
|
|
|
|
//
|
|
iPivot.Clean();
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|