prepare for test ...

This commit is contained in:
2025-02-02 00:37:22 +03:30
parent 959a4f417a
commit f60bc18d73
7 changed files with 3751 additions and 721 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+111
View File
@@ -0,0 +1,111 @@
//+------------------------------------------------------------------+
//| BOS_CHOCH.mq5|
//| Copyright 2023, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2
#property indicator_color1 clrGreen
#property indicator_color2 clrRed
#property indicator_width1 2
#property indicator_width2 2
// Indicator Buffers
double BOSBuffer[];
double CHOCHBuffer[];
// Input parameters
input int lookbackPeriod = 50; // Number of candles to look back for structure analysis
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
// Set up indicator buffers
SetIndexBuffer(0, BOSBuffer, INDICATOR_DATA);
SetIndexBuffer(1, CHOCHBuffer, INDICATOR_DATA);
// Set up indicator labels
IndicatorSetString(INDICATOR_SHORTNAME, "BOS & CHOCH Detector");
IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
// Loop through all candles
for (int i = prev_calculated; i < rates_total; i++)
{
// Detect BOS (Break of Structure)
if (IsBOS(i, high, low, lookbackPeriod))
{
BOSBuffer[i] = high[i]; // Mark BOS on the chart
}
else
{
BOSBuffer[i] = EMPTY_VALUE;
}
// Detect CHOCH (Change of Character)
if (IsCHOCH(i, high, low, lookbackPeriod))
{
CHOCHBuffer[i] = low[i]; // Mark CHOCH on the chart
}
else
{
CHOCHBuffer[i] = EMPTY_VALUE;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+
//| Function to detect Break of Structure (BOS) |
//+------------------------------------------------------------------+
bool IsBOS(int index, const double &high[], const double &low[], int lookback)
{
// Check if the current high is higher than the previous highs
for (int i = 1; i <= lookback; i++)
{
if (index - i >= 0 && high[index] <= high[index - i])
{
return false;
}
}
return true;
}
//+------------------------------------------------------------------+
//| Function to detect Change of Character (CHOCH) |
//+------------------------------------------------------------------+
bool IsCHOCH(int index, const double &high[], const double &low[], int lookback)
{
// Check if the current low is lower than the previous lows
for (int i = 1; i <= lookback; i++)
{
if (index - i >= 0 && low[index] >= low[index - i])
{
return false;
}
}
return true;
}
@@ -855,6 +855,90 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Count Prev Peak Repetition ...
*
* @param barIndex: Integer ...
*
* @return ( int )
*/
int CountPrevPeakRepetition(
int barIndex = 0//
) {
//
int result = 0;
//
if (barIndex < 0) {
barIndex = 0;
}
//
int index = barIndex + 1;
double value = mX121Helper.xpvHelper.GetPeak(index);
index++;
//
bool canContinue = true;
while(canContinue) {
//
double iValue = mX121Helper.xpvHelper.GetPeak(index);
//
canContinue = iValue == value;
if (canContinue) {
//
index++;
result++;
}
}
//
return result;
}
/**
* Count Prev Vale Repetition ...
*
* @param barIndex: Integer ...
*
* @return ( int )
*/
int CountPrevValeRepetition(
int barIndex = 0//
) {
//
int result = 0;
//
if (barIndex < 0) {
barIndex = 0;
}
//
int index = barIndex + 1;
double value = mX121Helper.xpvHelper.GetVale(index);
index++;
//
bool canContinue = true;
while(canContinue) {
//
double iValue = mX121Helper.xpvHelper.GetVale(index);
//
canContinue = iValue == value;
if (canContinue) {
//
index++;
result++;
}
}
//
return result;
}
/**
* Get Cycle State and Update it ...
*
@@ -704,631 +704,19 @@ bool DetectX121SMCXHKPVSignalSetup(
;
//
// Detect Cycle State ...
//
double upper = 0;
double lower = 0;
bool hasYoungestOB = false;
bool isPriceOBValid = false;
bool isBullishHappens = false;
bool isBearishHappens = false;
XCOrderBlock *youngestOB = NULL;
bool hasPriceBox = conditions.priceBox.IsValid();
bool hasState = visionCycleHelper.GetCycleState(conditions.state);
//
// Detect Price Box if not Provided ...
if (hasState &&
!hasPriceBox)
{
//
hasPriceBox = DetectPriceInsideBox(
conditions.priceBox,
conditions.priceOB,
decisionXConditions,
conditions.state //
);
if (hasPriceBox)
{
conditions.priceOBAt = cTime;
}
}
//
if (hasPriceBox)
{
//
// Update Price Box Date ...
conditions.priceOB.To(cTime);
conditions.priceBox.to = cTime;
upper = conditions.priceOB.Upper();
lower = conditions.priceOB.Lower();
//
hasYoungestOB = conditions.state.GetYoungestOB(youngestOB);
//
// Here We Can Validate Box by Same Cycles Peaks and Vales ...
bool isBullish = IsBullish(conditions.priceBox.dir);
//
bool isPriceBoxSameAsOB =
//
conditions.priceBox.upper <= conditions.priceOB.Upper() &&
conditions.priceBox.lower >= conditions.priceOB.Lower()
//
;
//
int cIDX = 1;
//
bool isSameCyclePeaks =
//
triggerXConditions.peaksBuffer[cIDX] == decisionXConditions.peaksBuffer[cIDX] &&
decisionXConditions.peaksBuffer[cIDX] == analyseXConditions.peaksBuffer[cIDX] &&
analyseXConditions.peaksBuffer[cIDX] == verificationXConditions.peaksBuffer[cIDX]
//
;
//
bool isSameCycleVales =
//
triggerXConditions.valesBuffer[cIDX] == decisionXConditions.valesBuffer[cIDX] &&
decisionXConditions.valesBuffer[cIDX] == analyseXConditions.valesBuffer[cIDX] &&
analyseXConditions.valesBuffer[cIDX] == verificationXConditions.valesBuffer[cIDX]
//
;
//
// Check Validation Conditions ...
isPriceOBValid =
//
hasPriceBox &&
isPriceBoxSameAsOB &&
(isBullish
? isSameCycleVales
: isSameCyclePeaks)
//
;
//
// Check Conditions ...
//
X121Conditions xConditions = triggerXConditions;
//
isBullishHappens =
//
isPriceOBValid &&
isCBarBullishFormed &&
conditions.priceOB.IsBullish() &&
IsBullish(conditions.priceBox.dir) &&
//
(xConditions.isBreakedUpPrevSar ||
xConditions.isBreakedUpPrevStr ||
xConditions.isVWapMaxBreakedUp ||
xConditions.isBreakedUpPrevCheMax ||
xConditions.isBreakedUpPrevAtrLower) &&
//
(xConditions.isSarSwitchedToBullish ||
xConditions.isStrSwitchedToBullish ||
xConditions.isCheSwitchedToBullish ||
xConditions.isVWapSwitchedToBullishState ||
xConditions.isVWapSwitchedToBullishOrdered)
//
;
//
isBearishHappens =
//
isPriceOBValid &&
isCBarBearishFormed &&
conditions.priceOB.IsBearish() &&
IsBearish(conditions.priceBox.dir) &&
//
(xConditions.isBreakedDownPrevSar ||
xConditions.isBreakedDownPrevStr ||
xConditions.isVWapMinBreakedDown ||
xConditions.isBreakedDownPrevCheMin ||
xConditions.isBreakedDownPrevAtrUpper) &&
//
(xConditions.isSarSwitchedToBearish ||
xConditions.isStrSwitchedToBearish ||
xConditions.isCheSwitchedToBearish ||
xConditions.isVWapSwitchedToBearishState ||
xConditions.isVWapSwitchedToBearishOrdered)
//
;
//
if (!conditions.isPriceOBActed)
{
conditions.isPriceOBActed = isBullishHappens ||
isBearishHappens;
}
}
//
// Detect Accumulation ...
if (conditions.isPriceOBActed)
{
//
// Checking OB Breake on Side ...
if (!conditions.isPriceOBBreaked)
{
//
conditions.isPriceOBBreaked =
(conditions.priceOB.IsBullish() &&
IsBullish(conditions.priceBox.dir))
? (cBar.low < upper &&
cBar.high > upper &&
cBar.close > upper)
//
||
//
(pBar.high < upper &&
cBar.low > upper &&
cBar.open > upper)
: (cBar.high > lower &&
cBar.low < lower &&
cBar.close < lower)
//
||
//
(pBar.low > lower &&
cBar.high < lower &&
cBar.open < lower);
}
}
//
// Detect Distribution ...
bool isPriceOBUpperBrekedUp = false;
bool isPriceOBLowerBrekedDown = false;
if (conditions.isPriceOBBreaked)
{
//
isPriceOBUpperBrekedUp = IsBarBreak(
upper,
X_DIRECTION_BULLISH,
cBar //
);
//
isPriceOBLowerBrekedDown = IsBarBreak(
lower,
X_DIRECTION_BEARISH,
cBar //
);
}
// //
// // Draw ...
// XCBaseObject *drawnObjects[];
// int drawnObjectsCount = visionCycleHelper.DrawCycleState(
// conditions.state,
// drawnObjects //
// );
// //
// if (hasPriceBox)
// {
// //
// bool isBullish = IsBullish(conditions.priceBox.dir);
// color boxColor = isBullish ? clrYellow : clrOrange;
// //
// XCBoxObject *iObj;
// bool isCreated = visionCycleHelper.mPOIDrawer.CreateBox(
// conditions.priceBox,
// iObj,
// boxColor,
// 1,
// false,
// STYLE_DASHDOTDOT //
// );
// //
// if (isCreated)
// {
// //
// Add(
// (XCBaseObject *)iObj,
// drawnObjects //
// );
// }
// //
// XCBaseObject *priceOBObj = NULL;
// if (isBullish)
// {
// //
// XCBullishOrderBlockObject *iObj;
// isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBullishOrderBlock(
// conditions.priceOB,
// iObj //
// );
// //
// if (isCreated)
// {
// //
// iObj.ZoneWidth(2);
// iObj.ZoneColor(boxColor);
// iObj.ZoneStyle(STYLE_SOLID);
// //
// priceOBObj = (XCBaseObject *)iObj;
// }
// }
// else
// {
// //
// XCBearishOrderBlockObject *iObj;
// isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBearishOrderBlock(
// conditions.priceOB,
// iObj //
// );
// //
// if (isCreated)
// {
// //
// iObj.ZoneWidth(2);
// iObj.ZoneColor(boxColor);
// iObj.ZoneStyle(STYLE_SOLID);
// //
// priceOBObj = (XCBaseObject *)iObj;
// }
// }
// //
// if (isCreated)
// {
// //
// Add(
// priceOBObj,
// drawnObjects //
// );
// }
// }
//
//
//
//
// Check Verifications Conditions ...
//
// XHK ...
bool isXHKBullish = false;
bool isXHKBearish = false;
//
// XSAR ...
bool isXSarBullish = false;
bool isXSarBearish = false;
//
// XATR ...
bool isXAtrBullish = false;
bool isXAtrBearish = false;
//
// XSTR ...
bool isXStrBullish = false;
bool isXStrBearish = false;
//
// XVWAP ...
bool isXVWapBullish = false;
bool isXVWapBearish = false;
//
// XCHE ...
bool isXCheBullish = false;
bool isXCheBearish = false;
//
if (hasPriceBox)
{
//
// XHK ...
//
isXHKBullish =
//
// Trigger ...
triggerXConditions.isSMHKBullish &&
triggerXConditions.isRawHKBullish &&
triggerXConditions.isClosedOverSMHK &&
triggerXConditions.isClosedOverRawHK &&
(triggerXConditions.isBreakedUpSMHK ||
triggerXConditions.isBreakedUpRawHK) &&
triggerXConditions.isRawHKClosedOverSMHK &&
//
// Decision ...
decisionXConditions.isSMHKBullish &&
decisionXConditions.isRawHKBullish &&
decisionXConditions.isClosedOverSMHK &&
decisionXConditions.isClosedOverRawHK &&
(decisionXConditions.isBreakedUpSMHK ||
decisionXConditions.isBreakedUpRawHK) &&
decisionXConditions.isRawHKClosedOverSMHK &&
//
// Analyse ...
analyseXConditions.isSMHKBullish &&
analyseXConditions.isRawHKBullish &&
analyseXConditions.isClosedOverSMHK &&
analyseXConditions.isClosedOverRawHK &&
(analyseXConditions.isBreakedUpSMHK ||
analyseXConditions.isBreakedUpRawHK) &&
decisionXConditions.isRawHKClosedOverSMHK
//
;
//
isXHKBearish =
//
// Trigger ...
triggerXConditions.isSMHKBearish &&
triggerXConditions.isRawHKBearish &&
triggerXConditions.isClosedUnderSMHK &&
triggerXConditions.isClosedUnderRawHK &&
(triggerXConditions.isBreakedDownSMHK ||
triggerXConditions.isBreakedDownRawHK) &&
triggerXConditions.isRawHKClosedUnderSMHK &&
//
// Decision ...
decisionXConditions.isSMHKBearish &&
decisionXConditions.isRawHKBearish &&
decisionXConditions.isClosedUnderSMHK &&
decisionXConditions.isClosedUnderRawHK &&
(decisionXConditions.isBreakedDownSMHK ||
decisionXConditions.isBreakedDownRawHK) &&
decisionXConditions.isRawHKClosedUnderSMHK &&
//
// Analyse ...
analyseXConditions.isSMHKBearish &&
analyseXConditions.isRawHKBearish &&
analyseXConditions.isClosedUnderSMHK &&
analyseXConditions.isClosedUnderRawHK &&
(analyseXConditions.isBreakedDownSMHK ||
analyseXConditions.isBreakedDownRawHK) &&
analyseXConditions.isRawHKClosedUnderSMHK
//
;
//
// XSAR ...
//
isXSarBullish =
//
// Trigger ...
triggerXConditions.isSarBullish &&
triggerXConditions.isSarIncreased &&
//
// Decision ...
decisionXConditions.isSarBullish &&
decisionXConditions.isSarIncreased &&
//
// Analyse ...
analyseXConditions.isSarBullish &&
analyseXConditions.isSarIncreased
//
;
//
isXSarBearish =
//
// Trigger ...
triggerXConditions.isSarBearish &&
triggerXConditions.isSarDecreased &&
//
// Decision ...
decisionXConditions.isSarBearish &&
decisionXConditions.isSarDecreased &&
//
// Analyse ...
analyseXConditions.isSarBearish // &&
//
;
//
// XATR ...
//
isXAtrBullish =
//
// Trigger ...
triggerXConditions.isClosedOverAtrUpper &&
//
// Decision ...
decisionXConditions.isClosedOverAtrUpper
//
// Analyse ...
//
;
//
isXAtrBearish =
//
// Trigger ...
triggerXConditions.isClosedUnderAtrLower &&
//
// Decision ...
decisionXConditions.isClosedUnderAtrLower
//
// Analyse ...
//
;
//
// XSTR ...
//
isXStrBullish =
//
// Trigger ...
triggerXConditions.isStrBullish &&
//
// Decision ...
decisionXConditions.isStrBullish
//
// Analyse ...
//
;
//
isXStrBearish =
//
// Trigger ...
triggerXConditions.isStrBearish &&
//
// Decision ...
decisionXConditions.isStrBearish
//
// Analyse ...
//
;
//
// XVWAP ...
//
isXVWapBullish =
//
// Trigger ...
triggerXConditions.isVWapBullishState &&
triggerXConditions.isVWapBullishOrdered &&
//
// Decision ...
decisionXConditions.isVWapBullishState &&
decisionXConditions.isVWapBullishOrdered &&
//
// Analyse ...
analyseXConditions.isVWapBullishState &&
analyseXConditions.isVWapBullishOrdered
//
;
//
isXVWapBearish =
//
// Trigger ...
triggerXConditions.isVWapBearishState &&
triggerXConditions.isVWapBearishOrdered &&
//
// Decision ...
decisionXConditions.isVWapBearishState &&
decisionXConditions.isVWapBearishOrdered &&
//
// Analyse ...
analyseXConditions.isVWapBearishState &&
analyseXConditions.isVWapBearishOrdered
//
;
//
// XCHE ...
//
isXCheBullish =
//
// Trigger ...
triggerXConditions.isCheBullish &&
//
// Decision ...
decisionXConditions.isCheBullish &&
//
// Analyse ...
analyseXConditions.isCheBullish
//
;
//
isXCheBearish =
//
// Trigger ...
triggerXConditions.isCheBearish &&
//
// Decision ...
decisionXConditions.isCheBearish &&
//
// Analyse ...
analyseXConditions.isCheBearish
//
;
}
//
// Summarize Conditions ...
// Detect ...
//
bool isCondition1Bullish =
//
isPriceOBUpperBrekedUp &&
conditions.isPriceOBBreaked &&
conditions.priceOB.IsBearish() &&
//
// XHK ...
isXHKBullish &&
//
// XSAR ...
isXSarBullish &&
//
// XATR ...
isXAtrBullish &&
//
// XSTR ...
isXStrBullish &&
//
// XVWAP ...
isXVWapBullish &&
//
// XCHE ...
isXCheBullish &&
//
true
false
//
;
//
bool isCondition1Bearish =
//
isPriceOBLowerBrekedDown &&
conditions.isPriceOBBreaked &&
conditions.priceOB.IsBullish() &&
//
// XHK ...
isXHKBearish &&
//
// XSAR ...
isXSarBearish &&
//
// XATR ...
isXAtrBearish &&
//
// XSTR ...
isXStrBearish &&
//
// XVWAP ...
isXVWapBearish &&
//
// XCHE ...
isXCheBearish &&
//
true
false
//
;
@@ -1350,8 +738,8 @@ bool DetectX121SMCXHKPVSignalSetup(
);
//
double longPivot = lower; // triggerXConditions.valesBuffer[1];
double shortPivot = upper; // triggerXConditions.peaksBuffer[1];
double longPivot = triggerXConditions.valesBuffer[1];
double shortPivot = triggerXConditions.peaksBuffer[1];
//
// Manipulate Conditions Point ...
@@ -1395,24 +783,6 @@ bool DetectX121SMCXHKPVSignalSetup(
isBearish;
if (!result)
{
//
// Detect PriceOB Lifetime Bars ...
if (hasPriceBox)
{
//
int obLifetimeBars = (int)(cTime - conditions.priceOBAt) / PeriodSeconds(PERIOD_M1);
bool canReset =
//
!conditions.isPriceOBActed &&
obLifetimeBars >= resetAfterUnActedZoneInMinutes
//
;
if (canReset)
{
conditions.Clean();
}
}
//
// Cleanup Arrays ...
Clean(triggerPoiEvents);
+270 -83
View File
@@ -57,14 +57,17 @@ struct X121SMCStrategyXOBSSignalConditions
//
// Extwnsion ...
//
datetime vOBAt;
XCOrderBlock *vOB;
bool isVOBActivated;
//
datetime cOBAt;
XCOrderBlock *cOB;
bool isCOBActivated;
datetime cOBActivatedAt;
//
datetime aOBAt;
XCOrderBlock *aOB;
bool isAOBActivated;
datetime aOBActivatedAt;
//
// Constructor ...
@@ -188,15 +191,16 @@ struct X121SMCStrategyXOBSSignalConditions
point = 0;
//
vOB = NULL;
cOB = NULL;
//
vOBAt = NULL;
cOBAt = NULL;
cOBActivatedAt = NULL;
isCOBActivated = false;
//
isVOBActivated = false;
aOB = NULL;
aOBAt = NULL;
aOBActivatedAt = NULL;
isAOBActivated = false;
}
//
@@ -728,12 +732,6 @@ bool DetectX121SMCXOBSSignalSetup(
//
// Detect OrderBlocks ...
//
bool hasVOB =
conditions.vOB != NULL &&
conditions.vOB.IsValid() &&
IsValid(conditions.vOBAt);
//
bool hasCOB =
conditions.cOB != NULL &&
@@ -741,23 +739,23 @@ bool DetectX121SMCXOBSSignalSetup(
IsValid(conditions.cOBAt);
//
if (!hasVOB)
if (!hasCOB)
{
//
int poiEvntsCount = ArraySize(visionPoiEvents);
int poiEvntsCount = ArraySize(consolidationPoiEvents);
bool hasEvent = IsValidSize(poiEvntsCount);
if (hasEvent)
{
//
bool hasNewBullOB = Contains(
X_BULLISH_ORDERBLOCK_DETECTED,
visionPoiEvents //
consolidationPoiEvents //
);
//
bool hasNewBearOB = Contains(
X_BEARISH_ORDERBLOCK_DETECTED,
visionPoiEvents //
consolidationPoiEvents //
);
//
@@ -769,110 +767,155 @@ bool DetectX121SMCXOBSSignalSetup(
if (hasNewOB)
{
//
XCOrderBlock *ob = NULL;
if (hasNewBullOB)
{
//
int lastIDX = visionState.CountBullishOrderBlocks() - 1;
conditions.vOB = visionState.bullishOrderBlocks[lastIDX];
int lastIDX = consolidationState.CountBullishOrderBlocks() - 1;
ob = consolidationState.bullishOrderBlocks[lastIDX];
//
// Validate OB ...
}
else if (hasNewBearOB)
{
//
int lastIDX = visionState.CountBearishOrderBlocks() - 1;
conditions.vOB = visionState.bearishOrderBlocks[lastIDX];
int lastIDX = consolidationState.CountBearishOrderBlocks() - 1;
ob = consolidationState.bearishOrderBlocks[lastIDX];
//
// Validate OB ...
}
//
conditions.vOBAt = cTime;
if (ob != NULL && ob.IsValid())
{
//
conditions.cOB = ob;
//
hasVOB =
conditions.vOB != NULL &&
conditions.vOB.IsValid() &&
IsValid(conditions.vOBAt);
//
conditions.cOBAt = cTime;
//
hasCOB =
conditions.cOB != NULL &&
conditions.cOB.IsValid() &&
IsValid(conditions.cOBAt);
}
}
}
else
}
//
if (hasCOB)
{
conditions.cOB.To(cTime);
}
//
bool hasAOB =
conditions.aOB != NULL &&
conditions.aOB.IsValid() &&
IsValid(conditions.aOBAt);
//
if (hasCOB &&
!hasAOB)
{
//
int poiEvntsCount = ArraySize(analysePoiEvents);
bool hasEvent = IsValidSize(poiEvntsCount);
if (hasEvent)
{
//
X121SMCCycleState vState;
bool hasVState = visionCycleHelper.GetCycleState(vState);
bool hasNewBullOB = Contains(
X_BULLISH_ORDERBLOCK_DETECTED,
analysePoiEvents //
);
//
bool hasYoungestOB = vState.GetYoungestOB(conditions.vOB);
if (hasYoungestOB)
bool hasNewBearOB = Contains(
X_BEARISH_ORDERBLOCK_DETECTED,
analysePoiEvents //
);
//
bool hasNewOB =
hasNewBullOB ||
hasNewBearOB;
//
if (hasNewOB)
{
//
conditions.vOBAt = cTime;
XCOrderBlock *ob = NULL;
if (hasNewBullOB)
{
//
int lastIDX = analyseState.CountBullishOrderBlocks() - 1;
ob = analyseState.bullishOrderBlocks[lastIDX];
//
// Validate OB ...
}
else if (hasNewBearOB)
{
//
int lastIDX = analyseState.CountBearishOrderBlocks() - 1;
ob = analyseState.bearishOrderBlocks[lastIDX];
//
// Validate OB ...
}
//
hasVOB =
conditions.vOB != NULL &&
conditions.vOB.IsValid() &&
IsValid(conditions.vOBAt);
if (ob != NULL && ob.IsValid())
{
//
conditions.aOB = ob;
//
conditions.aOBAt = cTime;
//
hasAOB =
conditions.aOB != NULL &&
conditions.aOB.IsValid() &&
IsValid(conditions.aOBAt);
}
}
}
}
//
// Update To Time ...
if (hasVOB)
if (hasAOB)
{
//
conditions.vOB.To(cTime);
conditions.aOB.To(cTime);
}
//
// Vait for Order Block Activation ...
if (hasVOB &&
!conditions.isVOBActivated)
{
//
conditions.isVOBActivated =
//
cBar.low >= conditions.vOB.Lower() &&
cBar.high <= conditions.vOB.Upper() &&
//
bid >= conditions.vOB.Lower() &&
bid <= conditions.vOB.Upper()
//
;
}
//
// Check Result ...
result = hasVOB &&
conditions.isVOBActivated;
result = hasCOB &&
hasAOB;
if (!result)
{
return result;
}
//
// Check Market Trend ...
bool isTrendOveralBullish = hasVisionBullishTrend &&
hasConsolidationBullishTrend;
bool isTrendOveralBearish = hasVisionBearishTrend &&
hasConsolidationBearishTrend;
result = (isTrendOveralBullish &&
!isTrendOveralBearish) ||
(!isTrendOveralBullish &&
isTrendOveralBearish);
if (!result)
{
return result;
}
// DRAW ...
//
//
bool isBullishOB = conditions.vOB.IsBullish();
if (isBullishOB)
// Draw Orer Block ...
bool isBullishCOB = conditions.cOB.IsBullish();
if (isBullishCOB)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = visionCycleHelper
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
conditions.vOB,
conditions.cOB,
iObj //
);
}
@@ -880,14 +923,158 @@ bool DetectX121SMCXOBSSignalSetup(
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = visionCycleHelper
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
conditions.vOB,
conditions.cOB,
iObj //
);
}
bool isBullishAOB = conditions.aOB.IsBullish();
if (isBullishAOB)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = analyseCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
conditions.aOB,
iObj //
);
}
else
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = analyseCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
conditions.aOB,
iObj //
);
}
//
// Draw From Bar ...
XOHCL cOBFromBar;
bool hasCOBFromBar = cOBFromBar.Init(
conditions.cOB.GetSymbol(),
conditions.cOB.GetPeriod(),
conditions.cOB.From() //
);
if (hasCOBFromBar)
{
//
XCOHCLObject *barObject;
bool iCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBar(
cOBFromBar,
barObject //
);
}
//
// Draw From Bar ...
XOHCL aOBFromBar;
bool hasAOBFromBar = aOBFromBar.Init(
conditions.aOB.GetSymbol(),
conditions.aOB.GetPeriod(),
conditions.aOB.From() //
);
if (hasAOBFromBar)
{
//
XCOHCLObject *barObject;
bool iCreated = analyseCycleHelper
.mPOIDrawer
.CreateBar(
aOBFromBar,
barObject //
);
}
//
// END DRAW ...
//
//
// Check AOB Activation ...
if (!conditions.isAOBActivated)
{
//
int aPeakRepetition = analyseCycleHelper.CountPrevPeakRepetition();
int aValeRepetition = analyseCycleHelper.CountPrevValeRepetition();
//
bool isActivated =
//
bid >= conditions.aOB.Lower() &&
bid <= conditions.aOB.Upper() &&
//
cBar.low >= conditions.aOB.Lower() &&
cBar.high <= conditions.aOB.Upper() &&
//
(conditions.aOB.IsBullish()
? decisionXConditions.valesBuffer[1] >= conditions.aOB.Lower() &&
decisionXConditions.valesBuffer[1] <= conditions.aOB.Upper()
: decisionXConditions.peaksBuffer[1] >= conditions.aOB.Lower() &&
decisionXConditions.peaksBuffer[1] <= conditions.aOB.Upper())
//
;
//
if (isActivated)
{
//
conditions.aOBActivatedAt = cTime;
conditions.isAOBActivated = isActivated;
}
}
//
// Check COB Activation ...
if (!conditions.isCOBActivated)
{
//
int aPeakRepetition = analyseCycleHelper.CountPrevPeakRepetition();
int aValeRepetition = analyseCycleHelper.CountPrevValeRepetition();
//
bool isActivated =
//
bid >= conditions.cOB.Lower() &&
bid <= conditions.cOB.Upper() &&
//
cBar.low >= conditions.cOB.Lower() &&
cBar.high <= conditions.cOB.Upper() &&
//
(conditions.cOB.IsBullish()
? decisionXConditions.valesBuffer[1] >= conditions.cOB.Lower() &&
decisionXConditions.valesBuffer[1] <= conditions.cOB.Upper()
: decisionXConditions.peaksBuffer[1] >= conditions.cOB.Lower() &&
decisionXConditions.peaksBuffer[1] <= conditions.cOB.Upper())
//
;
//
if (isActivated)
{
//
conditions.cOBActivatedAt = cTime;
conditions.isCOBActivated = isActivated;
}
}
//
result = conditions.isAOBActivated ||
conditions.isCOBActivated;
if (!result)
{
return result;
}
//
double upper = 0;
double lower = 0;
@@ -1662,10 +1662,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{
//
useXSignal = false;
useXOBSSignal = true;
useXOBSSignal = false;
useXHKPVSignal = false;
useXOBPVSignal = false;
useXIOBPVSignal = false;
useXOBPVSignal = true;
useXIOBPVSignal = true;
//
string symbol = GetSymbol();