last ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3612,7 +3612,8 @@ class XCSupportZone : public XCBarZone
|
||||
*/
|
||||
bool Init(
|
||||
XOHCL &bar,
|
||||
int range = 0 //
|
||||
int range = 0,
|
||||
bool useRangeAsStart = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -3647,7 +3648,10 @@ class XCSupportZone : public XCBarZone
|
||||
int periodSeconds = PeriodSeconds(bar.period);
|
||||
|
||||
//
|
||||
datetime from = (datetime)((int)time - (range * periodSeconds));
|
||||
datetime from =
|
||||
!useRangeAsStart
|
||||
? (datetime)((int)time - (range * periodSeconds))
|
||||
: time;
|
||||
datetime to = (datetime)((int)time + (range * periodSeconds));
|
||||
|
||||
//
|
||||
@@ -6323,588 +6327,3 @@ struct XBoxZone
|
||||
};
|
||||
|
||||
//
|
||||
struct XOBFVGPivot
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
double value;
|
||||
datetime at;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XOBFVGPivot()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
value = 0;
|
||||
at = NULL;
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
value > 0 &&
|
||||
IsValid(at);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
struct XOBFVG
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
XCFVG *fvg;
|
||||
XCOrderBlock *ob;
|
||||
|
||||
//
|
||||
XCSupplyZone *supplyZones[];
|
||||
XCDemandZone *demandZones[];
|
||||
|
||||
//
|
||||
XCSupportZone *supportZones[];
|
||||
XCResistanceZone *resistanceZones[];
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XOBFVG()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
ZeroMemory(ob);
|
||||
ZeroMemory(fvg);
|
||||
|
||||
//
|
||||
Clean(supplyZones);
|
||||
Clean(demandZones);
|
||||
Clean(supportZones);
|
||||
Clean(resistanceZones);
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsValid()
|
||||
{
|
||||
return HasOB() &&
|
||||
HasFVG();
|
||||
}
|
||||
|
||||
//
|
||||
bool HasOB()
|
||||
{
|
||||
return ob != NULL &&
|
||||
ob.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
bool HasFVG()
|
||||
{
|
||||
return fvg != NULL &&
|
||||
fvg.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
bool HasSupplyZones()
|
||||
{
|
||||
return HasChild(supplyZones);
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupplyZones()
|
||||
{
|
||||
return ArraySize(supplyZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasDemandZones()
|
||||
{
|
||||
return HasChild(demandZones);
|
||||
}
|
||||
|
||||
//
|
||||
int CountDemandZones()
|
||||
{
|
||||
return ArraySize(demandZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasSupportZones()
|
||||
{
|
||||
return HasChild(supportZones);
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupportZones()
|
||||
{
|
||||
return ArraySize(supportZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasResistanceZones()
|
||||
{
|
||||
return HasChild(resistanceZones);
|
||||
}
|
||||
|
||||
//
|
||||
int CountResistanceZones()
|
||||
{
|
||||
return ArraySize(resistanceZones);
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION GetDirection()
|
||||
{
|
||||
//
|
||||
ENUM_X_DIRECTION result = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
bool isValid = IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ob.GetDirection();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBullish()
|
||||
{
|
||||
return IsBullish(GetDirection());
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBearish()
|
||||
{
|
||||
return IsBearish(GetDirection());
|
||||
}
|
||||
|
||||
//
|
||||
int GetSwings(
|
||||
XOBFVGPivot &pivots[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(pivots);
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION forDir = GetDirection();
|
||||
bool isBullish = IsBullish(forDir);
|
||||
|
||||
//
|
||||
XOHCL passedBar;
|
||||
XOBFVGPivot iPivot;
|
||||
bool isPassed = false;
|
||||
double appliedPrice = 0;
|
||||
bool isBodyState = false;
|
||||
|
||||
//
|
||||
// Start ...
|
||||
isPassed = ob.IsStarted(
|
||||
forDir,
|
||||
passedBar,
|
||||
isBodyState //
|
||||
);
|
||||
if (isPassed)
|
||||
{
|
||||
//
|
||||
appliedPrice =
|
||||
isBullish
|
||||
? passedBar.low
|
||||
: passedBar.high;
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
iPivot.value = appliedPrice;
|
||||
iPivot.at = passedBar.time;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
pivots //
|
||||
);
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Activation ...
|
||||
isPassed = ob.IsActivated(
|
||||
forDir,
|
||||
passedBar,
|
||||
isBodyState //
|
||||
);
|
||||
if (isPassed)
|
||||
{
|
||||
//
|
||||
appliedPrice =
|
||||
isBullish
|
||||
? passedBar.low
|
||||
: passedBar.high;
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
iPivot.value = appliedPrice;
|
||||
iPivot.at = passedBar.time;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
pivots //
|
||||
);
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Worked ...
|
||||
isPassed = ob.IsWorked(
|
||||
forDir,
|
||||
passedBar,
|
||||
isBodyState //
|
||||
);
|
||||
if (isPassed)
|
||||
{
|
||||
//
|
||||
appliedPrice =
|
||||
isBullish
|
||||
? passedBar.low
|
||||
: passedBar.high;
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
iPivot.value = appliedPrice;
|
||||
iPivot.at = passedBar.time;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
pivots //
|
||||
);
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
passedBar.Clean();
|
||||
|
||||
//
|
||||
result = ArraySize(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void UpdateZones(
|
||||
XPOIState &state //
|
||||
)
|
||||
{
|
||||
//
|
||||
Clean(supplyZones);
|
||||
Clean(demandZones);
|
||||
Clean(supportZones);
|
||||
Clean(resistanceZones);
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
IsValid() &&
|
||||
state.HasChild();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
bool isPassed = false;
|
||||
|
||||
//
|
||||
// Supply Zones ...
|
||||
has = state.HasSupplyZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = state.CountSupplyZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCSupplyZone *iZone = state.supplyZones[i];
|
||||
|
||||
//
|
||||
isPassed = iZone.From() > ob.From();
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
isPassed = IsInsideDiff(
|
||||
iZone,
|
||||
ob //
|
||||
);
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
supplyZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Demand Zones ...
|
||||
has = state.HasDemandZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = state.CountDemandZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCDemandZone *iZone = state.demandZones[i];
|
||||
|
||||
//
|
||||
isPassed = iZone.From() > ob.From();
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
isPassed = IsInsideDiff(
|
||||
iZone,
|
||||
ob //
|
||||
);
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
demandZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Support Zones ...
|
||||
has = state.HasSupportZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = state.CountSupportZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCSupportZone *iZone = state.supportZones[i];
|
||||
|
||||
//
|
||||
isPassed = iZone.From() > ob.From();
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
isPassed = IsInsideDiff(
|
||||
iZone,
|
||||
ob //
|
||||
);
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
supportZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance Zones ...
|
||||
has = state.HasResistanceZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = state.CountResistanceZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCResistanceZone *iZone = state.resistanceZones[i];
|
||||
|
||||
//
|
||||
isPassed = iZone.From() > ob.From();
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
isPassed = IsInsideDiff(
|
||||
iZone,
|
||||
ob //
|
||||
);
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
resistanceZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void UpdateTo(datetime value = NULL)
|
||||
{
|
||||
//
|
||||
value = NormalizeTime(value);
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
has = HasOB();
|
||||
if (has)
|
||||
{
|
||||
ob.To(value);
|
||||
}
|
||||
|
||||
//
|
||||
has = HasFVG();
|
||||
if (has)
|
||||
{
|
||||
fvg.To(value);
|
||||
}
|
||||
|
||||
//
|
||||
// Supply Zones ...
|
||||
has = HasSupplyZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountSupplyZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
supplyZones[i].To(value);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Demand Zones ...
|
||||
has = HasDemandZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountDemandZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
demandZones[i].To(value);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Support Zones ...
|
||||
has = HasSupportZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountSupportZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
supportZones[i].To(value);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance Zones ...
|
||||
has = HasResistanceZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountResistanceZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
resistanceZones[i].To(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user