This commit is contained in:
2024-11-23 23:44:19 +03:30
parent a5e1f601d3
commit 0e2e474d46
3 changed files with 420 additions and 31 deletions
+105 -1
View File
@@ -1220,7 +1220,7 @@ class XCBarAnalyser : public XCBase
* @param bar: XOHCL instance ... * @param bar: XOHCL instance ...
* @param dir: ENUM_X_DIRECTION member ... * @param dir: ENUM_X_DIRECTION member ...
* @param extend: Integer ... * @param extend: Integer ...
* @param bodyPercent: Double ... * @param shadowPercent: Double ...
* *
* @return ( bool ) * @return ( bool )
*/ */
@@ -1298,6 +1298,110 @@ class XCBarAnalyser : public XCBase
return result; return result;
} }
/**
* Check Specified Bar is Engulfing Bar or not ...
*
* @param bar: XOHCL instance ...
* @param dir: ENUM_X_DIRECTION member ...
* @param extend: Integer ...
* @param bodyPercent: Double ...
*
* @return ( bool )
*/
bool IsEngulfBar(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
int extend = 1,
double bodyPercent = 60 //
)
{
//
bool result = false;
//
if (extend < 0)
{
extend = 0;
}
//
if (bodyPercent < 50)
{
bodyPercent = 50;
}
//
dir = X_DIRECTION_NONE;
//
result = bar.IsValid() &&
bar.Index() > 0;
if (!result)
{
return result;
}
//
// Previous Bar ...
XOHCL pBar;
result = bar.GetPreviousBar(pBar);
if (!result)
{
return result;
}
//
if (extend > 0)
{
//
result = IsExtended(
pBar,
extend //
);
//
if (!result)
{
return result;
}
}
//
// Check Engulfig ...
result =
bar.GetUp() > pBar.GetUp() &&
bar.GetDown() < pBar.GetDown();
if (!result)
{
return result;
}
//
// Check Engulfing Direction ...
bool isBullishEngulfed =
pBar.IsBearish() &&
bar.IsBullish();
bool isBearishEngulfed =
pBar.IsBullish() &&
bar.IsBearish();
//
result = isBullishEngulfed ||
isBearishEngulfed;
if (!result)
{
return result;
}
//
dir = isBullishEngulfed
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
return result;
}
// //
// Support and Resistance Zones ... // Support and Resistance Zones ...
+4 -1
View File
@@ -508,7 +508,10 @@ int OnCalculate(
for (int i = limit - 1; i >= 0 && !IsStopped(); i--) for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
{ {
// //
CalculateBuffers(i); if (i <= 1000)
{
CalculateBuffers(i);
}
} }
// //
@@ -181,31 +181,147 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
// Check Momentum Bar ... // Check Momentum Bar ...
ENUM_X_DIRECTION momentumBarDir; ENUM_X_DIRECTION momentumCBarDir;
bool isCMomentumBar = mBarAnalyser.IsMomentumBar( bool isCMomentumBar = mBarAnalyser.IsMomentumBar(
cBar, cBar,
momentumBarDir // momentumCBarDir //
); );
bool isCBullishMomentumBar = bool isCBullishMomentumBar =
isCMomentumBar && isCMomentumBar &&
IsBullish(momentumBarDir); IsBullish(momentumCBarDir);
bool isCBearishMomentumBar = bool isCBearishMomentumBar =
isCMomentumBar && isCMomentumBar &&
IsBearish(momentumBarDir); IsBearish(momentumCBarDir);
//
// Check Momentum Bar ...
ENUM_X_DIRECTION momentumPBarDir;
bool isPMomentumBar = mBarAnalyser.IsMomentumBar(
pBar,
momentumPBarDir //
);
bool isPBullishMomentumBar =
isPMomentumBar &&
IsBullish(momentumPBarDir);
bool isPBearishMomentumBar =
isPMomentumBar &&
IsBearish(momentumPBarDir);
// //
// Check Rejection Bar ... // Check Rejection Bar ...
ENUM_X_DIRECTION rejectionBarDir; ENUM_X_DIRECTION rejectionCBarDir;
bool isCRejectionBar = mBarAnalyser.IsRejectionBar( bool isCRejectionBar = mBarAnalyser.IsRejectionBar(
cBar, cBar,
rejectionBarDir // rejectionCBarDir //
); );
bool isCBullishRejectionBar = bool isCBullishRejectionBar =
isCRejectionBar && isCRejectionBar &&
IsBullish(rejectionBarDir); IsBullish(rejectionCBarDir);
bool isCBearishRejectionBar = bool isCBearishRejectionBar =
isCRejectionBar && isCRejectionBar &&
IsBearish(rejectionBarDir); IsBearish(rejectionCBarDir);
//
// Check Rejection Bar ...
ENUM_X_DIRECTION rejectionPBarDir;
bool isPRejectionBar = mBarAnalyser.IsRejectionBar(
pBar,
rejectionPBarDir //
);
bool isPBullishRejectionBar =
isPRejectionBar &&
IsBullish(rejectionPBarDir);
bool isPBearishRejectionBar =
isPRejectionBar &&
IsBearish(rejectionPBarDir);
//
// Check Engulfing ...
ENUM_X_DIRECTION engulfCBarDir;
bool isCEngulfed = mBarAnalyser.IsEngulfBar(
cBar,
engulfCBarDir //
);
bool isCBullishEngulfed =
isCEngulfed &&
IsBullish(engulfCBarDir);
bool isCBearishEngulfed =
isCEngulfed &&
IsBearish(engulfCBarDir);
//
// Check Engulfing ...
ENUM_X_DIRECTION engulfPBarDir;
bool isPEngulfed = mBarAnalyser.IsEngulfBar(
pBar,
engulfPBarDir //
);
bool isPBullishEngulfed =
isPEngulfed &&
IsBullish(engulfPBarDir);
bool isPBearishEngulfed =
isPEngulfed &&
IsBearish(engulfPBarDir);
//
bool isCRMEBullish =
//
isCBullishEngulfed
//
||
//
isCBullishMomentumBar
//
||
//
isCBullishRejectionBar
//
;
//
bool isPRMEBullish =
//
isPBullishEngulfed
//
||
//
isPBullishMomentumBar
//
||
//
isPBullishRejectionBar
//
;
//
bool isCRMEBearish =
//
isCBearishEngulfed
//
||
//
isCBearishMomentumBar
//
||
//
isCBearishRejectionBar
//
;
//
bool isPRMEBearish =
//
isPBearishEngulfed
//
||
//
isPBearishMomentumBar
//
||
//
isPBearishRejectionBar
//
;
// //
bool isSpreadPassed = IsSpreadPass(); bool isSpreadPassed = IsSpreadPass();
@@ -263,13 +379,17 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
// Price Close Over Pivot's High ... // Price Close Over Pivot's High ...
cBar.IsBullish() && cBar.IsBullish() &&
cBar.close > lastPivot.upper cBar.close > lastPivot.upper &&
(pBar.close < lastPivot.upper ||
pBar.low < lastPivot.upper)
// //
: :
// //
// Price Must Close Under Pivots Low ... // Price Must Close Under Pivots Low ...
cBar.IsBearish() && cBar.IsBearish() &&
cBar.close < lastPivot.lower cBar.close < lastPivot.lower &&
(pBar.close > lastPivot.lower ||
pBar.high > lastPivot.lower)
// //
; ;
bool hasCHOCH = bool hasCHOCH =
@@ -278,25 +398,50 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
// Price Close Under Pivot's Low ... // Price Close Under Pivot's Low ...
cBar.IsBearish() && cBar.IsBearish() &&
cBar.close < lastPivot.lower cBar.close < lastPivot.lower &&
(pBar.close > lastPivot.lower ||
pBar.high > lastPivot.lower)
// //
: :
// //
// Price Must Close Over Pivots High ... // Price Must Close Over Pivots High ...
cBar.IsBullish() && cBar.IsBullish() &&
cBar.close > lastPivot.upper cBar.close > lastPivot.upper &&
(pBar.close < lastPivot.upper ||
pBar.low < lastPivot.upper)
// //
; ;
// //
// BOS Signals ...
bool has_BOS_Long = false;
bool has_BOS_Short = false;
//
// CHOCH Signals ...
bool has_CHOCH_Long = false;
bool has_CHOCH_Short = false;
//
// SAR Signals ...
bool has_SAR_Long = false;
bool has_SAR_Short = false;
//
// PULLBACK Signals ...
bool has_PULLBK_Long = false;
bool has_PULLBK_Short = false;
//
// Detect BOS Or CHOCH Signals ...
if (hasBOS || hasCHOCH) if (hasBOS || hasCHOCH)
{ {
// //
// Do on CHOCH ... // Do on CHOCH ...
if (hasCHOCH) if (hasCHOCH)
{ {
//
hasLong = has_CHOCH_Long =
// //
!isOrderFlowBullish && !isOrderFlowBullish &&
cBar.IsBullish() && cBar.IsBullish() &&
@@ -305,7 +450,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
conditions.xchsarConditions.cSars[0] < cBar.low conditions.xchsarConditions.cSars[0] < cBar.low
// //
; ;
if (hasLong) if (has_CHOCH_Long)
{ {
// //
provider = "CHOCH-Long"; provider = "CHOCH-Long";
@@ -313,7 +458,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
} }
// //
hasShort = has_CHOCH_Short =
// //
isOrderFlowBullish && isOrderFlowBullish &&
cBar.IsBearish() && cBar.IsBearish() &&
@@ -322,12 +467,15 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
conditions.xchsarConditions.cSars[0] > cBar.high conditions.xchsarConditions.cSars[0] > cBar.high
// //
; ;
if (hasShort) if (has_CHOCH_Short)
{ {
// //
provider = "CHOCH-Short"; provider = "CHOCH-Short";
selectedSL = cBar.high; selectedSL = cBar.high;
} }
//
mLastCHOCHOn = TimeCurrent();
} }
// //
@@ -335,18 +483,17 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
if (hasBOS) if (hasBOS)
{ {
// //
hasLong = has_BOS_Long =
// //
isOrderFlowBullish && isOrderFlowBullish &&
isCRMEBullish &&
cBar.IsBullish() && cBar.IsBullish() &&
(isCBullishMomentumBar ||
isCBullishRejectionBar) &&
conditions.xchsarConditions.cSars[0] < cBar.low conditions.xchsarConditions.cSars[0] < cBar.low
// //
; ;
// //
if (hasLong) if (has_BOS_Long)
{ {
// //
provider = "BOS-Long"; provider = "BOS-Long";
@@ -354,23 +501,152 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
} }
// //
hasShort = has_BOS_Short =
// //
!isOrderFlowBullish && !isOrderFlowBullish &&
isCRMEBearish &&
cBar.IsBearish() && cBar.IsBearish() &&
(isCBearishMomentumBar ||
isCBearishRejectionBar) &&
conditions.xchsarConditions.cSars[0] > cBar.high conditions.xchsarConditions.cSars[0] > cBar.high
// //
; ;
if (hasShort) if (has_BOS_Short)
{ {
// //
provider = "BOS-Short"; provider = "BOS-Short";
selectedSL = cBar.high; selectedSL = cBar.high;
} }
//
mLastBOSOn = TimeCurrent();
} }
} }
else
{
//
// Check PSar is Equals to Peak or Vale ...
bool isSAREqualsToPeak =
conditions.xchsarConditions.cSars[0] == conditions.xpvConditions.peaks[1];
bool isSAREqualsToVale =
conditions.xchsarConditions.cSars[0] == conditions.xpvConditions.vales[1];
//
has_SAR_Long =
//
isSAREqualsToVale &&
isOrderFlowBullish &&
isPSarInDirectionOfOrderFlow
//
;
if (has_SAR_Long)
{
//
provider = "SAR_Long";
selectedSL = conditions.xchsarConditions.cSars[0];
}
//
has_SAR_Short =
//
isSAREqualsToPeak &&
!isOrderFlowBullish &&
isPSarInDirectionOfOrderFlow
//
;
if (has_SAR_Short)
{
//
provider = "SAR_Short";
selectedSL = conditions.xchsarConditions.cSars[0];
}
//
// Check PULLBK Conditions ...
//
has_PULLBK_Long =
//
isCRMEBullish &&
isPSarInDirectionOfOrderFlow &&
(cBar.low < conditions.x3maConditions.fasts[0] &&
cBar.GetDown() > conditions.x3maConditions.fasts[0]) &&
!(pBar.low < conditions.x3maConditions.fasts[1] &&
pBar.GetDown() > conditions.x3maConditions.fasts[1])
//
;
if (has_PULLBK_Long)
{
//
provider = "PULLBK-Long";
selectedSL = cBar.low;
}
//
has_PULLBK_Short =
//
isCRMEBearish &&
isPSarInDirectionOfOrderFlow &&
(cBar.high > conditions.x3maConditions.fasts[0] &&
cBar.GetUp() < conditions.x3maConditions.fasts[0]) &&
!(pBar.high > conditions.x3maConditions.fasts[1] &&
pBar.GetUp() < conditions.x3maConditions.fasts[1])
//
;
if (has_PULLBK_Short)
{
//
provider = "PULLBK-Short";
selectedSL = cBar.high;
}
}
//
// Combine all Signals Conditions ...
//
hasLong =
//
has_BOS_Long
//
||
//
has_CHOCH_Long
// //
// ||
// //
// // has_SAR_Long
// //
// ||
// //
// has_PULLBK_Long
// //
// ||
//
// false
//
;
//
hasShort =
//
has_BOS_Short
//
||
//
has_CHOCH_Short
// //
// ||
// //
// // has_SAR_Short
// //
// ||
// //
// has_PULLBK_Short
// //
// ||
//
// false
//
;
// //
result = hasLong || result = hasLong ||
@@ -428,6 +704,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
Print("PRV: ", provider); Print("PRV: ", provider);
RedrawOrderFlow();
ClearDraws(); ClearDraws();
// //
@@ -568,6 +845,11 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
XPVPivot mOrderFlow[]; XPVPivot mOrderFlow[];
ENUM_X_DIRECTION mOrderFlowDir; ENUM_X_DIRECTION mOrderFlowDir;
//
// Holds Last CHOCH and BOS time ...
datetime mLastBOSOn;
datetime mLastCHOCHOn;
// //
// Actions ... // Actions ...