last ...
This commit is contained in:
@@ -4585,6 +4585,7 @@ class XCPOIDrawer : public XCBase
|
||||
//
|
||||
bool drawOrderBlock = true,
|
||||
bool drawFairValueGaps = true,
|
||||
bool drawAllFVGs = true,
|
||||
//
|
||||
bool drawOBStartedBar = true,
|
||||
bool drawOBActivatedBar = true,
|
||||
@@ -4695,87 +4696,93 @@ class XCPOIDrawer : public XCBase
|
||||
|
||||
//
|
||||
// Fair Value Gap ...
|
||||
XCFVG *fvg;
|
||||
has = item.GetMainFVG(fvg);
|
||||
if (has)
|
||||
if (!drawAllFVGs)
|
||||
{
|
||||
//
|
||||
Clean(tmpObjects);
|
||||
int fvgsCount = DrawFairValueGap(
|
||||
fvg,
|
||||
tmpObjects,
|
||||
drawFVGStartedBar,
|
||||
drawFVGActivatedBar,
|
||||
drawFVGBreakedBar,
|
||||
drawFVGWorkedBar,
|
||||
widthFVGStartedBar,
|
||||
clrFVGStartedBar,
|
||||
styleFVGStartedBar,
|
||||
widthFVGActivatedBar,
|
||||
clrFVGActivatedBar,
|
||||
styleFVGActivatedBar,
|
||||
widthFVGBreakedBar,
|
||||
clrFVGBreakedBar,
|
||||
styleFVGBreakedBar,
|
||||
widthFVGWorkedBar,
|
||||
clrFVGWorkedBar,
|
||||
styleFVGWorkedBar //
|
||||
);
|
||||
has = IsValidSize(fvgsCount);
|
||||
if (has)
|
||||
XCFVG *fvg;
|
||||
has = item.GetMainFVG(fvg);
|
||||
if (has &&
|
||||
drawFairValueGaps)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
Clean(tmpObjects);
|
||||
int fvgsCount = DrawFairValueGap(
|
||||
fvg,
|
||||
tmpObjects,
|
||||
objects,
|
||||
false //
|
||||
drawFVGStartedBar,
|
||||
drawFVGActivatedBar,
|
||||
drawFVGBreakedBar,
|
||||
drawFVGWorkedBar,
|
||||
widthFVGStartedBar,
|
||||
clrFVGStartedBar,
|
||||
styleFVGStartedBar,
|
||||
widthFVGActivatedBar,
|
||||
clrFVGActivatedBar,
|
||||
styleFVGActivatedBar,
|
||||
widthFVGBreakedBar,
|
||||
clrFVGBreakedBar,
|
||||
styleFVGBreakedBar,
|
||||
widthFVGWorkedBar,
|
||||
clrFVGWorkedBar,
|
||||
styleFVGWorkedBar //
|
||||
);
|
||||
has = IsValidSize(fvgsCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
tmpObjects,
|
||||
objects,
|
||||
false //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
has = item.HasFVGs();
|
||||
if (has &&
|
||||
drawFairValueGaps)
|
||||
{
|
||||
//
|
||||
count = item.CountFVGs();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
Clean(tmpObjects);
|
||||
int fvgsCount = DrawFairValueGap(
|
||||
item.fvgs[i],
|
||||
tmpObjects,
|
||||
drawFVGStartedBar,
|
||||
drawFVGActivatedBar,
|
||||
drawFVGBreakedBar,
|
||||
drawFVGWorkedBar,
|
||||
widthFVGStartedBar,
|
||||
clrFVGStartedBar,
|
||||
styleFVGStartedBar,
|
||||
widthFVGActivatedBar,
|
||||
clrFVGActivatedBar,
|
||||
styleFVGActivatedBar,
|
||||
widthFVGBreakedBar,
|
||||
clrFVGBreakedBar,
|
||||
styleFVGBreakedBar,
|
||||
widthFVGWorkedBar,
|
||||
clrFVGWorkedBar,
|
||||
styleFVGWorkedBar //
|
||||
);
|
||||
has = IsValidSize(fvgsCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
tmpObjects,
|
||||
objects,
|
||||
false //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// //
|
||||
// has = item.HasFVGs();
|
||||
// if (has &&
|
||||
// drawFairValueGaps)
|
||||
// {
|
||||
// //
|
||||
// count = item.CountFVGs();
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// //
|
||||
// Clean(tmpObjects);
|
||||
// int fvgsCount = DrawFairValueGap(
|
||||
// item.fvgs[i],
|
||||
// tmpObjects,
|
||||
// drawFVGStartedBar,
|
||||
// drawFVGActivatedBar,
|
||||
// drawFVGBreakedBar,
|
||||
// drawFVGWorkedBar,
|
||||
// widthFVGStartedBar,
|
||||
// clrFVGStartedBar,
|
||||
// styleFVGStartedBar,
|
||||
// widthFVGActivatedBar,
|
||||
// clrFVGActivatedBar,
|
||||
// styleFVGActivatedBar,
|
||||
// widthFVGBreakedBar,
|
||||
// clrFVGBreakedBar,
|
||||
// styleFVGBreakedBar,
|
||||
// widthFVGWorkedBar,
|
||||
// clrFVGWorkedBar,
|
||||
// styleFVGWorkedBar //
|
||||
// );
|
||||
// has = IsValidSize(fvgsCount);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// Copy(
|
||||
// tmpObjects,
|
||||
// objects,
|
||||
// false //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
Clean(tmpObjects);
|
||||
|
||||
+2992
-2678
File diff suppressed because it is too large
Load Diff
+140
-105
@@ -30,7 +30,7 @@ int OnInit()
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
// mPOIDetector.Init();
|
||||
mPOIDetector.Init();
|
||||
|
||||
//---
|
||||
mPOIDrawer = new XCPOIDrawer();
|
||||
@@ -79,130 +79,165 @@ void OnTick()
|
||||
mPOIDetector.GetState(mPOIState);
|
||||
|
||||
//
|
||||
bool has = mPOIState.HasFairValueGaps();
|
||||
bool has = Contains(
|
||||
X_BULLISH_FVG_DETECTED,
|
||||
mPOIEvents //
|
||||
) ||
|
||||
Contains(
|
||||
X_BEARISH_FVG_DETECTED,
|
||||
mPOIEvents //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
int count = mPOIState.CountFairValueGaps();
|
||||
for (int i = 0; i < count; i++)
|
||||
XCFVG *fvg;
|
||||
int idx = GetYoungest(mPOIState.fairValueGaps);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
mPOIState.fairValueGaps[i].To(TimeCurrent());
|
||||
fvg = mPOIState.fairValueGaps[idx];
|
||||
|
||||
//
|
||||
XCBaseObject *iObj;
|
||||
bool isCreated = mPOIDrawer.CreateFairValueGap(
|
||||
mPOIState.fairValueGaps[i],
|
||||
has = mPOIDrawer.CreateFairValueGap(
|
||||
fvg,
|
||||
iObj //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
Print("Salam");
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Print("New Fair Value Gap ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// //
|
||||
// bool has = mPOIState.HasFairValueGaps();
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// int count = mPOIState.CountFairValueGaps();
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// //
|
||||
// mPOIState.fairValueGaps[i].To(TimeCurrent());
|
||||
|
||||
// //
|
||||
// XCBaseObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateFairValueGap(
|
||||
// mPOIState.fairValueGaps[i],
|
||||
// iObj //
|
||||
// );
|
||||
// }
|
||||
|
||||
//
|
||||
// Print("Salam");
|
||||
|
||||
//
|
||||
return;
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
bool isInited = bar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
0 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// //
|
||||
// XOHCL bar;
|
||||
// bool isInited = bar.Init(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// 0 //
|
||||
// );
|
||||
// if (!isInited)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
//
|
||||
int index = 0;
|
||||
ENUM_X_DIRECTION sameBarDir;
|
||||
bool hasSameBars = mBarAnalyser.HasSameBars(
|
||||
bar,
|
||||
sameBarDir,
|
||||
index,
|
||||
3 //
|
||||
);
|
||||
if (hasSameBars)
|
||||
{
|
||||
}
|
||||
// //
|
||||
// int index = 0;
|
||||
// ENUM_X_DIRECTION sameBarDir;
|
||||
// bool hasSameBars = mBarAnalyser.HasSameBars(
|
||||
// bar,
|
||||
// sameBarDir,
|
||||
// index,
|
||||
// 3 //
|
||||
// );
|
||||
// if (hasSameBars)
|
||||
// {
|
||||
// }
|
||||
|
||||
//
|
||||
// Detect Fair Value Gap ...
|
||||
XOHCL fvgEndBar;
|
||||
XOHCL fvgStartBar;
|
||||
ENUM_X_DIRECTION fvgDir;
|
||||
bool hasFVG = mBarAnalyser.HasFairValueGap(
|
||||
bar,
|
||||
fvgStartBar,
|
||||
fvgEndBar,
|
||||
fvgDir,
|
||||
3 //
|
||||
);
|
||||
if (hasFVG)
|
||||
{
|
||||
//
|
||||
XCFVG *fvg;
|
||||
fvg = new XCFVG();
|
||||
bool isInit = fvg.Init(
|
||||
fvgStartBar,
|
||||
fvgEndBar,
|
||||
fvgDir //
|
||||
);
|
||||
// if (isInit)
|
||||
// {
|
||||
// //
|
||||
// XCBaseObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateFairValueGap(
|
||||
// fvg,
|
||||
// iObj //
|
||||
// );
|
||||
//
|
||||
// //
|
||||
// if (isCreated)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// //
|
||||
// // Detect Fair Value Gap ...
|
||||
// XOHCL fvgEndBar;
|
||||
// XOHCL fvgStartBar;
|
||||
// ENUM_X_DIRECTION fvgDir;
|
||||
// bool hasFVG = mBarAnalyser.HasFairValueGap(
|
||||
// bar,
|
||||
// fvgStartBar,
|
||||
// fvgEndBar,
|
||||
// fvgDir,
|
||||
// 3 //
|
||||
// );
|
||||
// if (hasFVG)
|
||||
// {
|
||||
// //
|
||||
// XCFVG *fvg;
|
||||
// fvg = new XCFVG();
|
||||
// bool isInit = fvg.Init(
|
||||
// fvgStartBar,
|
||||
// fvgEndBar,
|
||||
// fvgDir //
|
||||
// );
|
||||
// // if (isInit)
|
||||
// // {
|
||||
// // //
|
||||
// // XCBaseObject *iObj;
|
||||
// // bool isCreated = mPOIDrawer.CreateFairValueGap(
|
||||
// // fvg,
|
||||
// // iObj //
|
||||
// // );
|
||||
// //
|
||||
// // //
|
||||
// // if (isCreated)
|
||||
// // {
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
|
||||
//
|
||||
XOHCL obBar;
|
||||
ENUM_X_DIRECTION obDir;
|
||||
bool hasOB = mBarAnalyser.HasOrderBlock(
|
||||
bar,
|
||||
obBar,
|
||||
obDir,
|
||||
3 //
|
||||
);
|
||||
if (hasOB)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *ob;
|
||||
ob = new XCOrderBlock();
|
||||
bool isInit = ob.Init(
|
||||
obBar,
|
||||
obDir //
|
||||
);
|
||||
if (isInit)
|
||||
{
|
||||
// //
|
||||
// XCBaseObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateOrderBlock(
|
||||
// ob,
|
||||
// iObj //
|
||||
// );
|
||||
// //
|
||||
// XOHCL obBar;
|
||||
// ENUM_X_DIRECTION obDir;
|
||||
// bool hasOB = mBarAnalyser.HasOrderBlock(
|
||||
// bar,
|
||||
// obBar,
|
||||
// obDir,
|
||||
// 3 //
|
||||
// );
|
||||
// if (hasOB)
|
||||
// {
|
||||
// //
|
||||
// XCOrderBlock *ob;
|
||||
// ob = new XCOrderBlock();
|
||||
// bool isInit = ob.Init(
|
||||
// obBar,
|
||||
// obDir //
|
||||
// );
|
||||
// if (isInit)
|
||||
// {
|
||||
// // //
|
||||
// // XCBaseObject *iObj;
|
||||
// // bool isCreated = mPOIDrawer.CreateOrderBlock(
|
||||
// // ob,
|
||||
// // iObj //
|
||||
// // );
|
||||
|
||||
// //
|
||||
// if (isCreated)
|
||||
// {
|
||||
// Print("Order Block ...");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// // //
|
||||
// // if (isCreated)
|
||||
// // {
|
||||
// // Print("Order Block ...");
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
|
||||
//
|
||||
}
|
||||
// //
|
||||
// }
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
@@ -388,7 +388,6 @@ struct XOBFVG
|
||||
|
||||
//
|
||||
bool IsValidZone(
|
||||
XOHCL &invalidBar,
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
@@ -401,9 +400,6 @@ struct XOBFVG
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
invalidBar.Clean();
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
@@ -412,101 +408,132 @@ struct XOBFVG
|
||||
}
|
||||
|
||||
//
|
||||
XCFVG *fvg;
|
||||
result = GetMainFVG(fvg);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
ZeroMemory(fvg);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL startedBar;
|
||||
bool isBodyOut = false;
|
||||
result = fvg.IsStarted(
|
||||
fvg.GetDirection(),
|
||||
startedBar,
|
||||
isBodyOut //
|
||||
XCFVG *tmpFVGs[];
|
||||
Copy(
|
||||
fvgs,
|
||||
tmpFVGs //
|
||||
);
|
||||
if (!result)
|
||||
int count = CountFVGs();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
ZeroMemory(fvg);
|
||||
startedBar.Clean();
|
||||
XCFVG *iFVG = tmpFVGs[i];
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
bool isBullish = fvg.IsBullish();
|
||||
|
||||
//
|
||||
int fromIndex = iBarShift(
|
||||
fvg.GetSymbol(),
|
||||
fvg.GetPeriod(),
|
||||
startedBar.NextAt() //
|
||||
);
|
||||
result = IsValidIndex(fromIndex);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
ZeroMemory(fvg);
|
||||
startedBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isInited = false;
|
||||
for (int i = barIndex; i < fromIndex; i++)
|
||||
{
|
||||
//
|
||||
isInited = bar.Init(
|
||||
fvg.GetSymbol(),
|
||||
fvg.GetPeriod(),
|
||||
i //
|
||||
XOHCL startedBar;
|
||||
bool isBodyOut = false;
|
||||
result = iFVG.IsStarted(
|
||||
iFVG.GetDirection(),
|
||||
startedBar,
|
||||
isBodyOut //
|
||||
);
|
||||
if (!isInited)
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
ZeroMemory(iFVG);
|
||||
startedBar.Clean();
|
||||
ArrayRemove(
|
||||
fvgs,
|
||||
i,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBarAbove =
|
||||
bar.low > fvg.Upper();
|
||||
bool isBarBelow =
|
||||
bar.high < fvg.Lower();
|
||||
XOHCL bar;
|
||||
bool isBullish = iFVG.IsBullish();
|
||||
datetime fromTime = startedBar.NextAt();
|
||||
|
||||
//
|
||||
result =
|
||||
isBullish
|
||||
? isBarAbove
|
||||
: isBarBelow;
|
||||
int fromIndex = iBarShift(
|
||||
iFVG.GetSymbol(),
|
||||
iFVG.GetPeriod(),
|
||||
fromTime //
|
||||
);
|
||||
result = IsValidIndex(fromIndex);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
invalidBar = bar;
|
||||
bar.Clean();
|
||||
ZeroMemory(iFVG);
|
||||
startedBar.Clean();
|
||||
ArrayRemove(
|
||||
fvgs,
|
||||
i,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isInited = false;
|
||||
bool isValidFVG = false;
|
||||
for (int j = barIndex; j < fromIndex; j++)
|
||||
{
|
||||
//
|
||||
isInited = bar.Init(
|
||||
iFVG.GetSymbol(),
|
||||
iFVG.GetPeriod(),
|
||||
j //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBarAbove =
|
||||
bar.low > iFVG.Upper();
|
||||
bool isBarBelow =
|
||||
bar.high < iFVG.Lower();
|
||||
|
||||
//
|
||||
isValidFVG =
|
||||
isBullish
|
||||
? isBarAbove
|
||||
: isBarBelow;
|
||||
if (!isValidFVG)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
if (!isValidFVG)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
fvgs,
|
||||
i,
|
||||
1 //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
ZeroMemory(iFVG);
|
||||
startedBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
ZeroMemory(fvg);
|
||||
startedBar.Clean();
|
||||
Clean(tmpFVGs);
|
||||
|
||||
//
|
||||
result = HasFVGs();
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
@@ -164,7 +164,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
double targets[];
|
||||
double reward = 0;
|
||||
XBoxZone signalBox;
|
||||
XOBFVG activatedZone;
|
||||
int activatedFVGIDX = 0;
|
||||
int activatedZoneIDX = 0;
|
||||
double amountPercent = 0;
|
||||
bool hasPriority = false;
|
||||
bool hasSignalBox = false;
|
||||
@@ -214,16 +215,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
|
||||
//
|
||||
hasWaitingZones = workingZone.DetectZone(
|
||||
drawer,
|
||||
provider //
|
||||
);
|
||||
if (hasWaitingZones)
|
||||
{
|
||||
//
|
||||
// Validate Waiting Zones ...
|
||||
workingZone.ValidateWaitingZones(zIndex);
|
||||
hasWaitingZones = HasChild(workingZone.waitingZones);
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Working Zone Destory or not ...
|
||||
@@ -239,7 +232,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
//
|
||||
result = false;
|
||||
workingZone.Clean();
|
||||
activatedZone.Clean();
|
||||
hasWorkingZone = false;
|
||||
|
||||
//
|
||||
@@ -255,13 +247,41 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Start Draw ...
|
||||
//
|
||||
|
||||
//
|
||||
UpdateTo(cTime);
|
||||
|
||||
//
|
||||
// Draw Working Zone ...
|
||||
if (hasWorkingZone)
|
||||
{
|
||||
//
|
||||
workingZone.Draw(
|
||||
drawer,
|
||||
//
|
||||
true, // Draw Supply Zone ...
|
||||
true, // Draw Demand Zone ...
|
||||
true, // Draw Waiting Zones ...
|
||||
true // Draw Waiting Zones Box Area ...
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// End Draw ...
|
||||
//
|
||||
|
||||
//
|
||||
// Detect Signal Box ...
|
||||
hasSignalBox =
|
||||
hasWorkingZone &&
|
||||
hasWaitingZones &&
|
||||
workingZone.IsZoneActivated(
|
||||
activatedZone,
|
||||
activatedZoneIDX,
|
||||
activatedFVGIDX,
|
||||
provider,
|
||||
zIndex //
|
||||
);
|
||||
@@ -269,7 +289,14 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
{
|
||||
//
|
||||
signalBox.Clean();
|
||||
hasSignalBox = activatedZone.ToZone(signalBox);
|
||||
|
||||
//
|
||||
XOBFVG iOBFVG = workingZone.waitingZones[activatedZoneIDX];
|
||||
XCFVG *activatedFVG = iOBFVG.fvgs[activatedFVGIDX];
|
||||
hasSignalBox = ToBox(
|
||||
signalBox,
|
||||
activatedFVG //
|
||||
);
|
||||
if (hasSignalBox)
|
||||
{
|
||||
//
|
||||
@@ -278,27 +305,42 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE;
|
||||
|
||||
//
|
||||
int idx = FindIndex(
|
||||
activatedZone,
|
||||
workingZone.waitingZones //
|
||||
ArrayRemove(
|
||||
workingZone.waitingZones[activatedZoneIDX].fvgs,
|
||||
activatedFVGIDX,
|
||||
1 //
|
||||
);
|
||||
bool has = IsValidIndex(idx);
|
||||
if (has)
|
||||
bool isValid = workingZone.waitingZones[activatedZoneIDX].IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
workingZone.waitingZones,
|
||||
idx,
|
||||
1 //
|
||||
AddRef(
|
||||
workingZone.waitingZones[activatedZoneIDX],
|
||||
workingZone.unavailableZones //
|
||||
);
|
||||
|
||||
//
|
||||
AddRef(
|
||||
activatedZone,
|
||||
workingZone.unavailableZones //
|
||||
ArrayRemove(
|
||||
workingZone.waitingZones,
|
||||
activatedZoneIDX,
|
||||
1 //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
iOBFVG.Clean();
|
||||
ZeroMemory(activatedFVG);
|
||||
}
|
||||
|
||||
//
|
||||
// Remove Invalidate Zones ...
|
||||
if (hasWaitingZones)
|
||||
{
|
||||
//
|
||||
// Validate Waiting Zones ...
|
||||
workingZone.ValidateWaitingZones(zIndex);
|
||||
hasWaitingZones = workingZone.HasWaitingZones();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -314,10 +356,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
signalBoxDir = X_DIRECTION_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
// Check Priority Exists ...
|
||||
hasPriority = workingZone
|
||||
@@ -732,37 +770,11 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
mConditions.setupTime = cTime;
|
||||
mConditions.dir = signalBoxDir;
|
||||
mConditions.priority = priority;
|
||||
mConditions.provider = signalProvider;
|
||||
mConditions.signalBox = signalBox;
|
||||
mConditions.provider = signalProvider;
|
||||
mConditions.amountPercent = amountPercent;
|
||||
}
|
||||
|
||||
//
|
||||
UpdateTo(cTime);
|
||||
|
||||
//
|
||||
// Draw Working Zone ...
|
||||
if (hasWorkingZone)
|
||||
{
|
||||
//
|
||||
workingZone.Draw(
|
||||
drawer,
|
||||
//
|
||||
true, // Draw Supply Zone ...
|
||||
true, // Draw Demand Zone ...
|
||||
true, // Draw Waiting Zones ...
|
||||
true // Draw Waiting Zones Box Area ...
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
if (hasSignalBox)
|
||||
{
|
||||
//
|
||||
Print("Has Signal Box ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -779,7 +791,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
|
||||
//
|
||||
signalBox.Clean();
|
||||
activatedZone.Clean();
|
||||
consolidationZBar.Clean();
|
||||
|
||||
//
|
||||
|
||||
@@ -273,7 +273,6 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
bool DetectZone(
|
||||
XCPOIDrawer *drawer,
|
||||
X121SMCStrategySignalProviderData &provider //
|
||||
)
|
||||
{
|
||||
@@ -290,6 +289,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
@@ -461,15 +461,102 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
// Detect OB FVG ...
|
||||
result =
|
||||
hasNewOrderBlock &&
|
||||
hasNewFairValueGap &&
|
||||
ob.GetDirection() == fvg.GetDirection();
|
||||
if (result)
|
||||
if (hasNewOrderBlock)
|
||||
{
|
||||
//
|
||||
obFVG.ob = ob;
|
||||
obFVG.AddFVG(fvg);
|
||||
XOHCL obStartedBar;
|
||||
bool isOBStartedBodyOut = false;
|
||||
bool isOBStarted = ob.IsStarted(
|
||||
ob.GetDirection(),
|
||||
obStartedBar,
|
||||
isOBStartedBodyOut //
|
||||
);
|
||||
|
||||
//
|
||||
has = isOBStarted &&
|
||||
isOBStartedBodyOut;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
obFVG.ob = ob;
|
||||
|
||||
//
|
||||
// Select FVGs ...
|
||||
count = provider
|
||||
.analyseState
|
||||
.CountFairValueGaps();
|
||||
has = IsValidSize(count);
|
||||
if (!has)
|
||||
{
|
||||
obFVG.Clean();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Select FVG ...
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCFVG *iFVG = provider
|
||||
.analyseState
|
||||
.fairValueGaps[i];
|
||||
bool isBullish = iFVG.IsBullish();
|
||||
|
||||
//
|
||||
XOHCL iStartedBar;
|
||||
bool isBodyOut = false;
|
||||
bool isStarted = iFVG.IsStarted(
|
||||
iFVG.GetDirection(),
|
||||
iStartedBar,
|
||||
isBodyOut //
|
||||
);
|
||||
iStartedBar.Clean();
|
||||
|
||||
//
|
||||
bool isKindPassed = isStarted &&
|
||||
isBodyOut;
|
||||
bool isSameDir = iFVG.GetDirection() == ob.GetDirection();
|
||||
bool isFromPassed = iFVG.From() >= obStartedBar.time;
|
||||
bool isPlacePassed =
|
||||
//
|
||||
IsInsideOrDiff(
|
||||
iFVG,
|
||||
ob //
|
||||
)
|
||||
//
|
||||
||
|
||||
//
|
||||
(isBullish
|
||||
? IsAboveDiff(
|
||||
iFVG,
|
||||
ob,
|
||||
true // Ignore Inside ...
|
||||
)
|
||||
: IsBelowDiff(
|
||||
iFVG,
|
||||
ob,
|
||||
true // Ignore Inside ...
|
||||
)
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
has = isSameDir &&
|
||||
isKindPassed &&
|
||||
isFromPassed &&
|
||||
isPlacePassed;
|
||||
if (has)
|
||||
{
|
||||
obFVG.AddFVG(iFVG);
|
||||
}
|
||||
|
||||
//
|
||||
ZeroMemory(iFVG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
has = obFVG.IsValid();
|
||||
@@ -503,98 +590,12 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
obFVG.Clean();
|
||||
obStartedBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Detect SupDem FVG ...
|
||||
// if (!result)
|
||||
// {
|
||||
// //
|
||||
// result = hasNewFairValueGap &&
|
||||
// (hasNewSupply ||
|
||||
// hasNewDemand);
|
||||
// if (result)
|
||||
// {
|
||||
// //
|
||||
// // Converts Supply or Demand Zone to OrderBlock ...
|
||||
// XOHCL bar;
|
||||
// ob = new XCOrderBlock();
|
||||
// if (hasNewSupply)
|
||||
// {
|
||||
// //
|
||||
// has = supply.FillBar(bar);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = ob.Init(
|
||||
// bar,
|
||||
// X_DIRECTION_BEARISH //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// ob.Upper(supply.Upper());
|
||||
// ob.Lower(supply.Lower());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if (hasNewDemand)
|
||||
// {
|
||||
// //
|
||||
// has = demand.FillBar(bar);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = ob.Init(
|
||||
// bar,
|
||||
// X_DIRECTION_BULLISH //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// ob.Upper(demand.Upper());
|
||||
// ob.Lower(demand.Lower());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// obFVG.ob = ob;
|
||||
// obFVG.AddFVG(fvg);
|
||||
|
||||
// //
|
||||
// has = obFVG.IsValid();
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// // Check Item Is not Exists ...
|
||||
// idx = FindIndex(
|
||||
// obFVG,
|
||||
// waitingZones //
|
||||
// );
|
||||
// has = !IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// // New Waiting Zone ...
|
||||
// AddRef(
|
||||
// obFVG,
|
||||
// waitingZones //
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// // Update Exists Waiting Zone ...
|
||||
// waitingZones[idx].AddFVG(fvg);
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// bar.Clean();
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
result = HasWaitingZones();
|
||||
|
||||
@@ -635,6 +636,12 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
if (barIndex == 0)
|
||||
{
|
||||
barIndex = 1;
|
||||
}
|
||||
|
||||
//
|
||||
has = IsValid() &&
|
||||
HasWaitingZones();
|
||||
@@ -649,12 +656,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
for (int i = 0; i < result; i++)
|
||||
{
|
||||
//
|
||||
XOBFVG iOBFVG = waitingZones[i];
|
||||
|
||||
//
|
||||
XOHCL iInvalidBar;
|
||||
has = iOBFVG.IsValidZone(
|
||||
iInvalidBar,
|
||||
has = waitingZones[i].IsValidZone(
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -667,13 +669,10 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iOBFVG,
|
||||
waitingZones[i],
|
||||
unavailableZones //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
iInvalidBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -697,7 +696,8 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
bool IsZoneActivated(
|
||||
XOBFVG &zone,
|
||||
int &zoneIDX,
|
||||
int &fvgIDX,
|
||||
X121SMCStrategySignalProviderData &provider,
|
||||
int barIndex = 0 //
|
||||
)
|
||||
@@ -706,8 +706,10 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Cleanup Result ...
|
||||
zone.Clean();
|
||||
zoneIDX = -1;
|
||||
|
||||
//
|
||||
fvgIDX = -1;
|
||||
|
||||
//
|
||||
// Normalize Bar Index ...
|
||||
@@ -742,7 +744,6 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
zone.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -752,6 +753,64 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
double peak = provider.decisionXConditions.peaksBuffer[1];
|
||||
double vale = provider.decisionXConditions.valesBuffer[1];
|
||||
|
||||
//
|
||||
double analysePeak = provider.analyseXConditions.peaksBuffer[1];
|
||||
double analyseVale = provider.analyseXConditions.valesBuffer[1];
|
||||
|
||||
//
|
||||
double consolidationPeak = provider.consolidationXConditions.peaksBuffer[1];
|
||||
double consolidationVale = provider.consolidationXConditions.valesBuffer[1];
|
||||
|
||||
//
|
||||
double visionPeak = provider.visionXConditions.peaksBuffer[1];
|
||||
double visionVale = provider.visionXConditions.valesBuffer[1];
|
||||
|
||||
//
|
||||
bool isPeaksSame =
|
||||
peak == analysePeak &&
|
||||
analysePeak == consolidationPeak;
|
||||
|
||||
//
|
||||
bool isValesSame =
|
||||
vale == analyseVale &&
|
||||
analyseVale == consolidationVale;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
bool isDecisionScoreBullish =
|
||||
provider.decisionBullishScore > provider.decisionBearishScore;
|
||||
|
||||
//
|
||||
bool isDecisionScoreBearish =
|
||||
provider.decisionBearishScore > provider.decisionBullishScore;
|
||||
|
||||
//
|
||||
bool isAnalyseScoreBullish =
|
||||
provider.analyseBullishScore > provider.analyseBearishScore;
|
||||
|
||||
//
|
||||
bool isAnalyseScoreBearish =
|
||||
provider.analyseBearishScore > provider.analyseBullishScore;
|
||||
|
||||
//
|
||||
bool isConsolidationScoreBullish =
|
||||
provider.consolidationBullishScore > provider.consolidationBearishScore;
|
||||
|
||||
//
|
||||
bool isConsolidationScoreBearish =
|
||||
provider.consolidationBearishScore > provider.consolidationBullishScore;
|
||||
|
||||
//
|
||||
bool isVisionScoreBullish =
|
||||
provider.visionBullishScore > provider.visionBearishScore;
|
||||
|
||||
//
|
||||
bool isVisionScoreBearish =
|
||||
provider.visionBearishScore > provider.visionBullishScore;
|
||||
|
||||
//
|
||||
int count = CountWaitingZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -764,56 +823,112 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
bool isBullish = iOBFVG.IsBullish();
|
||||
|
||||
//
|
||||
XBoxZone iBox;
|
||||
result = iOBFVG.ToZone(iBox);
|
||||
if (!result)
|
||||
int fvgsCount = iOBFVG.CountFVGs();
|
||||
bool has = IsValidSize(fvgsCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iBox.Clean();
|
||||
iOBFVG.Clean();
|
||||
for (int j = 0; j < fvgsCount; j++)
|
||||
{
|
||||
//
|
||||
XCFVG *jFVG = iOBFVG.fvgs[j];
|
||||
|
||||
//
|
||||
continue;
|
||||
//
|
||||
XBoxZone iBox;
|
||||
has = ToBox(
|
||||
iBox,
|
||||
jFVG //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
double iRange = iBox.lower + ((iBox.upper - iBox.lower) / 2);
|
||||
|
||||
//
|
||||
// Activate Zone Using PV ...
|
||||
bool isPVPassed =
|
||||
isBullish
|
||||
? vale < iBox.upper &&
|
||||
vale > iBox.lower
|
||||
: peak < iBox.upper &&
|
||||
peak > iBox.lower;
|
||||
bool isPV50Passed =
|
||||
isBullish
|
||||
? vale < iBox.upper &&
|
||||
vale < iRange &&
|
||||
vale > iBox.lower
|
||||
: peak < iBox.upper &&
|
||||
peak < iRange &&
|
||||
peak > iBox.lower;
|
||||
|
||||
//
|
||||
// Activate Zone using Rejection ...
|
||||
bool isRejected =
|
||||
isBullish
|
||||
? bar.low <= iBox.upper &&
|
||||
bar.GetDown() > iBox.upper
|
||||
: bar.high >= iBox.lower &&
|
||||
bar.GetUp() < iBox.lower;
|
||||
|
||||
//
|
||||
// Combine Result ...
|
||||
result = isPV50Passed;
|
||||
// || isPV50Passed
|
||||
// || isRejected;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
fvgIDX = j;
|
||||
iBox.Clean();
|
||||
zoneIDX = i;
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
iBox.Clean();
|
||||
ZeroMemory(jFVG);
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// XCFVG *fvg;
|
||||
// result = iOBFVG.GetMainFVG(fvg);
|
||||
// if (!result)
|
||||
// {
|
||||
// //
|
||||
// iOBFVG.Clean();
|
||||
// ZeroMemory(fvg);
|
||||
|
||||
// //
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//
|
||||
result =
|
||||
isBullish
|
||||
? vale < iBox.upper &&
|
||||
vale > iBox.lower
|
||||
: peak < iBox.upper &&
|
||||
peak > iBox.lower;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
zone = iOBFVG;
|
||||
iOBFVG.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
iOBFVG.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
result =
|
||||
IsValidIndex(fvgIDX) &&
|
||||
IsValidIndex(zoneIDX);
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
bar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -1466,6 +1581,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
iObjects,
|
||||
true, // Draw Order Block ...
|
||||
true, // Draw Fair Value Gaps ...
|
||||
true, // Draw All Fair Value Gaps ...
|
||||
//
|
||||
true, // Draw OB StartedBar ...
|
||||
true, // Draw OB ActivatedBar ...
|
||||
|
||||
Reference in New Issue
Block a user