Last ...
This commit is contained in:
@@ -2261,3 +2261,333 @@
|
|||||||
{
|
{
|
||||||
bearOB = mBearOB;
|
bearOB = mBearOB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect an Order Block in Vision ...
|
||||||
|
if (conditions.visionBullOB == NULL ||
|
||||||
|
conditions.visionBearOB == NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = DetectOrderBlocks(
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
conditions.visionBullOB,
|
||||||
|
conditions.visionBearOB,
|
||||||
|
cBar,
|
||||||
|
mVisionState //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
conditions.Clean();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XCBullishOrderBlockObject *iBullOBObj;
|
||||||
|
conditions.visionBullOB.To(cTime);
|
||||||
|
result = mPOIDrawer.CreateBullishOrderBlock(
|
||||||
|
conditions.visionBullOB,
|
||||||
|
iBullOBObj //
|
||||||
|
);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iBullOBObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XCBearishOrderBlockObject *iBearOBObj;
|
||||||
|
conditions.visionBearOB.To(cTime);
|
||||||
|
result = mPOIDrawer.CreateBearishOrderBlock(
|
||||||
|
conditions.visionBearOB,
|
||||||
|
iBearOBObj //
|
||||||
|
);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iBearOBObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Consolidation Order Blocks ...
|
||||||
|
if (conditions.consolidationBullOB == NULL ||
|
||||||
|
conditions.consolidationBearOB == NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = DetectOrderBlocks(
|
||||||
|
conditions.visionBullOB,
|
||||||
|
conditions.visionBearOB,
|
||||||
|
conditions.consolidationBullOB,
|
||||||
|
conditions.consolidationBearOB,
|
||||||
|
cBar,
|
||||||
|
mConsolidationState //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
conditions.Clean();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XCBullishOrderBlockObject *iBullOBObj;
|
||||||
|
conditions.consolidationBullOB.To(cTime);
|
||||||
|
result = mPOIDrawer.CreateBullishOrderBlock(
|
||||||
|
conditions.consolidationBullOB,
|
||||||
|
iBullOBObj //
|
||||||
|
);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iBullOBObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XCBearishOrderBlockObject *iBearOBObj;
|
||||||
|
conditions.consolidationBearOB.To(cTime);
|
||||||
|
result = mPOIDrawer.CreateBearishOrderBlock(
|
||||||
|
conditions.consolidationBearOB,
|
||||||
|
iBearOBObj //
|
||||||
|
);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iBearOBObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
msg = "OrderBlocks Detected ...";
|
||||||
|
Alert(msg);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Trigger Order Flow ...
|
||||||
|
if (!HasValidOrderFlow())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int samePivots = 40;
|
||||||
|
int requiredPivots = 10;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool useVisionState = false;
|
||||||
|
bool useConsolidationState = false;
|
||||||
|
bool useVerificationState = false;
|
||||||
|
bool useAnalyseState = false;
|
||||||
|
bool useDecisionState = true;
|
||||||
|
bool useTriggerState = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
DetectOrderFlow(
|
||||||
|
cIndex,
|
||||||
|
samePivots,
|
||||||
|
requiredPivots,
|
||||||
|
mTriggerCycleHelper,
|
||||||
|
mOrderFlow,
|
||||||
|
mOrderFlowDir,
|
||||||
|
//
|
||||||
|
// Filling Pivot State ...
|
||||||
|
useVisionState, // Use Vision State ...
|
||||||
|
useConsolidationState, // Use Consolidation State ...
|
||||||
|
useVerificationState, // Use Verification State ...
|
||||||
|
useAnalyseState, // Use Analyse State ...
|
||||||
|
useDecisionState, // Use Decision State ...
|
||||||
|
useTriggerState // Use Trigger State ...
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = HasValidOrderFlow();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
conditions.Clean();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool ignoreSwingHighs = true;
|
||||||
|
bool ignoreSwingLows = true;
|
||||||
|
bool ignoreSupportZones = true;
|
||||||
|
bool ignoreResistanceZones = true;
|
||||||
|
bool ignoreSupplyZones = true;
|
||||||
|
bool ignoreDemandZones = true;
|
||||||
|
bool ignoreBullishOrderBlocks = true;
|
||||||
|
bool ignoreBearishOrderBlocks = true;
|
||||||
|
bool ignoreBullishFairValueGaps = true;
|
||||||
|
bool ignoreBearishFairValueGaps = true;
|
||||||
|
bool ignoreBullishRejectionBars = true;
|
||||||
|
bool ignoreBearishRejectionBars = true;
|
||||||
|
bool ignoreBullishMomentumBars = true;
|
||||||
|
bool ignoreBearishMomentumBars = true;
|
||||||
|
|
||||||
|
//
|
||||||
|
RedrawOrderFlow(
|
||||||
|
false, // Force Clean ...
|
||||||
|
false, // Same Period ...
|
||||||
|
true, // Order Flow ...
|
||||||
|
true, // Order Flow State ...
|
||||||
|
false, // Only Last Order Flow ...
|
||||||
|
true, // Only Last Order Flow State ...
|
||||||
|
//
|
||||||
|
mOrderFlowDir, // Direction Force ...
|
||||||
|
ignoreSwingHighs,
|
||||||
|
ignoreSwingLows,
|
||||||
|
ignoreSupportZones,
|
||||||
|
ignoreResistanceZones,
|
||||||
|
ignoreSupplyZones,
|
||||||
|
ignoreDemandZones,
|
||||||
|
ignoreBullishOrderBlocks,
|
||||||
|
ignoreBearishOrderBlocks,
|
||||||
|
ignoreBullishFairValueGaps,
|
||||||
|
ignoreBearishFairValueGaps,
|
||||||
|
ignoreBullishRejectionBars,
|
||||||
|
ignoreBearishRejectionBars,
|
||||||
|
ignoreBullishMomentumBars,
|
||||||
|
ignoreBearishMomentumBars //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
msg = "Found OrderFlow : " + (IsBullish(mOrderFlowDir) ? "Bullish" : "Berish");
|
||||||
|
Alert(msg);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Market Conditions for
|
||||||
|
// Specified Structure ...
|
||||||
|
// ENUM_X_DIRECTION marketStructureDir = X_DIRECTION_NONE;
|
||||||
|
// result = conditions.HasDirection(
|
||||||
|
// marketStructureDir,
|
||||||
|
// cBar //
|
||||||
|
// );
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// conditions.Clean();
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// msg = "Found Market Strucutre : " + (IsBullish(marketStructureDir) ? "Bullish" : "Berish");
|
||||||
|
// Alert(msg);
|
||||||
|
|
||||||
|
//
|
||||||
|
// conditions.marketStructureDir = marketStructureDir;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// XPVPivot lastPivot;
|
||||||
|
// result = GetLastItem(
|
||||||
|
// lastPivot,
|
||||||
|
// mOrderFlow //
|
||||||
|
// );
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// conditions.Clean();
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Last FVG ...
|
||||||
|
// XOHCL breakerBar;
|
||||||
|
// result = DetectLastBreakerBar(
|
||||||
|
// cBar,
|
||||||
|
// breakerBar,
|
||||||
|
// lastPivot,
|
||||||
|
// marketStructureDir //
|
||||||
|
// );
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// conditions.Clean();
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// msg = "Found Breaker Bar: " + breakerBar.GetTag();
|
||||||
|
// Alert(msg);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Detect Nearest Momentum or Rejection Bar ...
|
||||||
|
// XOHCL decisionBar;
|
||||||
|
// result = mDecisionCycleHelper.DetectNearestDecisionBar(
|
||||||
|
// decisionBar,
|
||||||
|
// marketStructureDir,
|
||||||
|
// cBar //
|
||||||
|
// );
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// msg = "Found Decision Bar: " + decisionBar.GetTag();
|
||||||
|
// Alert(msg);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Detect Nearest Sar Change ...
|
||||||
|
// XOHCL sarChangeBar;
|
||||||
|
// result = mTriggerCycleHelper.DetectNearestCSARChange(
|
||||||
|
// sarChangeBar,
|
||||||
|
// cBar //
|
||||||
|
// );
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// conditions.Clean();
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// msg = "Found Sar Change Bar: " + sarChangeBar.GetTag();
|
||||||
|
// Alert(msg);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Now we Hvae to Check Other Conditions ...
|
||||||
|
// result =
|
||||||
|
// // breakerBar.time > sarChangeBar.time &&
|
||||||
|
// // decisionBar.time > breakerBar.time;
|
||||||
|
// decisionBar.time > sarChangeBar.time;
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// conditions.Clean();
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Now we Have Check Direction Related Conditions ...
|
||||||
|
// if (IsBullish(marketStructureDir))
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// result =
|
||||||
|
// // bid > decisionBar.high &&
|
||||||
|
// // bid > breakerBar.high &&
|
||||||
|
// bid > sarChangeBar.high &&
|
||||||
|
// bid > conditions.triggerConditions.xchsarConditions.cSars[0];
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// result =
|
||||||
|
// // bid < decisionBar.low &&
|
||||||
|
// // bid < breakerBar.low &&
|
||||||
|
// bid < sarChangeBar.high &&
|
||||||
|
// bid < conditions.triggerConditions.xchsarConditions.cSars[0];
|
||||||
|
// }
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// conditions.Clean();
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// conditions.provider = "X121SMC";
|
||||||
|
// if (IsBullish(marketStructureDir))
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // conditions.sl = decisionBar.low;
|
||||||
|
// // conditions.sl = breakerBar.low;
|
||||||
|
// conditions.sl = conditions.triggerConditions.xchsarConditions.cSars[0];
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // conditions.sl = decisionBar.high;
|
||||||
|
// // conditions.sl = breakerBar.high;
|
||||||
|
// conditions.sl = conditions.triggerConditions.xchsarConditions.cSars[0];
|
||||||
|
// }
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -10362,6 +10362,35 @@ bool GetLastItem(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Remove Last Item of Specified Buffer ...
|
||||||
|
template <typename T>
|
||||||
|
bool RemoveLastItem(
|
||||||
|
T &buffer[] // Specified Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(buffer);
|
||||||
|
result = IsValidSize(count);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ArrayRemove(
|
||||||
|
buffer,
|
||||||
|
count - 1,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search Array For Specific Item ...
|
// Search Array For Specific Item ...
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -26,6 +26,140 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Definitions ...
|
// Definitions ...
|
||||||
|
struct XSarChange
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
ENUM_X_DIRECTION dir; // Sar Changed To Direction ...
|
||||||
|
datetime time; // Sar Changed Time ...
|
||||||
|
double last; // Sar Value Before Change ...
|
||||||
|
double value; // Sar Value After Change ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
XSarChange()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup ...
|
||||||
|
*/
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
last = 0;
|
||||||
|
value = 0;
|
||||||
|
time = NULL;
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
last > 0 &&
|
||||||
|
value > 0 &&
|
||||||
|
IsValid(time) &&
|
||||||
|
HasDirection(dir);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize ...
|
||||||
|
*
|
||||||
|
* @param _last: Last Sar Value ...
|
||||||
|
* @param _current: Current Sar Value ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool Init(
|
||||||
|
double _last,
|
||||||
|
double _current,
|
||||||
|
datetime _time,
|
||||||
|
ENUM_X_DIRECTION _dir //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
_last > 0 &&
|
||||||
|
_current > 0 &&
|
||||||
|
IsValid(_time) &&
|
||||||
|
HasDirection(_dir);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
dir = _dir;
|
||||||
|
last = _last;
|
||||||
|
time = _time;
|
||||||
|
value = _current;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Change is Bullish ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsBullish()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
IsValid() &&
|
||||||
|
IsBullish(dir);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Change is Bearish ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsBearishّ()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
IsValid() &&
|
||||||
|
IsBearish(dir);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implementations ...
|
// Implementations ...
|
||||||
@@ -40,6 +174,8 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
//
|
//
|
||||||
// XPV ...
|
// XPV ...
|
||||||
XCXPVHelper *mXPVHelper;
|
XCXPVHelper *mXPVHelper;
|
||||||
|
XPVPivot pivots[];
|
||||||
|
XPVPivot orderFlow[];
|
||||||
|
|
||||||
//
|
//
|
||||||
// X3MA ...
|
// X3MA ...
|
||||||
@@ -52,6 +188,7 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
//
|
//
|
||||||
// XCHSAR ...
|
// XCHSAR ...
|
||||||
XCXCHSARHelper *mXCHSARHelper;
|
XCXCHSARHelper *mXCHSARHelper;
|
||||||
|
XSarChange sarChanges[];
|
||||||
|
|
||||||
//
|
//
|
||||||
// POI Detector ...
|
// POI Detector ...
|
||||||
@@ -271,6 +408,102 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Specified Bar ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL instance ...
|
||||||
|
* @param index: Integer ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool GetBar(
|
||||||
|
XOHCL &bar,
|
||||||
|
int index = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
bar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
result = bar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
index //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Specified Bar ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL instance ...
|
||||||
|
* @param time: Datetime ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool GetBar(
|
||||||
|
XOHCL &bar,
|
||||||
|
datetime time = NULL //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int index = GetBarIndex(time);
|
||||||
|
result = GetBar(bar,
|
||||||
|
index //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Specified Time Bar Index ...
|
||||||
|
*
|
||||||
|
* @param time: DateTime ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int GetBarIndex(datetime time = NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
time = NormalizeTime(time);
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
result = iBarShift(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
time //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Cycle Conditions ...
|
* Retrieve Cycle Conditions ...
|
||||||
*
|
*
|
||||||
@@ -569,6 +802,557 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Parabolic Sar Extensions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Sar Changes and Save it ...
|
||||||
|
*
|
||||||
|
* @param change: XSarChange instance ...
|
||||||
|
* @param time: DateTime ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsSarChanged(
|
||||||
|
XSarChange &change,
|
||||||
|
datetime time = NULL //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
change.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL bar;
|
||||||
|
result = GetBar(
|
||||||
|
bar,
|
||||||
|
time //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL prevBar;
|
||||||
|
result = bar.GetPreviousBar(prevBar);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL prevPrevBar;
|
||||||
|
result = prevBar.GetPreviousBar(prevPrevBar);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
prevPrevBar = prevBar;
|
||||||
|
prevBar = bar;
|
||||||
|
|
||||||
|
//
|
||||||
|
int index = prevBar.Index();
|
||||||
|
|
||||||
|
//
|
||||||
|
double current = mXCHSARHelper.GetC(index);
|
||||||
|
double prev = mXCHSARHelper.GetC(index + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isCurrentBullish =
|
||||||
|
current < prevBar.low;
|
||||||
|
bool isPrevBullish =
|
||||||
|
prev < prevPrevBar.low;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isCurrentBearish =
|
||||||
|
current > prevBar.high;
|
||||||
|
bool isPrevBearish =
|
||||||
|
prev > prevPrevBar.high;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isChangedToBullish =
|
||||||
|
isCurrentBullish &&
|
||||||
|
!isPrevBullish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isChangedToBearish =
|
||||||
|
isCurrentBearish &&
|
||||||
|
!isPrevBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isChangedToBullish ||
|
||||||
|
isChangedToBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
ENUM_X_DIRECTION dir =
|
||||||
|
isChangedToBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = change
|
||||||
|
.Init(
|
||||||
|
prev,
|
||||||
|
current,
|
||||||
|
prevBar.time,
|
||||||
|
dir //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XSarChange lastChange;
|
||||||
|
bool hasLastItem = GetLastItem(
|
||||||
|
lastChange,
|
||||||
|
sarChanges //
|
||||||
|
);
|
||||||
|
bool canAdd = !hasLastItem
|
||||||
|
? true
|
||||||
|
: lastChange.time < change.time;
|
||||||
|
if (canAdd)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
change,
|
||||||
|
sarChanges //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanSarChanges();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup Unused Sar Changes ...
|
||||||
|
*/
|
||||||
|
void CleanSarChanges()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int required = 10;
|
||||||
|
int count = ArraySize(sarChanges);
|
||||||
|
if (!IsValidSize(count) || count <= required)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int mustRemove = count - required;
|
||||||
|
ArrayRemove(
|
||||||
|
sarChanges,
|
||||||
|
0,
|
||||||
|
mustRemove //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XPV Extensions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect First Pivot ...
|
||||||
|
*
|
||||||
|
* @param pivot: XPVPivot instance ...
|
||||||
|
* @param time: DateTime ...
|
||||||
|
* @param minRepetition: Integer, Minimum Repetition ...
|
||||||
|
* @param maxAllowedLoopbackBars: Integer, Max Allowed LoopBack Bars ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool DetectLastPivot(
|
||||||
|
XPVPivot &pivot,
|
||||||
|
datetime time = NULL,
|
||||||
|
int minRepetition = 40,
|
||||||
|
int maxAllowedLoopbackBars = 576 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
pivot.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
int index = GetBarIndex(time);
|
||||||
|
result = DetectPivot(
|
||||||
|
pivot,
|
||||||
|
index,
|
||||||
|
minRepetition,
|
||||||
|
maxAllowedLoopbackBars //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Pivot ...
|
||||||
|
*
|
||||||
|
* @param pivot: XPVPivot instance ...
|
||||||
|
* @param barIndex: Integer ...
|
||||||
|
* @param minRepetition: Integer, Minimum Repetition ...
|
||||||
|
* @param maxAllowedLoopbackBars: Integer, Max Allowed LoopBack Bars ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool DetectPivot(
|
||||||
|
XPVPivot &pivot,
|
||||||
|
int barIndex = 0,
|
||||||
|
int minRepetition = 40,
|
||||||
|
int maxAllowedLoopbackBars = 576 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
int start = barIndex;
|
||||||
|
int end = start + maxAllowedLoopbackBars;
|
||||||
|
|
||||||
|
//
|
||||||
|
double peak = 0;
|
||||||
|
int peakRepeate = 0;
|
||||||
|
int peakToBarIndex = 0;
|
||||||
|
int peakFromBarIndex = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
double vale = 0;
|
||||||
|
int valeRepeate = 0;
|
||||||
|
int valeToBarIndex = 0;
|
||||||
|
int valeFromBarIndex = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canLookupPeak = true;
|
||||||
|
bool canLookupVale = true;
|
||||||
|
bool canLookup = true;
|
||||||
|
while (canLookup)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Peak ...
|
||||||
|
double iPeak = mXPVHelper.GetPeak(barIndex);
|
||||||
|
if (iPeak != peak)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (peak != 0 &&
|
||||||
|
peakRepeate >= minRepetition)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XPVPivot iPivot;
|
||||||
|
|
||||||
|
//
|
||||||
|
iPivot.lower = 0;
|
||||||
|
iPivot.upper = peak;
|
||||||
|
iPivot.symbol = symbol;
|
||||||
|
iPivot.period = period;
|
||||||
|
iPivot.type = XPV_PEAK;
|
||||||
|
iPivot.repetition = peakRepeate;
|
||||||
|
iPivot.to = iTime(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
peakToBarIndex //
|
||||||
|
);
|
||||||
|
iPivot.from = iTime(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
peakFromBarIndex //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
iPivot.lower = iPivot.CalculateLower();
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid = iPivot.IsValid();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pivot = iPivot;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
peak = iPeak;
|
||||||
|
peakRepeate = 0;
|
||||||
|
peakFromBarIndex = 0;
|
||||||
|
peakToBarIndex = barIndex;
|
||||||
|
}
|
||||||
|
else if (iPeak == peak)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
peakRepeate++;
|
||||||
|
peakFromBarIndex = barIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Vale ...
|
||||||
|
double iVale = mXPVHelper.GetVale(barIndex);
|
||||||
|
if (iVale != vale)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (vale != 0 &&
|
||||||
|
valeRepeate >= minRepetition)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XPVPivot iPivot;
|
||||||
|
|
||||||
|
//
|
||||||
|
iPivot.upper = 0;
|
||||||
|
iPivot.lower = vale;
|
||||||
|
iPivot.symbol = symbol;
|
||||||
|
iPivot.period = period;
|
||||||
|
iPivot.type = XPV_VALE;
|
||||||
|
iPivot.repetition = valeRepeate;
|
||||||
|
iPivot.to = iTime(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
valeToBarIndex //
|
||||||
|
);
|
||||||
|
iPivot.from = iTime(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
valeFromBarIndex //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
iPivot.upper = iPivot.CalculateUpper();
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid = iPivot.IsValid();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pivot = iPivot;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
vale = iVale;
|
||||||
|
valeRepeate = 0;
|
||||||
|
valeFromBarIndex = 0;
|
||||||
|
valeToBarIndex = barIndex;
|
||||||
|
}
|
||||||
|
else if (iVale == vale)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
valeRepeate++;
|
||||||
|
valeFromBarIndex = barIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
canLookupPeak = !pivot.IsValid();
|
||||||
|
canLookupVale = !pivot.IsValid();
|
||||||
|
canLookup = barIndex < end &&
|
||||||
|
(canLookupPeak ||
|
||||||
|
canLookupVale);
|
||||||
|
if (canLookup)
|
||||||
|
{
|
||||||
|
barIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = pivot.IsValid();
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XPVPivot last;
|
||||||
|
bool hasLastPivot = GetLastPivot(last);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (hasLastPivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check For Pivot Update ...
|
||||||
|
bool isLastPivotSameAsCurrent =
|
||||||
|
pivot.IsValid() &&
|
||||||
|
last.IsValid() &&
|
||||||
|
pivot.from == last.from &&
|
||||||
|
pivot.type == last.type;
|
||||||
|
if (!isLastPivotSameAsCurrent)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
pivot,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanPivots();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Last Pivot ...
|
||||||
|
RemoveLastItem(pivots);
|
||||||
|
|
||||||
|
//
|
||||||
|
pivot.to = TimeCurrent();
|
||||||
|
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
pivot,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanPivots();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Add New Pivot ...
|
||||||
|
AddRef(
|
||||||
|
pivot,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanPivots();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retriece Last Pivot if Exists ...
|
||||||
|
*
|
||||||
|
* @param pivot: XPVPivot instane ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool GetLastPivot(XPVPivot &pivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
pivot.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(pivots);
|
||||||
|
if (!IsValidSize(count))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetLastItem(
|
||||||
|
pivot,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Order Flow ...
|
||||||
|
*
|
||||||
|
* @param dir: ENUM_X_DIRECTION member, Hold's Order Flow Direction ...
|
||||||
|
* @param minPivots: Integer, minimum Required Pivots for Order Flow ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool DetectOrderFlow(
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
int minPivots = 3 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize Minimum Pivots ...
|
||||||
|
if (minPivots < 2)
|
||||||
|
{
|
||||||
|
minPivots = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(orderFlow);
|
||||||
|
Copy(
|
||||||
|
pivots,
|
||||||
|
orderFlow //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Sort Pivots ...
|
||||||
|
SortPivots(orderFlow);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Filter Broken Order Flows ...
|
||||||
|
FilterBrokenPivots(orderFlow);
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(orderFlow);
|
||||||
|
result = IsValidSize(count) &&
|
||||||
|
count >= minPivots;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Order Flow Direction ...
|
||||||
|
result = DetectPivotDirection(
|
||||||
|
orderFlow,
|
||||||
|
dir //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup Unused Pivots ...
|
||||||
|
*/
|
||||||
|
void CleanPivots()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int required = 10;
|
||||||
|
int count = ArraySize(pivots);
|
||||||
|
if (!IsValidSize(count) || count <= required)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int mustRemove = count - required;
|
||||||
|
ArrayRemove(
|
||||||
|
pivots,
|
||||||
|
0,
|
||||||
|
mustRemove //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtuals ...
|
// Virtuals ...
|
||||||
|
|
||||||
|
|||||||
@@ -751,10 +751,6 @@ struct X121SMCStrategyConditions
|
|||||||
//
|
//
|
||||||
double sl;
|
double sl;
|
||||||
string provider;
|
string provider;
|
||||||
XCOrderBlock *visionBullOB;
|
|
||||||
XCOrderBlock *visionBearOB;
|
|
||||||
XCOrderBlock *consolidationBullOB;
|
|
||||||
XCOrderBlock *consolidationBearOB;
|
|
||||||
ENUM_X_DIRECTION marketStructureDir;
|
ENUM_X_DIRECTION marketStructureDir;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -779,10 +775,6 @@ struct X121SMCStrategyConditions
|
|||||||
//
|
//
|
||||||
sl = 0;
|
sl = 0;
|
||||||
provider = NULL;
|
provider = NULL;
|
||||||
visionBullOB = NULL;
|
|
||||||
visionBearOB = NULL;
|
|
||||||
consolidationBullOB = NULL;
|
|
||||||
consolidationBearOB = NULL;
|
|
||||||
marketStructureDir = X_DIRECTION_NONE;
|
marketStructureDir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -123,6 +123,15 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
double pip = GetPipPrice(symbol);
|
double pip = GetPipPrice(symbol);
|
||||||
double pip2 = 2 * pip;
|
double pip2 = 2 * pip;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Conditions ...
|
||||||
|
result = DetectConditions(conditions);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
conditions.Clean();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Spread ...
|
// Check Spread ...
|
||||||
bool isSpreadPassed = IsSpreadPass();
|
bool isSpreadPassed = IsSpreadPass();
|
||||||
@@ -137,15 +146,6 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Detect Conditions ...
|
|
||||||
result = DetectConditions(conditions);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
conditions.Clean();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Combine all Signals Conditions ...
|
// Combine all Signals Conditions ...
|
||||||
selectedSL = conditions.sl;
|
selectedSL = conditions.sl;
|
||||||
@@ -459,330 +459,58 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
conditions.visionConditions.state = mVisionState;
|
conditions.visionConditions.state = mVisionState;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Detect an Order Block in Vision ...
|
// Detect and Store Parabolic Sar Changes ...
|
||||||
if (conditions.visionBullOB == NULL ||
|
XSarChange sarChange;
|
||||||
conditions.visionBearOB == NULL)
|
bool isSarChanged = mTriggerCycleHelper
|
||||||
{
|
.IsSarChanged(
|
||||||
|
sarChange,
|
||||||
|
cTime //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect and Store Pivots ...
|
||||||
|
XPVPivot pivot;
|
||||||
|
bool isPivotDetected = mTriggerCycleHelper
|
||||||
|
.DetectPivot(pivot);
|
||||||
|
if (isPivotDetected) {
|
||||||
//
|
//
|
||||||
result = DetectOrderBlocks(
|
Print("Pivot Detected ...");
|
||||||
NULL,
|
|
||||||
NULL,
|
//
|
||||||
conditions.visionBullOB,
|
XCXPVPivotObject *iObj;
|
||||||
conditions.visionBearOB,
|
iObj = new XCXPVPivotObject();
|
||||||
cBar,
|
bool isCreated = iObj.Create(
|
||||||
mVisionState //
|
mPOIDrawer.ChartIdentification(),
|
||||||
|
mPOIDrawer.SubWindowIdentification(),
|
||||||
|
pivot //
|
||||||
);
|
);
|
||||||
if (!result)
|
if (isCreated)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
conditions.Clean();
|
if (pivot.IsPeak())
|
||||||
return result;
|
{
|
||||||
}
|
//
|
||||||
|
iObj.PivotWidth(1);
|
||||||
|
iObj.PivotFill(false);
|
||||||
|
iObj.PivotColor(clrAqua);
|
||||||
|
iObj.PivotStyle(STYLE_SOLID);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
XCBullishOrderBlockObject *iBullOBObj;
|
if (pivot.IsVale())
|
||||||
conditions.visionBullOB.To(cTime);
|
{
|
||||||
result = mPOIDrawer.CreateBullishOrderBlock(
|
//
|
||||||
conditions.visionBullOB,
|
iObj.PivotWidth(1);
|
||||||
iBullOBObj //
|
iObj.PivotFill(false);
|
||||||
);
|
iObj.PivotStyle(STYLE_SOLID);
|
||||||
if (result)
|
iObj.PivotColor(clrMagenta);
|
||||||
{
|
}
|
||||||
AddObjectIfNotExists(iBullOBObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
XCBearishOrderBlockObject *iBearOBObj;
|
AddObjectIfNotExists(iObj);
|
||||||
conditions.visionBearOB.To(cTime);
|
|
||||||
result = mPOIDrawer.CreateBearishOrderBlock(
|
|
||||||
conditions.visionBearOB,
|
|
||||||
iBearOBObj //
|
|
||||||
);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iBearOBObj);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Consolidation Order Blocks ...
|
|
||||||
if (conditions.consolidationBullOB == NULL ||
|
|
||||||
conditions.consolidationBearOB == NULL)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
result = DetectOrderBlocks(
|
|
||||||
conditions.visionBullOB,
|
|
||||||
conditions.visionBearOB,
|
|
||||||
conditions.consolidationBullOB,
|
|
||||||
conditions.consolidationBearOB,
|
|
||||||
cBar,
|
|
||||||
mConsolidationState //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
conditions.Clean();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
XCBullishOrderBlockObject *iBullOBObj;
|
|
||||||
conditions.consolidationBullOB.To(cTime);
|
|
||||||
result = mPOIDrawer.CreateBullishOrderBlock(
|
|
||||||
conditions.consolidationBullOB,
|
|
||||||
iBullOBObj //
|
|
||||||
);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iBullOBObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
XCBearishOrderBlockObject *iBearOBObj;
|
|
||||||
conditions.consolidationBearOB.To(cTime);
|
|
||||||
result = mPOIDrawer.CreateBearishOrderBlock(
|
|
||||||
conditions.consolidationBearOB,
|
|
||||||
iBearOBObj //
|
|
||||||
);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iBearOBObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
msg = "OrderBlocks Detected ...";
|
|
||||||
Alert(msg);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detect Trigger Order Flow ...
|
|
||||||
if (!HasValidOrderFlow())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
int samePivots = 40;
|
|
||||||
int requiredPivots = 10;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool useVisionState = false;
|
|
||||||
bool useConsolidationState = false;
|
|
||||||
bool useVerificationState = false;
|
|
||||||
bool useAnalyseState = false;
|
|
||||||
bool useDecisionState = true;
|
|
||||||
bool useTriggerState = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
DetectOrderFlow(
|
|
||||||
cIndex,
|
|
||||||
samePivots,
|
|
||||||
requiredPivots,
|
|
||||||
mTriggerCycleHelper,
|
|
||||||
mOrderFlow,
|
|
||||||
mOrderFlowDir,
|
|
||||||
//
|
|
||||||
// Filling Pivot State ...
|
|
||||||
useVisionState, // Use Vision State ...
|
|
||||||
useConsolidationState, // Use Consolidation State ...
|
|
||||||
useVerificationState, // Use Verification State ...
|
|
||||||
useAnalyseState, // Use Analyse State ...
|
|
||||||
useDecisionState, // Use Decision State ...
|
|
||||||
useTriggerState // Use Trigger State ...
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
result = HasValidOrderFlow();
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
conditions.Clean();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
bool ignoreSwingHighs = true;
|
|
||||||
bool ignoreSwingLows = true;
|
|
||||||
bool ignoreSupportZones = true;
|
|
||||||
bool ignoreResistanceZones = true;
|
|
||||||
bool ignoreSupplyZones = true;
|
|
||||||
bool ignoreDemandZones = true;
|
|
||||||
bool ignoreBullishOrderBlocks = true;
|
|
||||||
bool ignoreBearishOrderBlocks = true;
|
|
||||||
bool ignoreBullishFairValueGaps = true;
|
|
||||||
bool ignoreBearishFairValueGaps = true;
|
|
||||||
bool ignoreBullishRejectionBars = true;
|
|
||||||
bool ignoreBearishRejectionBars = true;
|
|
||||||
bool ignoreBullishMomentumBars = true;
|
|
||||||
bool ignoreBearishMomentumBars = true;
|
|
||||||
|
|
||||||
//
|
|
||||||
RedrawOrderFlow(
|
|
||||||
false, // Force Clean ...
|
|
||||||
false, // Same Period ...
|
|
||||||
true, // Order Flow ...
|
|
||||||
true, // Order Flow State ...
|
|
||||||
false, // Only Last Order Flow ...
|
|
||||||
true, // Only Last Order Flow State ...
|
|
||||||
//
|
|
||||||
mOrderFlowDir, // Direction Force ...
|
|
||||||
ignoreSwingHighs,
|
|
||||||
ignoreSwingLows,
|
|
||||||
ignoreSupportZones,
|
|
||||||
ignoreResistanceZones,
|
|
||||||
ignoreSupplyZones,
|
|
||||||
ignoreDemandZones,
|
|
||||||
ignoreBullishOrderBlocks,
|
|
||||||
ignoreBearishOrderBlocks,
|
|
||||||
ignoreBullishFairValueGaps,
|
|
||||||
ignoreBearishFairValueGaps,
|
|
||||||
ignoreBullishRejectionBars,
|
|
||||||
ignoreBearishRejectionBars,
|
|
||||||
ignoreBullishMomentumBars,
|
|
||||||
ignoreBearishMomentumBars //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
msg = "Found OrderFlow : " + (IsBullish(mOrderFlowDir) ? "Bullish" : "Berish");
|
|
||||||
Alert(msg);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check Market Conditions for
|
|
||||||
// Specified Structure ...
|
|
||||||
// ENUM_X_DIRECTION marketStructureDir = X_DIRECTION_NONE;
|
|
||||||
// result = conditions.HasDirection(
|
|
||||||
// marketStructureDir,
|
|
||||||
// cBar //
|
|
||||||
// );
|
|
||||||
// if (!result)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// conditions.Clean();
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
// msg = "Found Market Strucutre : " + (IsBullish(marketStructureDir) ? "Bullish" : "Berish");
|
|
||||||
// Alert(msg);
|
|
||||||
|
|
||||||
//
|
|
||||||
// conditions.marketStructureDir = marketStructureDir;
|
|
||||||
|
|
||||||
// //
|
|
||||||
// XPVPivot lastPivot;
|
|
||||||
// result = GetLastItem(
|
|
||||||
// lastPivot,
|
|
||||||
// mOrderFlow //
|
|
||||||
// );
|
|
||||||
// if (!result)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// conditions.Clean();
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detect Last FVG ...
|
|
||||||
// XOHCL breakerBar;
|
|
||||||
// result = DetectLastBreakerBar(
|
|
||||||
// cBar,
|
|
||||||
// breakerBar,
|
|
||||||
// lastPivot,
|
|
||||||
// marketStructureDir //
|
|
||||||
// );
|
|
||||||
// if (!result)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// conditions.Clean();
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
// msg = "Found Breaker Bar: " + breakerBar.GetTag();
|
|
||||||
// Alert(msg);
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Detect Nearest Momentum or Rejection Bar ...
|
|
||||||
// XOHCL decisionBar;
|
|
||||||
// result = mDecisionCycleHelper.DetectNearestDecisionBar(
|
|
||||||
// decisionBar,
|
|
||||||
// marketStructureDir,
|
|
||||||
// cBar //
|
|
||||||
// );
|
|
||||||
// if (!result)
|
|
||||||
// {
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
// msg = "Found Decision Bar: " + decisionBar.GetTag();
|
|
||||||
// Alert(msg);
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Detect Nearest Sar Change ...
|
|
||||||
// XOHCL sarChangeBar;
|
|
||||||
// result = mTriggerCycleHelper.DetectNearestCSARChange(
|
|
||||||
// sarChangeBar,
|
|
||||||
// cBar //
|
|
||||||
// );
|
|
||||||
// if (!result)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// conditions.Clean();
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
// msg = "Found Sar Change Bar: " + sarChangeBar.GetTag();
|
|
||||||
// Alert(msg);
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Now we Hvae to Check Other Conditions ...
|
|
||||||
// result =
|
|
||||||
// // breakerBar.time > sarChangeBar.time &&
|
|
||||||
// // decisionBar.time > breakerBar.time;
|
|
||||||
// decisionBar.time > sarChangeBar.time;
|
|
||||||
// if (!result)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// conditions.Clean();
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Now we Have Check Direction Related Conditions ...
|
|
||||||
// if (IsBullish(marketStructureDir))
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// result =
|
|
||||||
// // bid > decisionBar.high &&
|
|
||||||
// // bid > breakerBar.high &&
|
|
||||||
// bid > sarChangeBar.high &&
|
|
||||||
// bid > conditions.triggerConditions.xchsarConditions.cSars[0];
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// result =
|
|
||||||
// // bid < decisionBar.low &&
|
|
||||||
// // bid < breakerBar.low &&
|
|
||||||
// bid < sarChangeBar.high &&
|
|
||||||
// bid < conditions.triggerConditions.xchsarConditions.cSars[0];
|
|
||||||
// }
|
|
||||||
// if (!result)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// conditions.Clean();
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// conditions.provider = "X121SMC";
|
|
||||||
// if (IsBullish(marketStructureDir))
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// // conditions.sl = decisionBar.low;
|
|
||||||
// // conditions.sl = breakerBar.low;
|
|
||||||
// conditions.sl = conditions.triggerConditions.xchsarConditions.cSars[0];
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// // conditions.sl = decisionBar.high;
|
|
||||||
// // conditions.sl = breakerBar.high;
|
|
||||||
// conditions.sl = conditions.triggerConditions.xchsarConditions.cSars[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
//
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user