222 lines
3.9 KiB
Plaintext
222 lines
3.9 KiB
Plaintext
|
|
//
|
|
// Detect Signals Based On XPV Indicator Golden Zones ...
|
|
//
|
|
bool HasTMPConditions(
|
|
ENUM_X_CYCLES cycle,
|
|
XBoxZone &box,
|
|
ENUM_X_DIRECTION &dir,
|
|
X121SMCStrategySignalProviderData &provider,
|
|
int barIndex = 0 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
box.Clean();
|
|
dir = X_DIRECTION_NONE;
|
|
|
|
//
|
|
// Fil Selected Data ...
|
|
XPOIState cState;
|
|
X121Conditions cXConditions;
|
|
XPOIStateEvents cStateEvents;
|
|
XC121SMCCycleHelper *cHelper;
|
|
X121SMCCycleConditions cConditions;
|
|
result = provider.SelectCycle(
|
|
cycle,
|
|
cState,
|
|
cStateEvents,
|
|
cXConditions,
|
|
cHelper,
|
|
cConditions //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
cState.Clean();
|
|
ZeroMemory(cHelper);
|
|
cConditions.Clean();
|
|
cXConditions.Clean();
|
|
cStateEvents.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Normalize Args ...
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
int idx = -1;
|
|
int count = 0;
|
|
bool has = false;
|
|
|
|
//
|
|
int zIDX = barIndex;
|
|
int cIDX = zIDX + 1;
|
|
int pIDX = cIDX + 1;
|
|
int ppIDX = pIDX + 1;
|
|
|
|
//
|
|
bool isBullish = false;
|
|
bool isBearish = false;
|
|
|
|
//
|
|
XOHCL zBar;
|
|
XOHCL cBar;
|
|
XOHCL pBar;
|
|
XOHCL pPBar;
|
|
|
|
//
|
|
// Initial Bars ...
|
|
result = zBar.Init(
|
|
cState.symbol,
|
|
cState.period,
|
|
barIndex //
|
|
);
|
|
result =
|
|
result &&
|
|
zBar.GetPreviousBar(cBar);
|
|
result =
|
|
result &&
|
|
cBar.GetPreviousBar(pBar);
|
|
result =
|
|
result &&
|
|
pBar.GetPreviousBar(pPBar);
|
|
if (!result)
|
|
{
|
|
//
|
|
zBar.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
cState.Clean();
|
|
ZeroMemory(cHelper);
|
|
cConditions.Clean();
|
|
cXConditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Checking Conditions ...
|
|
|
|
//
|
|
// Summarize Conditions ...
|
|
|
|
//
|
|
isBullish =
|
|
//
|
|
false
|
|
//
|
|
;
|
|
|
|
//
|
|
isBearish =
|
|
//
|
|
false
|
|
//
|
|
;
|
|
|
|
//
|
|
// Filling Requirements ...
|
|
result =
|
|
isBullish ||
|
|
isBearish;
|
|
if (result)
|
|
{
|
|
//
|
|
dir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
|
|
//
|
|
box.dir = dir;
|
|
box.from = pPBar.time;
|
|
box.to = TimeCurrent();
|
|
box.symbol = cBar.symbol;
|
|
box.period = cBar.period;
|
|
|
|
//
|
|
double points = GetPoints(box.symbol);
|
|
|
|
//
|
|
// Usually is Preffered SL ...
|
|
double pivot = 0;
|
|
|
|
//
|
|
// Usually is Current Price or Entry Price ...
|
|
double point = GetEntry(
|
|
cBar.symbol,
|
|
dir //
|
|
);
|
|
|
|
//
|
|
box.upper =
|
|
isBullish
|
|
? point
|
|
: pivot;
|
|
|
|
//
|
|
box.lower =
|
|
isBullish
|
|
? pivot
|
|
: point;
|
|
|
|
//
|
|
XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer;
|
|
bool drawBoxes = true;
|
|
if (drawBoxes)
|
|
{
|
|
//
|
|
if (box.IsValid()) {
|
|
//
|
|
XCBoxObject *iObj;
|
|
bool isCreated = drawer.DrawBox(
|
|
box,
|
|
iObj //
|
|
);
|
|
|
|
//
|
|
if (isCreated) {
|
|
//
|
|
// TODO: ...
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Check All Conditions ...
|
|
result =
|
|
box.IsValid() &&
|
|
HasDirection(dir) &&
|
|
(isBullish ||
|
|
isBearish);
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
zBar.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
pPBar.Clean();
|
|
cState.Clean();
|
|
cConditions.Clean();
|
|
cConditions.Clean();
|
|
ZeroMemory(cHelper);
|
|
cStateEvents.Clean();
|
|
cXConditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|