last ...
This commit is contained in:
@@ -94,3 +94,125 @@
|
||||
swing.Clean();
|
||||
breaker.Clean();
|
||||
outSide.Clean();
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Swing or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance reference, Specified Swing Bar ...
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Direction of Swing ...
|
||||
* @param barIndex: int, Specified Bar Index to Check ...
|
||||
* @param loopback: int, Specified Loopback for BothSide Checking ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSwingSide(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION forDir,
|
||||
int loopback = 7 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid() &&
|
||||
HasDirection(forDir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isSwingLow = IsBullish(forDir);
|
||||
bool isSwingHigh = IsBearish(forDir);
|
||||
|
||||
//
|
||||
string symbol = bar.symbol;
|
||||
ENUM_TIMEFRAMES period = bar.period;
|
||||
|
||||
//
|
||||
int totalBars = iBars(
|
||||
symbol,
|
||||
period //
|
||||
);
|
||||
int barIndex = bar.Index();
|
||||
loopback = NormalizeInt(loopback, 3);
|
||||
result =
|
||||
barIndex - loopback > 0 &&
|
||||
barIndex + 1 + loopback <= totalBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < loopback; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iPBar;
|
||||
XOHCL iNBar;
|
||||
result = iPBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
barIndex + i //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
iNBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
barIndex - i //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iPBar.Clean();
|
||||
iNBar.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
isSwingLow =
|
||||
isSwingLow &&
|
||||
bar.low < iPBar.low &&
|
||||
bar.low < iNBar.low;
|
||||
|
||||
//
|
||||
isSwingHigh =
|
||||
isSwingHigh &&
|
||||
bar.high > iPBar.high &&
|
||||
bar.high > iNBar.high;
|
||||
|
||||
//
|
||||
result = isSwingLow ||
|
||||
isSwingHigh;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iPBar.Clean();
|
||||
iNBar.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iPBar.Clean();
|
||||
iNBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
bar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user