last ...
This commit is contained in:
@@ -1653,6 +1653,164 @@ class XCBarAnalyser : public XCBase
|
||||
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:
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user