last ...
This commit is contained in:
@@ -421,20 +421,233 @@ class XCBarAnalyser : public XSCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bar CHOCH ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Specified Bar Has Bullish CHOCH or not ...
|
||||||
|
*
|
||||||
|
* @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 HasBullishCHOCH(
|
||||||
|
XOHCL &bar,
|
||||||
|
int loopback = 3,
|
||||||
|
bool forceBody = false //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_DIRECTION dir;
|
||||||
|
result = HasCHOCH(
|
||||||
|
dir,
|
||||||
|
bar,
|
||||||
|
loopback,
|
||||||
|
forceBody //
|
||||||
|
);
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
dir == X_DIRECTION_BULLISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Specified Bar Has Bearish CHOCH or not ...
|
||||||
|
*
|
||||||
|
* @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 HasBearishCHOCH(
|
||||||
|
XOHCL &bar,
|
||||||
|
int loopback = 3,
|
||||||
|
bool forceBody = false //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_DIRECTION dir;
|
||||||
|
result = HasCHOCH(
|
||||||
|
dir,
|
||||||
|
bar,
|
||||||
|
loopback,
|
||||||
|
forceBody //
|
||||||
|
);
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
dir == X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
protected:
|
protected:
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
|
||||||
private:
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Props ...
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Actions ...
|
// Actions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate Loopback Data for Specific Bar ...
|
||||||
|
*
|
||||||
|
* @param index: Integer, Bar Current Index ...
|
||||||
|
* @param start: Integer, Start of Loopback ...
|
||||||
|
* @param end: Integer, End of Loopback ...
|
||||||
|
* @param count: Integer, Number of Calculating Bars ...
|
||||||
|
* @param bar: XOHCL instance, Specified Bar ...
|
||||||
|
* @param loopback: Integer, Loopback Length ...
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool CalculateLoopBackData(
|
||||||
|
int &index,
|
||||||
|
int &start,
|
||||||
|
int &end,
|
||||||
|
int &count,
|
||||||
|
XOHCL &bar,
|
||||||
|
int loopback = 1 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback < 1)
|
||||||
|
{
|
||||||
|
loopback = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
index = -1;
|
||||||
|
start = -1;
|
||||||
|
end = -1;
|
||||||
|
count = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = bar.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
index = bar.Index();
|
||||||
|
start = index + 1;
|
||||||
|
end = start + loopback;
|
||||||
|
count = end - start;
|
||||||
|
result = count >= 1;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Loopback HH & LL Data ...
|
||||||
|
*
|
||||||
|
* @param hhIDX: Integer, HH Index ...
|
||||||
|
* @param hh: Double, HH Value ...
|
||||||
|
* @param llIDX: Integer, LL Index ...
|
||||||
|
* @param ll: Double, LL Value ...
|
||||||
|
* @param bar: XOHCL instance ...
|
||||||
|
* @param loopback: Integer, Loopback Length ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool CalculateLoopbackHLData(
|
||||||
|
int &hhIDX,
|
||||||
|
double &hh,
|
||||||
|
int &llIDX,
|
||||||
|
double &ll,
|
||||||
|
XOHCL &bar,
|
||||||
|
int loopback //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback < 1)
|
||||||
|
{
|
||||||
|
loopback = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int index = -1;
|
||||||
|
int start = -1;
|
||||||
|
int end = -1;
|
||||||
|
int count = -1;
|
||||||
|
result = CalculateLoopBackData(
|
||||||
|
index,
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
count,
|
||||||
|
bar,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
hhIDX = iHighest(
|
||||||
|
bar.symbol,
|
||||||
|
bar.period,
|
||||||
|
MODE_HIGH,
|
||||||
|
start,
|
||||||
|
count //
|
||||||
|
);
|
||||||
|
result = IsValidIndex(hhIDX);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
llIDX = iLowest(
|
||||||
|
bar.symbol,
|
||||||
|
bar.period,
|
||||||
|
MODE_LOW,
|
||||||
|
start,
|
||||||
|
count //
|
||||||
|
);
|
||||||
|
result = IsValidIndex(llIDX);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
hh = iHigh(
|
||||||
|
bar.symbol,
|
||||||
|
bar.period,
|
||||||
|
hhIDX //
|
||||||
|
);
|
||||||
|
ll = iLow(
|
||||||
|
bar.symbol,
|
||||||
|
bar.period,
|
||||||
|
llIDX //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate Bar Range ...
|
* Calculate Bar Range ...
|
||||||
*
|
*
|
||||||
@@ -564,91 +777,6 @@ class XCBarAnalyser : public XSCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve Loopback HH LL Data ...
|
|
||||||
*
|
|
||||||
* @param hhIDX: Integer, HH Index ...
|
|
||||||
* @param hh: Double, HH Value ...
|
|
||||||
* @param llIDX: Integer, LL Index ...
|
|
||||||
* @param ll: Double, LL Value ...
|
|
||||||
* @param bar: XOHCL instance ...
|
|
||||||
* @param loopback: Integer, Loopback Length ...
|
|
||||||
*
|
|
||||||
* @return ( bool )
|
|
||||||
*/
|
|
||||||
bool GetLoopbackData(
|
|
||||||
int &hhIDX,
|
|
||||||
double &hh,
|
|
||||||
int &llIDX,
|
|
||||||
double &ll,
|
|
||||||
XOHCL &bar,
|
|
||||||
int loopback //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
if (loopback < 1)
|
|
||||||
{
|
|
||||||
loopback = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int index = bar.Index();
|
|
||||||
int start = index + 1;
|
|
||||||
int end = start + loopback;
|
|
||||||
int count = end - start;
|
|
||||||
result = count >= 1;
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
hhIDX = iHighest(
|
|
||||||
bar.symbol,
|
|
||||||
bar.period,
|
|
||||||
MODE_HIGH,
|
|
||||||
start,
|
|
||||||
count //
|
|
||||||
);
|
|
||||||
result = IsValidIndex(hhIDX);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
llIDX = iLowest(
|
|
||||||
bar.symbol,
|
|
||||||
bar.period,
|
|
||||||
MODE_LOW,
|
|
||||||
start,
|
|
||||||
count //
|
|
||||||
);
|
|
||||||
result = IsValidIndex(llIDX);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
hh = iHigh(
|
|
||||||
bar.symbol,
|
|
||||||
bar.period,
|
|
||||||
hhIDX //
|
|
||||||
);
|
|
||||||
ll = iLow(
|
|
||||||
bar.symbol,
|
|
||||||
bar.period,
|
|
||||||
llIDX //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Bar is Engulfed or not ...
|
* Check Bar is Engulfed or not ...
|
||||||
*
|
*
|
||||||
@@ -679,7 +807,7 @@ class XCBarAnalyser : public XSCBase
|
|||||||
double ll = 0;
|
double ll = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
result = GetLoopbackData(
|
result = CalculateLoopbackHLData(
|
||||||
hhIDX,
|
hhIDX,
|
||||||
hh,
|
hh,
|
||||||
llIDX,
|
llIDX,
|
||||||
@@ -707,6 +835,171 @@ class XCBarAnalyser : public XSCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Specified Bar Has CHOCH 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 HasCHOCH(
|
||||||
|
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 //
|
||||||
|
);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Actions ...
|
||||||
|
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user