last ...
This commit is contained in:
@@ -1653,6 +1653,164 @@ class XCBarAnalyser : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bar CHOCH ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Specified Bar Has PullBack or not ...
|
||||||
|
*
|
||||||
|
* @param dir: ENUM_X_DIRECTION member, Specified Direction ...
|
||||||
|
* @param bar: XOHCL instance, Speciied Bar ...
|
||||||
|
* @param loopback: Integer, loopback Length ...
|
||||||
|
* @param forceBody: Boolean, Specified Choch Happens only by Bar's Body ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool HasPullBack(
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
XOHCL &bar,
|
||||||
|
int loopback = 3,
|
||||||
|
bool forceBody = false //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback < 1)
|
||||||
|
{
|
||||||
|
loopback = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = bar.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = bar.symbol;
|
||||||
|
ENUM_TIMEFRAMES period = bar.period;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Loopback Data ...
|
||||||
|
int index = -1;
|
||||||
|
int start = -1;
|
||||||
|
int end = -1;
|
||||||
|
int count = -1;
|
||||||
|
result = CalculateLoopBackData(
|
||||||
|
index,
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
count,
|
||||||
|
bar,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Loopback HH and LL Data ...
|
||||||
|
int hhIDX = -1;
|
||||||
|
double hh = -1;
|
||||||
|
int llIDX = -1;
|
||||||
|
double ll = -1;
|
||||||
|
result = CalculateLoopbackHLData(
|
||||||
|
hhIDX,
|
||||||
|
hh,
|
||||||
|
llIDX,
|
||||||
|
ll,
|
||||||
|
bar,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullishDirection =
|
||||||
|
bar.high > hh &&
|
||||||
|
bar.low > ll;
|
||||||
|
bool isBearishDirection =
|
||||||
|
bar.high < hh &&
|
||||||
|
bar.low < ll;
|
||||||
|
result = isBullishDirection ||
|
||||||
|
isBearishDirection;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (forceBody)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
isBullishDirection =
|
||||||
|
bar.GetUp() > hh &&
|
||||||
|
bar.GetDown() > ll;
|
||||||
|
isBearishDirection =
|
||||||
|
bar.GetUp() < hh &&
|
||||||
|
bar.GetDown() < ll;
|
||||||
|
result = isBullishDirection ||
|
||||||
|
isBearishDirection;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar's Direction in related to CHOCH Direction ...
|
||||||
|
result =
|
||||||
|
isBullishDirection
|
||||||
|
? bar.IsBullish()
|
||||||
|
: bar.IsBearish();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set Direction ...
|
||||||
|
dir =
|
||||||
|
isBullishDirection
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Loopback End Bar ...
|
||||||
|
XOHCL endBar;
|
||||||
|
result = endBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
end - 1 //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// End Bar Must be InDirect by Specified Bar ...
|
||||||
|
result =
|
||||||
|
isBullishDirection
|
||||||
|
? endBar.IsBearish()
|
||||||
|
: endBar.IsBullish();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Loopback for Directional Bars ...
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
protected:
|
protected:
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -198,6 +198,216 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Candlestick PullBacks ...
|
||||||
|
ENUM_X_DIRECTION pullBackDir;
|
||||||
|
bool hasPullBack = mBarAnalyser.HasPullBack(
|
||||||
|
pullBackDir,
|
||||||
|
cBar,
|
||||||
|
3, // Loopback ...
|
||||||
|
true // Force Body ...
|
||||||
|
);
|
||||||
|
bool hasBullishPullback =
|
||||||
|
hasPullBack &&
|
||||||
|
pullBackDir == X_DIRECTION_BULLISH;
|
||||||
|
bool hasBearishPullback =
|
||||||
|
hasPullBack &&
|
||||||
|
pullBackDir == X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check 3MA and 3VWAP State ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWAPBullishOrdered =
|
||||||
|
//
|
||||||
|
(
|
||||||
|
//
|
||||||
|
(conditions.x3vwapConditions.isBullishOrdered ||
|
||||||
|
conditions.x3vwapConditions.isSwitchedToBullishOrdered)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
conditions.x3vwapConditions.fasts[cIndex] > conditions.x3vwapConditions.mids[cIndex]
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
conditions.x3vwapConditions.mids[cIndex] > conditions.x3vwapConditions.slows[cIndex]
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWAPBearishOrdered =
|
||||||
|
//
|
||||||
|
(
|
||||||
|
//
|
||||||
|
(conditions.x3vwapConditions.isBearishOrdered ||
|
||||||
|
conditions.x3vwapConditions.isSwitchedToBearishOrdered)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
conditions.x3vwapConditions.fasts[cIndex] < conditions.x3vwapConditions.mids[cIndex]
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
conditions.x3vwapConditions.mids[cIndex] < conditions.x3vwapConditions.slows[cIndex]
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapBullishState =
|
||||||
|
//
|
||||||
|
(
|
||||||
|
//
|
||||||
|
(conditions.x3vwapConditions.isBullishState ||
|
||||||
|
conditions.x3vwapConditions.isSwitchedToBullishState)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(x3vwapHelper.IsBullish(conditions.x3vwapConditions.fastStates[cIndex]) &&
|
||||||
|
x3vwapHelper.IsBullish(conditions.x3vwapConditions.midStates[cIndex]))
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(x3vwapHelper.IsBullish(conditions.x3vwapConditions.midStates[cIndex]) &&
|
||||||
|
x3vwapHelper.IsBullish(conditions.x3vwapConditions.slowStates[cIndex]))
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapBearishState =
|
||||||
|
//
|
||||||
|
(
|
||||||
|
//
|
||||||
|
(conditions.x3vwapConditions.isBearishState ||
|
||||||
|
conditions.x3vwapConditions.isSwitchedToBearishState)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(x3vwapHelper.IsBearish(conditions.x3vwapConditions.fastStates[cIndex]) &&
|
||||||
|
x3vwapHelper.IsBearish(conditions.x3vwapConditions.midStates[cIndex]))
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(x3vwapHelper.IsBearish(conditions.x3vwapConditions.midStates[cIndex]) &&
|
||||||
|
x3vwapHelper.IsBearish(conditions.x3vwapConditions.slowStates[cIndex]))
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapOverFastMA =
|
||||||
|
//
|
||||||
|
(
|
||||||
|
//
|
||||||
|
(conditions.x3vwapConditions.fasts[cIndex] > conditions.x3maConditions.fasts[cIndex] &&
|
||||||
|
conditions.x3vwapConditions.mids[cIndex] > conditions.x3maConditions.fasts[cIndex])
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(conditions.x3vwapConditions.fasts[cIndex] > conditions.x3maConditions.fasts[cIndex] &&
|
||||||
|
conditions.x3vwapConditions.mids[cIndex] > conditions.x3maConditions.fasts[cIndex] &&
|
||||||
|
conditions.x3vwapConditions.slows[cIndex] > conditions.x3maConditions.fasts[cIndex])
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapUnderFastMA =
|
||||||
|
//
|
||||||
|
(
|
||||||
|
//
|
||||||
|
(conditions.x3vwapConditions.fasts[cIndex] < conditions.x3maConditions.fasts[cIndex] &&
|
||||||
|
conditions.x3vwapConditions.mids[cIndex] < conditions.x3maConditions.fasts[cIndex])
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(conditions.x3vwapConditions.fasts[cIndex] < conditions.x3maConditions.fasts[cIndex] &&
|
||||||
|
conditions.x3vwapConditions.mids[cIndex] < conditions.x3maConditions.fasts[cIndex] &&
|
||||||
|
conditions.x3vwapConditions.slows[cIndex] < conditions.x3maConditions.fasts[cIndex])
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool is3Bullish =
|
||||||
|
//
|
||||||
|
(
|
||||||
|
//
|
||||||
|
(isVWAPBullishOrdered &&
|
||||||
|
isVWapBullishState)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(isVWAPBullishOrdered &&
|
||||||
|
isVWapOverFastMA)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(isVWapBullishState &&
|
||||||
|
isVWapOverFastMA)
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool is3Bearish =
|
||||||
|
//
|
||||||
|
(
|
||||||
|
//
|
||||||
|
(isVWAPBearishOrdered &&
|
||||||
|
isVWapBearishState)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(isVWAPBearishOrdered &&
|
||||||
|
isVWapUnderFastMA)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(isVWapBearishState &&
|
||||||
|
isVWapUnderFastMA)
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Parabolic Sars State ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isSarBullish =
|
||||||
|
//
|
||||||
|
(conditions.xchsarConditions.isCBullish &&
|
||||||
|
conditions.xchsarConditions.isSSwitchedBullish)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(conditions.xchsarConditions.isSBullish &&
|
||||||
|
conditions.xchsarConditions.isCSwitchedBullish)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
bool isSarBearish =
|
||||||
|
//
|
||||||
|
(conditions.xchsarConditions.isCBearish &&
|
||||||
|
conditions.xchsarConditions.isSSwitchedBearish)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
(conditions.xchsarConditions.isSBearish &&
|
||||||
|
conditions.xchsarConditions.isCSwitchedBearish)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Prepare Areas ...
|
// Prepare Areas ...
|
||||||
double bid = GetBid(_symbol);
|
double bid = GetBid(_symbol);
|
||||||
@@ -218,7 +428,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
bid > lastPivot.lower;
|
bid > lastPivot.lower;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool IsInPremium =
|
bool isInPremium =
|
||||||
bid > pivotMid &&
|
bid > pivotMid &&
|
||||||
bid < lastPivot.upper;
|
bid < lastPivot.upper;
|
||||||
|
|
||||||
@@ -239,38 +449,44 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
isBullish ? bid > lastPivot.upper + pip
|
isBullish ? bid > lastPivot.upper + pip
|
||||||
: bid < lastPivot.lower - pip;
|
: bid < lastPivot.lower - pip;
|
||||||
|
|
||||||
//
|
|
||||||
if (isCHOCHHappens)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// When Chouch Happens we Have to Destry Order Flow and
|
|
||||||
// Clean another ...
|
|
||||||
|
|
||||||
//
|
|
||||||
Print("CHOCH ...");
|
|
||||||
|
|
||||||
//
|
|
||||||
result = false;
|
|
||||||
ResetOrderFlow();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
if (isBOSHappens)
|
if (isBOSHappens)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// When Chouch Happens we Have to Destry Order Flow and
|
RedrawOrderFlow();
|
||||||
// Clean another ...
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
Print("BOS ...");
|
if (isCHOCHHappens)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
result = false;
|
result = false;
|
||||||
ResetOrderFlow();
|
ResetOrderFlow();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
hasLong =
|
||||||
|
//
|
||||||
|
is3Bullish &&
|
||||||
|
// isInDiscount &&
|
||||||
|
isSarBullish &&
|
||||||
|
// hasBullishPullback &&
|
||||||
|
bullishLiquidityPercent > 30
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
hasShort =
|
||||||
|
//
|
||||||
|
is3Bearish &&
|
||||||
|
// isInPremium &&
|
||||||
|
isSarBearish &&
|
||||||
|
// hasBearishPullback &&
|
||||||
|
bearishLiquidityPercent > 30
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
//
|
//
|
||||||
result = hasLong ||
|
result = hasLong ||
|
||||||
hasShort;
|
hasShort;
|
||||||
@@ -368,6 +584,46 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
ENUM_X_POSITION_TYPES type //
|
ENUM_X_POSITION_TYPES type //
|
||||||
) override
|
) override
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
Clean(result);
|
||||||
|
|
||||||
|
//
|
||||||
|
int cIndex = 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (entry <= 0 ||
|
||||||
|
!conditions.IsValid() ||
|
||||||
|
type == X_POSITION_TYPE_ALL ||
|
||||||
|
type == X_POSITION_TYPE_NONE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
conditions.x3vwapConditions.fasts[cIndex],
|
||||||
|
result //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
conditions.x3vwapConditions.mids[cIndex],
|
||||||
|
result //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
conditions.x3vwapConditions.slows[cIndex],
|
||||||
|
result //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
conditions.x3maConditions.fasts[cIndex],
|
||||||
|
result //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1784,7 +2040,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
x3maInputs.Default();
|
x3maInputs.Default();
|
||||||
|
|
||||||
//
|
//
|
||||||
x3maInputs.showFast = false;
|
x3maInputs.showFast = true;
|
||||||
x3maInputs.showMid = false;
|
x3maInputs.showMid = false;
|
||||||
x3maInputs.showSlow = false;
|
x3maInputs.showSlow = false;
|
||||||
|
|
||||||
@@ -1833,7 +2089,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
|
|
||||||
//
|
//
|
||||||
xchsarInputs.showCurrent = true;
|
xchsarInputs.showCurrent = true;
|
||||||
xchsarInputs.showShort = true;
|
xchsarInputs.showShort = false;
|
||||||
xchsarInputs.showMedium = false;
|
xchsarInputs.showMedium = false;
|
||||||
xchsarInputs.showLong = false;
|
xchsarInputs.showLong = false;
|
||||||
xchsarInputs.showHind = false;
|
xchsarInputs.showHind = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user