Complete Support and Resistance POI ...
This commit is contained in:
@@ -730,6 +730,185 @@ class XCBarAnalyser : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Support and Resistance Zones ...
|
||||
|
||||
/**
|
||||
* Check a Bar is Support Bar or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
* @param range: Integer, Specified Verifiation Range ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSupport(
|
||||
XOHCL &bar,
|
||||
int range = 21 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (range < 2)
|
||||
{
|
||||
range = 2;
|
||||
}
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int index = bar.Index();
|
||||
result = range > 0 &&
|
||||
index >= range;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbol = bar.symbol;
|
||||
ENUM_TIMEFRAMES period = bar.period;
|
||||
|
||||
//
|
||||
for (int i = 1; i <= range; i++)
|
||||
{
|
||||
//
|
||||
int prevIDX = index + i;
|
||||
int nextIDX = index - 1;
|
||||
|
||||
//
|
||||
// Prev Bar ...
|
||||
XOHCL iPrevBar;
|
||||
result = iPrevBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
prevIDX //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Next Bar ...
|
||||
XOHCL iNextBar;
|
||||
result = iNextBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
nextIDX //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
result = bar.low <= iPrevBar.low &&
|
||||
bar.low <= iNextBar.low;
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is Resistance Bar or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
* @param range: Integer, Specified Verifiation Range ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsResistance(
|
||||
XOHCL &bar,
|
||||
int range = 21 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (range < 2)
|
||||
{
|
||||
range = 2;
|
||||
}
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int index = bar.Index();
|
||||
result = range > 0 &&
|
||||
index >= range;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbol = bar.symbol;
|
||||
ENUM_TIMEFRAMES period = bar.period;
|
||||
|
||||
//
|
||||
for (int i = 1; i <= range; i++)
|
||||
{
|
||||
//
|
||||
int prevIDX = index + i;
|
||||
int nextIDX = index - 1;
|
||||
|
||||
//
|
||||
// Prev Bar ...
|
||||
XOHCL iPrevBar;
|
||||
result = iPrevBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
prevIDX //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Next Bar ...
|
||||
XOHCL iNextBar;
|
||||
result = iNextBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
nextIDX //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
result = bar.high >= iPrevBar.high &&
|
||||
bar.high >= iNextBar.high;
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
protected:
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user