last ...
This commit is contained in:
@@ -0,0 +1,218 @@
|
||||
|
||||
//
|
||||
// Detect Block Based Trigger ...
|
||||
XBoxZone ob;
|
||||
XOHCL swing;
|
||||
XOHCL breaker;
|
||||
XOHCL outSide;
|
||||
ENUM_X_DIRECTION passedDir;
|
||||
bool isPassed = helper.IsBlockBasedTriggerBar(
|
||||
ob,
|
||||
swing,
|
||||
breaker,
|
||||
outSide,
|
||||
passedDir,
|
||||
1, // Bar Index ...
|
||||
50, // Loopback ...
|
||||
3 // Swing Length ...
|
||||
);
|
||||
if (isPassed)
|
||||
{
|
||||
//
|
||||
// Draw Block Based Trigger ...
|
||||
|
||||
//
|
||||
// Draw OB ...
|
||||
XCBoxObject *obObject;
|
||||
has = helper.poiDrawer.DrawBox(
|
||||
ob,
|
||||
obObject //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
obObject.BoxWidth(2);
|
||||
obObject.BoxStyle(STYLE_SOLID);
|
||||
|
||||
//
|
||||
color obColor =
|
||||
ob.IsBullish()
|
||||
? clrAqua
|
||||
: clrMagenta;
|
||||
obObject.BoxColor(obColor);
|
||||
|
||||
//
|
||||
mObjects.Add(obObject);
|
||||
|
||||
//
|
||||
ZeroMemory(obObject);
|
||||
}
|
||||
|
||||
//
|
||||
double breakPrice =
|
||||
ob.IsBullish()
|
||||
? swing.high
|
||||
: swing.low;
|
||||
|
||||
//
|
||||
// Draw Swing and Breake ...
|
||||
CChartObjectTrend *tObj;
|
||||
tObj = new CChartObjectTrend();
|
||||
string tName = "Swing_For_" + ToString(ob.dir) + "_" + ToString(breakPrice);
|
||||
has = tObj.Create(
|
||||
0,
|
||||
tName,
|
||||
0,
|
||||
swing.time,
|
||||
breakPrice,
|
||||
breaker.time,
|
||||
breakPrice //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
tObj.Width(2);
|
||||
tObj.Style(STYLE_SOLID);
|
||||
|
||||
//
|
||||
color tColor = ob.IsBullish()
|
||||
? clrRed
|
||||
: clrLime;
|
||||
tObj.Color(tColor);
|
||||
|
||||
//
|
||||
mObjects.Add(tObj);
|
||||
|
||||
//
|
||||
ZeroMemory(tObj);
|
||||
}
|
||||
|
||||
//
|
||||
Print("Passed Bar ...");
|
||||
}
|
||||
ob.Clean();
|
||||
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