2793 lines
76 KiB
Plaintext
2793 lines
76 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// --------------------------------------
|
|
// Name: XCX121SMCTestStrategy
|
|
// Description: provides all based classes for use ...
|
|
//
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property library
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://www.saherelm.ir"
|
|
#property version "1.00"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
|
|
//
|
|
#include "../Classes/x-121.smc.base.strategy.class.mq5"
|
|
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// XStrategy Class Implementation(s) ...
|
|
class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
|
|
//
|
|
// Constructor(s) ...
|
|
void XCX121SMCTestStrategy(
|
|
//
|
|
// Base ...
|
|
string _symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES _period // Trading TimeFrame
|
|
)
|
|
: XCX121SMCBaseStrategy(_symbol, _period)
|
|
{
|
|
InitialHelpers();
|
|
}
|
|
|
|
//
|
|
// Deconstructur ...
|
|
void ~XCX121SMCTestStrategy()
|
|
{
|
|
}
|
|
|
|
//
|
|
// Overrides Actions ...
|
|
|
|
/**
|
|
* Destroy All Class Implementations ...
|
|
*/
|
|
void Destroy() override
|
|
{
|
|
//
|
|
delete mTriggerCycleHelper;
|
|
delete mDecisionCycleHelper;
|
|
delete mAnalyseCycleHelper;
|
|
delete mVerificationCycleHelper;
|
|
delete mConsolidationCycleHelper;
|
|
delete mVisionCycleHelper;
|
|
}
|
|
|
|
/**
|
|
* Check Conditions For Signal ...
|
|
*/
|
|
bool HasSignal(
|
|
XSignal &signal,
|
|
X121SMCStrategyConditions &conditions //
|
|
) override
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
signal.Clean();
|
|
conditions.Clean();
|
|
|
|
//
|
|
int pushers = 0;
|
|
|
|
//
|
|
double sl = 0;
|
|
double tp = 0;
|
|
double risk = 0;
|
|
double entry = 0;
|
|
double reward = 0;
|
|
double r2r = R2R();
|
|
string provider = "";
|
|
double volume = Volume();
|
|
ENUM_POSITION_TYPE type = POSITION_TYPE_BUY;
|
|
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
|
|
|
|
//
|
|
bool hasLong = false;
|
|
bool hasShort = false;
|
|
|
|
//
|
|
double selectedSL = 0;
|
|
|
|
//
|
|
// Start Calculations ...
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
double points = GetPoints(symbol);
|
|
double pip = GetPipPrice(symbol);
|
|
double pip2 = 2 * pip;
|
|
|
|
//
|
|
// Detect Conditions ...
|
|
result = DetectConditions(conditions);
|
|
if (!result)
|
|
{
|
|
conditions.Clean();
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Spread ...
|
|
bool isSpreadPassed = IsSpreadPass();
|
|
result = isSpreadPassed;
|
|
if (!result)
|
|
{
|
|
//
|
|
// string message = "Spread is not Passed for Analysing ...";
|
|
// LogAlert(message);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Combine all Signals Conditions ...
|
|
selectedSL = conditions.sl;
|
|
provider = conditions.provider;
|
|
|
|
//
|
|
hasLong =
|
|
//
|
|
IsBullish(conditions.marketStructureDir)
|
|
//
|
|
;
|
|
|
|
//
|
|
hasShort =
|
|
//
|
|
IsBearish(conditions.marketStructureDir)
|
|
//
|
|
;
|
|
|
|
//
|
|
result = hasLong ||
|
|
hasShort;
|
|
|
|
//
|
|
// Rmove Signal Condition ...
|
|
if (result)
|
|
{
|
|
//
|
|
// TYPE ...
|
|
type =
|
|
hasLong
|
|
? POSITION_TYPE_BUY
|
|
: POSITION_TYPE_SELL;
|
|
ENUM_X_POSITION_TYPES xType =
|
|
hasLong
|
|
? X_POSITION_TYPE_LONG
|
|
: X_POSITION_TYPE_SHORT;
|
|
|
|
//
|
|
entry = GetEntry(
|
|
conditions.symbol,
|
|
type //
|
|
);
|
|
|
|
//
|
|
sl =
|
|
hasLong
|
|
? selectedSL - pip2
|
|
: selectedSL + pip2;
|
|
|
|
//
|
|
// RISK Reward ...
|
|
risk =
|
|
hasLong
|
|
? entry - sl
|
|
: sl - entry;
|
|
reward = risk * r2r;
|
|
tp =
|
|
hasLong
|
|
? entry + reward
|
|
: entry - reward;
|
|
|
|
//
|
|
signal.sl = sl;
|
|
signal.tp = tp;
|
|
signal.type = type;
|
|
signal.mode = mode;
|
|
signal.entry = entry;
|
|
signal.volume = volume;
|
|
signal.symbol = symbol;
|
|
signal.period = period;
|
|
signal.pushers = pushers;
|
|
signal.provider = provider;
|
|
signal.time = TimeCurrent();
|
|
|
|
//
|
|
result = PrepareSignal(signal);
|
|
if (result)
|
|
{
|
|
//
|
|
Print("PRV: ", provider);
|
|
|
|
//
|
|
ENUM_X_DIRECTION forDir = ToDirection(signal.type);
|
|
bool ignoreSwingHighs = false;
|
|
bool ignoreSwingLows = false;
|
|
bool ignoreSupportZones = false;
|
|
bool ignoreResistanceZones = false;
|
|
bool ignoreSupplyZones = false;
|
|
bool ignoreDemandZones = false;
|
|
bool ignoreBullishOrderBlocks = false;
|
|
bool ignoreBearishOrderBlocks = false;
|
|
bool ignoreBullishFairValueGaps = false;
|
|
bool ignoreBearishFairValueGaps = false;
|
|
bool ignoreBullishRejectionBars = false;
|
|
bool ignoreBearishRejectionBars = false;
|
|
bool ignoreBullishMomentumBars = false;
|
|
bool ignoreBearishMomentumBars = false;
|
|
if (IsBullish(forDir))
|
|
{
|
|
//
|
|
ignoreSwingLows = false;
|
|
ignoreDemandZones = false;
|
|
ignoreSupportZones = false;
|
|
ignoreBullishOrderBlocks = false;
|
|
ignoreBullishFairValueGaps = false;
|
|
ignoreBullishRejectionBars = false;
|
|
ignoreBullishMomentumBars = false;
|
|
}
|
|
else
|
|
{
|
|
//
|
|
ignoreSwingHighs = true;
|
|
ignoreSupplyZones = true;
|
|
ignoreResistanceZones = true;
|
|
ignoreBearishOrderBlocks = true;
|
|
ignoreBearishFairValueGaps = false;
|
|
ignoreBearishRejectionBars = true;
|
|
ignoreBearishMomentumBars = true;
|
|
}
|
|
|
|
//
|
|
RedrawOrderFlow(
|
|
true, // Force Clean ...
|
|
false, // Same Period ...
|
|
true, // Order Flow ...
|
|
true, // Order Flow State ...
|
|
false, // Only Last Order Flow ...
|
|
true, // Only Last Order Flow State ...
|
|
//
|
|
forDir, // Direction Force ...
|
|
ignoreSwingHighs,
|
|
ignoreSwingLows,
|
|
ignoreSupportZones,
|
|
ignoreResistanceZones,
|
|
ignoreSupplyZones,
|
|
ignoreDemandZones,
|
|
ignoreBullishOrderBlocks,
|
|
ignoreBearishOrderBlocks,
|
|
ignoreBullishFairValueGaps,
|
|
ignoreBearishFairValueGaps,
|
|
ignoreBullishRejectionBars,
|
|
ignoreBearishRejectionBars,
|
|
ignoreBullishMomentumBars,
|
|
ignoreBearishMomentumBars //
|
|
);
|
|
DrawSignal(signal);
|
|
ClearDraws();
|
|
|
|
//
|
|
ResetOrderFlow();
|
|
}
|
|
|
|
//
|
|
hasLong = false;
|
|
hasShort = false;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Customize Strategy Identifier ...
|
|
*/
|
|
string GetTag() override
|
|
{
|
|
return X121SMCStrategyToken;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Trigger Order Flow ...
|
|
XPVPivot mOrderFlow[];
|
|
ENUM_X_DIRECTION mOrderFlowDir;
|
|
|
|
//
|
|
XC121SMCCycleHelper *mTriggerCycleHelper;
|
|
XC121SMCCycleHelper *mDecisionCycleHelper;
|
|
XC121SMCCycleHelper *mAnalyseCycleHelper;
|
|
XC121SMCCycleHelper *mVerificationCycleHelper;
|
|
XC121SMCCycleHelper *mConsolidationCycleHelper;
|
|
XC121SMCCycleHelper *mVisionCycleHelper;
|
|
|
|
//
|
|
// Actions ...
|
|
|
|
/**
|
|
* Detect and Parse Market Conditions ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DetectConditions(
|
|
X121SMCStrategyConditions &conditions //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
int ppIndex = pIndex + 1;
|
|
|
|
//
|
|
XOHCL zBar;
|
|
result = zBar.Init(
|
|
symbol,
|
|
period,
|
|
zIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL cBar;
|
|
result = cBar.Init(
|
|
symbol,
|
|
period,
|
|
cIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string msg = NULL;
|
|
|
|
//
|
|
double bid = GetBid(symbol);
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
conditions.time = cTime;
|
|
conditions.symbol = symbol;
|
|
conditions.period = period;
|
|
|
|
//
|
|
int conditionsLoopback = 7;
|
|
|
|
//
|
|
// Fill Cycles Conditions ...
|
|
|
|
//
|
|
// Trigger ...
|
|
mTriggerCycleHelper.GetConditions(
|
|
conditions.triggerConditions,
|
|
zIndex,
|
|
conditionsLoopback //
|
|
);
|
|
conditions.triggerConditions.state = mTriggerState;
|
|
|
|
//
|
|
// Decision ...
|
|
mDecisionCycleHelper.GetConditions(
|
|
conditions.decisionConditions,
|
|
zIndex,
|
|
conditionsLoopback //
|
|
);
|
|
conditions.decisionConditions.state = mDecisionState;
|
|
|
|
//
|
|
// Analyse ...
|
|
mAnalyseCycleHelper.GetConditions(
|
|
conditions.analyseConditions,
|
|
zIndex,
|
|
conditionsLoopback //
|
|
);
|
|
conditions.analyseConditions.state = mAnalyseState;
|
|
|
|
//
|
|
// Verification ...
|
|
mVerificationCycleHelper.GetConditions(
|
|
conditions.verificationConditions,
|
|
zIndex,
|
|
conditionsLoopback //
|
|
);
|
|
conditions.verificationConditions.state = mVerificationState;
|
|
|
|
//
|
|
// Consolidation ...
|
|
mConsolidationCycleHelper.GetConditions(
|
|
conditions.consolidationConditions,
|
|
zIndex,
|
|
conditionsLoopback //
|
|
);
|
|
conditions.consolidationConditions.state = mConsolidationState;
|
|
|
|
//
|
|
// Vision ...
|
|
mVisionCycleHelper.GetConditions(
|
|
conditions.visionConditions,
|
|
zIndex,
|
|
conditionsLoopback //
|
|
);
|
|
conditions.visionConditions.state = mVisionState;
|
|
|
|
//
|
|
// Detect and Store Parabolic Sar Changes ...
|
|
XSarChange sarChange;
|
|
bool isSarChanged = mTriggerCycleHelper
|
|
.IsSarChanged(
|
|
sarChange,
|
|
cTime //
|
|
);
|
|
|
|
//
|
|
// Detect and Store Pivots ...
|
|
XPVPivot pivot;
|
|
bool isPivotDetected = mTriggerCycleHelper
|
|
.DetectPivot(pivot);
|
|
if (isPivotDetected) {
|
|
//
|
|
Print("Pivot Detected ...");
|
|
|
|
//
|
|
ClearDraws();
|
|
XCXPVPivotObject *iObj;
|
|
iObj = new XCXPVPivotObject();
|
|
bool isCreated = iObj.Create(
|
|
mPOIDrawer.ChartIdentification(),
|
|
mPOIDrawer.SubWindowIdentification(),
|
|
pivot //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
//
|
|
if (pivot.IsPeak())
|
|
{
|
|
//
|
|
iObj.PivotWidth(1);
|
|
iObj.PivotFill(false);
|
|
iObj.PivotColor(clrAqua);
|
|
iObj.PivotStyle(STYLE_SOLID);
|
|
}
|
|
|
|
//
|
|
if (pivot.IsVale())
|
|
{
|
|
//
|
|
iObj.PivotWidth(1);
|
|
iObj.PivotFill(false);
|
|
iObj.PivotStyle(STYLE_SOLID);
|
|
iObj.PivotColor(clrMagenta);
|
|
}
|
|
|
|
//
|
|
AddObjectIfNotExists(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (!result)
|
|
{
|
|
//
|
|
conditions.Clean();
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Detect XPV Based POI(s) ...
|
|
*
|
|
* @param barIndex: Start Bar Index ...
|
|
* @param minRepetition: minimum Repeate of POI for Validation ...
|
|
* @param requiredPivots: Number of Min Requirement POI(s) ...
|
|
* @param pivotHelper: XC121SMCCycleHelper instance Pointer ...
|
|
* @param orderFlow: XPVPivot instance Array Reference ...
|
|
* @param orderFlowDirection: ENUM_X_DIRECTION member Reference which represents OrderFlow Direction ...
|
|
* @param maxAllowedLoopbackBars: Integer, Max Allowed Loopback Bars ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DetectOrderFlow(
|
|
int barIndex,
|
|
int minRepetition,
|
|
int requiredPivots,
|
|
XC121SMCCycleHelper *pivotHelper, // XPV Helper ...
|
|
XPVPivot &orderFlow[], // OrderFlows ...
|
|
ENUM_X_DIRECTION &orderFlowDirection, // Order Flow Direction ...
|
|
//
|
|
bool useVisionState = true, // Use Vision State ...
|
|
bool useConsolidationState = true, // Use Consolidation State ...
|
|
bool useVerificationState = true, // Use Verification State ...
|
|
bool useAnalyseState = true, // Use Analyse State ...
|
|
bool useDecisionState = true, // Use Decision State ...
|
|
bool useTriggerState = true, // Use Trigger State ...
|
|
//
|
|
int maxAllowedLoopbackBars = 576 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
orderFlowDirection = X_DIRECTION_NONE;
|
|
|
|
//
|
|
if (maxAllowedLoopbackBars <= 0)
|
|
{
|
|
maxAllowedLoopbackBars = 1000;
|
|
}
|
|
|
|
//
|
|
int start = barIndex;
|
|
int end = start + maxAllowedLoopbackBars;
|
|
|
|
//
|
|
Clean(orderFlow);
|
|
|
|
//
|
|
result = minRepetition > 0 &&
|
|
requiredPivots > 0 &&
|
|
pivotHelper != NULL;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
double peak = 0;
|
|
XPVPivot peaks[];
|
|
int peakRepeate = 0;
|
|
int peakToBarIndex = 0;
|
|
int peakFromBarIndex = 0;
|
|
|
|
//
|
|
double vale = 0;
|
|
XPVPivot vales[];
|
|
int valeRepeate = 0;
|
|
int valeToBarIndex = 0;
|
|
int valeFromBarIndex = 0;
|
|
|
|
//
|
|
bool canLookupPeak = true;
|
|
bool canLookupVale = true;
|
|
bool canLookup = true;
|
|
while (canLookup)
|
|
{
|
|
//
|
|
// Check Peak ...
|
|
double iPeak = pivotHelper.mXPVHelper.GetPeak(barIndex);
|
|
if (iPeak != peak)
|
|
{
|
|
//
|
|
if (peak != 0 &&
|
|
peakRepeate >= minRepetition)
|
|
{
|
|
//
|
|
bool isExists = false;
|
|
int count = ArraySize(peaks);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XPVPivot iPivot = peaks[i];
|
|
|
|
//
|
|
if (iPivot.upper == iPeak)
|
|
{
|
|
//
|
|
isExists = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (!isExists)
|
|
{
|
|
//
|
|
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)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
peaks //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
peak = iPeak;
|
|
peakRepeate = 0;
|
|
peakFromBarIndex = 0;
|
|
peakToBarIndex = barIndex;
|
|
}
|
|
else if (iPeak == peak)
|
|
{
|
|
//
|
|
peakRepeate++;
|
|
peakFromBarIndex = barIndex;
|
|
}
|
|
|
|
//
|
|
// Check Vale ...
|
|
double iVale = pivotHelper.mXPVHelper.GetVale(barIndex);
|
|
if (iVale != vale)
|
|
{
|
|
//
|
|
if (vale != 0 &&
|
|
valeRepeate >= minRepetition)
|
|
{
|
|
//
|
|
bool isExists = false;
|
|
int count = ArraySize(vales);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XPVPivot iPivot = vales[i];
|
|
|
|
//
|
|
if (iPivot.lower == iVale)
|
|
{
|
|
//
|
|
isExists = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (!isExists)
|
|
{
|
|
//
|
|
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)
|
|
{
|
|
//
|
|
AddRef(
|
|
iPivot,
|
|
vales //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
vale = iVale;
|
|
valeRepeate = 0;
|
|
valeFromBarIndex = 0;
|
|
valeToBarIndex = barIndex;
|
|
}
|
|
else if (iVale == vale)
|
|
{
|
|
//
|
|
valeRepeate++;
|
|
valeFromBarIndex = barIndex;
|
|
}
|
|
|
|
//
|
|
canLookupPeak = ArraySize(peaks) < requiredPivots;
|
|
canLookupVale = ArraySize(vales) < requiredPivots;
|
|
canLookup = barIndex < end &&
|
|
(canLookupPeak ||
|
|
canLookupVale);
|
|
if (canLookup)
|
|
{
|
|
barIndex++;
|
|
}
|
|
}
|
|
|
|
//
|
|
result = IsValidSize(ArraySize(peaks)) ||
|
|
IsValidSize(ArraySize(vales));
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Detect Order Flow ...
|
|
Copy(
|
|
peaks,
|
|
orderFlow,
|
|
false //
|
|
);
|
|
Copy(
|
|
vales,
|
|
orderFlow,
|
|
false //
|
|
);
|
|
int count = ArraySize(orderFlow);
|
|
result = IsValidSize(orderFlow);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Sort Pivots ...
|
|
SortPivots(orderFlow);
|
|
|
|
//
|
|
// Filter Broken Order Flows ...
|
|
FilterBrokenPivots(orderFlow);
|
|
|
|
//
|
|
// Detect Order Flow Direction ...
|
|
result = DetectPivotDirection(
|
|
orderFlow,
|
|
orderFlowDirection //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Find State Inside Pivots and Attached Them to Pivot ...
|
|
int orderFlowCount = ArraySize(mOrderFlow);
|
|
if (IsValidSize(orderFlowCount))
|
|
{
|
|
//
|
|
// Loop Through Order Flow ...
|
|
for (int i = 0; i < orderFlowCount; i++)
|
|
{
|
|
//
|
|
FillPivotSate(
|
|
i,
|
|
useVisionState, // Use Vision State ...
|
|
useConsolidationState, // Use Consolidation State ...
|
|
useVerificationState, // Use Verification State ...
|
|
useAnalyseState, // Use Analyse State ...
|
|
useDecisionState, // Use Decision State ...
|
|
useTriggerState // Use Trigger State ...
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Filling Specified Orer Flow Index ...
|
|
*
|
|
* @param pivotIDX: Integer ...
|
|
* @param lookupSwingHighs: Boolean ...
|
|
* @param lookupSwingLows: Boolean ...
|
|
* @param lookupSupportZones: Boolean ...
|
|
* @param lookupResistanceZones: Boolean ...
|
|
* @param lookupSupplyZones: Boolean ...
|
|
* @param lookupDemandZones: Boolean ...
|
|
* @param lookupBullishOrderBlocks: Boolean ...
|
|
* @param lookupBearishOrderBlocks: Boolean ...
|
|
* @param lookupBullishFairValueGaps: Boolean ...
|
|
* @param lookupBearishFairValueGaps: Boolean ...
|
|
* @param lookupBullishRejectionBars: Boolean ...
|
|
* @param lookupBearishRejectionBars: Boolean ...
|
|
* @param lookupBullishMomentumBars: Boolean ...
|
|
* @param lookupBearishMomentumBars: Boolean ...
|
|
*/
|
|
void FillPivotSate(
|
|
int pivotIDX, //
|
|
bool useVisionState = true, // Use Vision State ...
|
|
bool useConsolidationState = true, // Use Consolidation State ...
|
|
bool useVerificationState = true, // Use Verification State ...
|
|
bool useAnalyseState = true, // Use Analyse State ...
|
|
bool useDecisionState = true, // Use Decision State ...
|
|
bool useTriggerState = true, // Use Trigger State ...
|
|
bool lookupSwingHighs = true,
|
|
bool lookupSwingLows = true,
|
|
bool lookupSupportZones = true,
|
|
bool lookupResistanceZones = true,
|
|
bool lookupSupplyZones = true,
|
|
bool lookupDemandZones = true,
|
|
bool lookupBullishOrderBlocks = true,
|
|
bool lookupBearishOrderBlocks = true,
|
|
bool lookupBullishFairValueGaps = true,
|
|
bool lookupBearishFairValueGaps = true,
|
|
bool lookupBullishRejectionBars = true,
|
|
bool lookupBearishRejectionBars = true,
|
|
bool lookupBullishMomentumBars = true,
|
|
bool lookupBearishMomentumBars = true //
|
|
)
|
|
{
|
|
//
|
|
CalculatePivotTickZone(pivotIDX);
|
|
|
|
//
|
|
// Trigger ...
|
|
XPOIState mPivotTriggerState;
|
|
if (useTriggerState &&
|
|
mTriggerState.HasChild())
|
|
{
|
|
//
|
|
DetectPivotPOIs(
|
|
mOrderFlow[pivotIDX],
|
|
mTriggerState,
|
|
mPivotTriggerState,
|
|
lookupSwingHighs,
|
|
lookupSwingLows,
|
|
lookupSupportZones,
|
|
lookupResistanceZones,
|
|
lookupSupplyZones,
|
|
lookupDemandZones,
|
|
lookupBullishOrderBlocks,
|
|
lookupBearishOrderBlocks,
|
|
lookupBullishFairValueGaps,
|
|
lookupBearishFairValueGaps,
|
|
lookupBullishRejectionBars,
|
|
lookupBearishRejectionBars,
|
|
lookupBullishMomentumBars,
|
|
lookupBearishMomentumBars //
|
|
);
|
|
|
|
//
|
|
if (mPivotTriggerState.HasChild())
|
|
{
|
|
mPivotTriggerState.Fill(mOrderFlow[pivotIDX].state);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Decision ...
|
|
XPOIState mPivotDecisionState;
|
|
if (useDecisionState &&
|
|
mDecisionState.HasChild())
|
|
{
|
|
//
|
|
DetectPivotPOIs(
|
|
mOrderFlow[pivotIDX],
|
|
mDecisionState,
|
|
mPivotDecisionState,
|
|
lookupSwingHighs,
|
|
lookupSwingLows,
|
|
lookupSupportZones,
|
|
lookupResistanceZones,
|
|
lookupSupplyZones,
|
|
lookupDemandZones,
|
|
lookupBullishOrderBlocks,
|
|
lookupBearishOrderBlocks,
|
|
lookupBullishFairValueGaps,
|
|
lookupBearishFairValueGaps,
|
|
lookupBullishRejectionBars,
|
|
lookupBearishRejectionBars,
|
|
lookupBullishMomentumBars,
|
|
lookupBearishMomentumBars //
|
|
);
|
|
|
|
//
|
|
if (mPivotDecisionState.HasChild())
|
|
{
|
|
mPivotDecisionState.Fill(mOrderFlow[pivotIDX].state);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Analyse ...
|
|
XPOIState mPivotAnalyseState;
|
|
if (useAnalyseState &&
|
|
mAnalyseState.HasChild())
|
|
{
|
|
//
|
|
DetectPivotPOIs(
|
|
mOrderFlow[pivotIDX],
|
|
mAnalyseState,
|
|
mPivotAnalyseState,
|
|
lookupSwingHighs,
|
|
lookupSwingLows,
|
|
lookupSupportZones,
|
|
lookupResistanceZones,
|
|
lookupSupplyZones,
|
|
lookupDemandZones,
|
|
lookupBullishOrderBlocks,
|
|
lookupBearishOrderBlocks,
|
|
lookupBullishFairValueGaps,
|
|
lookupBearishFairValueGaps,
|
|
lookupBullishRejectionBars,
|
|
lookupBearishRejectionBars,
|
|
lookupBullishMomentumBars,
|
|
lookupBearishMomentumBars //
|
|
);
|
|
|
|
//
|
|
if (mPivotAnalyseState.HasChild())
|
|
{
|
|
mPivotAnalyseState.Fill(mOrderFlow[pivotIDX].state);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Verification ...
|
|
XPOIState mPivotVerificationState;
|
|
if (useVerificationState &&
|
|
mVerificationState.HasChild())
|
|
{
|
|
//
|
|
DetectPivotPOIs(
|
|
mOrderFlow[pivotIDX],
|
|
mVerificationState,
|
|
mPivotVerificationState,
|
|
lookupSwingHighs,
|
|
lookupSwingLows,
|
|
lookupSupportZones,
|
|
lookupResistanceZones,
|
|
lookupSupplyZones,
|
|
lookupDemandZones,
|
|
lookupBullishOrderBlocks,
|
|
lookupBearishOrderBlocks,
|
|
lookupBullishFairValueGaps,
|
|
lookupBearishFairValueGaps,
|
|
lookupBullishRejectionBars,
|
|
lookupBearishRejectionBars,
|
|
lookupBullishMomentumBars,
|
|
lookupBearishMomentumBars //
|
|
);
|
|
|
|
//
|
|
if (mPivotVerificationState.HasChild())
|
|
{
|
|
mPivotVerificationState.Fill(mOrderFlow[pivotIDX].state);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Consolidation ...
|
|
XPOIState mPivotConsolidationState;
|
|
if (useConsolidationState &&
|
|
mConsolidationState.HasChild())
|
|
{
|
|
//
|
|
DetectPivotPOIs(
|
|
mOrderFlow[pivotIDX],
|
|
mConsolidationState,
|
|
mPivotConsolidationState,
|
|
lookupSwingHighs,
|
|
lookupSwingLows,
|
|
lookupSupportZones,
|
|
lookupResistanceZones,
|
|
lookupSupplyZones,
|
|
lookupDemandZones,
|
|
lookupBullishOrderBlocks,
|
|
lookupBearishOrderBlocks,
|
|
lookupBullishFairValueGaps,
|
|
lookupBearishFairValueGaps,
|
|
lookupBullishRejectionBars,
|
|
lookupBearishRejectionBars,
|
|
lookupBullishMomentumBars,
|
|
lookupBearishMomentumBars //
|
|
);
|
|
|
|
//
|
|
if (mPivotConsolidationState.HasChild())
|
|
{
|
|
mPivotConsolidationState.Fill(mOrderFlow[pivotIDX].state);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Vision ...
|
|
XPOIState mPivotVisionState;
|
|
if (useVisionState &&
|
|
mVisionState.HasChild())
|
|
{
|
|
//
|
|
DetectPivotPOIs(
|
|
mOrderFlow[pivotIDX],
|
|
mVisionState,
|
|
mPivotVisionState,
|
|
lookupSwingHighs,
|
|
lookupSwingLows,
|
|
lookupSupportZones,
|
|
lookupResistanceZones,
|
|
lookupSupplyZones,
|
|
lookupDemandZones,
|
|
lookupBullishOrderBlocks,
|
|
lookupBearishOrderBlocks,
|
|
lookupBullishFairValueGaps,
|
|
lookupBearishFairValueGaps,
|
|
lookupBullishRejectionBars,
|
|
lookupBearishRejectionBars,
|
|
lookupBullishMomentumBars,
|
|
lookupBearishMomentumBars //
|
|
);
|
|
|
|
//
|
|
if (mPivotVisionState.HasChild())
|
|
{
|
|
mPivotVisionState.Fill(mOrderFlow[pivotIDX].state);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* When a BOS Happens ...
|
|
* we have to Update Order Flow ...
|
|
*/
|
|
void UpdateOrderFlow()
|
|
{
|
|
ResetOrderFlow();
|
|
}
|
|
|
|
/**
|
|
* Fill Pivot Tick Zone ...
|
|
*
|
|
* @param pivotIDX: Integer ...
|
|
*/
|
|
void CalculatePivotTickZone(int pivotIDX)
|
|
{
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
bool isInited = false;
|
|
|
|
//
|
|
datetime from = mOrderFlow[pivotIDX].from;
|
|
XOHCL iFromBar;
|
|
int iFromBarIndex = iBarShift(
|
|
symbol,
|
|
period,
|
|
from //
|
|
);
|
|
isInited = iFromBar.Init(
|
|
symbol,
|
|
period,
|
|
iFromBarIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
datetime to = mOrderFlow[pivotIDX].to;
|
|
XOHCL iToBar;
|
|
int iToBarIndex = iBarShift(
|
|
symbol,
|
|
period,
|
|
to //
|
|
);
|
|
isInited = iToBar.Init(
|
|
symbol,
|
|
period,
|
|
iToBarIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XCTicksZone *iZone;
|
|
iZone = new XCTicksZone();
|
|
|
|
//
|
|
int ticksLevels = mTriggerDetector.TicksRangeZoneLevel();
|
|
int ticksRange = mTriggerDetector.TicksRangeZoneRange();
|
|
isInited = ticksLevels > 0 &&
|
|
ticksRange > 0;
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
isInited = iZone.Init(
|
|
iFromBar,
|
|
iToBar //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
mOrderFlow[pivotIDX].state.ticksZone = iZone;
|
|
}
|
|
|
|
/**
|
|
* Validate Order Flow ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool HasValidOrderFlow()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
int orderFlowCount = ArraySize(mOrderFlow);
|
|
result =
|
|
IsValidSize(orderFlowCount) &&
|
|
mOrderFlowDir != X_DIRECTION_ALL &&
|
|
mOrderFlowDir != X_DIRECTION_NONE;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Reset Order Flow ...
|
|
*/
|
|
void ResetOrderFlow()
|
|
{
|
|
//
|
|
Clean(mOrderFlow);
|
|
mOrderFlowDir = X_DIRECTION_NONE;
|
|
|
|
//
|
|
ClearDraws();
|
|
}
|
|
|
|
/**
|
|
* Detect Breaker Bar ...
|
|
*
|
|
* @param bar: XOHCL instance ...
|
|
* @param breakerBar: XOHCL instance, Breaker Bar ...
|
|
* @param pivot: XPVPivot instance ...
|
|
* @param forDir: ENUM_X_DIRECTION member, Market Structure Direction ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DetectLastBreakerBar(
|
|
XOHCL &bar,
|
|
XOHCL &breakerBar,
|
|
XPVPivot &pivot,
|
|
ENUM_X_DIRECTION forDir //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
bar.IsValid() &&
|
|
pivot.IsValid() &&
|
|
forDir != X_DIRECTION_ALL &&
|
|
forDir != X_DIRECTION_NONE;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// FVG ...
|
|
result = DetectLastFVGBreakerBar(
|
|
bar,
|
|
breakerBar,
|
|
pivot,
|
|
forDir //
|
|
);
|
|
if (result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Order Block ...
|
|
// result = DetectLastOBBreakerBar(
|
|
// bar,
|
|
// breakerBar,
|
|
// pivot,
|
|
// forDir //
|
|
// );
|
|
// if (result)
|
|
// {
|
|
// return result;
|
|
// }
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
bool DetectLastFVGBreakerBar(
|
|
XOHCL &bar,
|
|
XOHCL &breakerBar,
|
|
XPVPivot &pivot,
|
|
ENUM_X_DIRECTION forDir //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
bar.IsValid() &&
|
|
pivot.IsValid() &&
|
|
forDir != X_DIRECTION_ALL &&
|
|
forDir != X_DIRECTION_NONE;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool isBullishDir = IsBullish(forDir);
|
|
|
|
//
|
|
int fvgsCount =
|
|
isBullishDir
|
|
? pivot.state.CountBullishFairValueGaps()
|
|
: pivot.state.CountBearishFairValueGaps();
|
|
result = IsValidSize(fvgsCount);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int idx = -1;
|
|
XCFVG *zone = NULL;
|
|
for (int i = 0; i < fvgsCount; i++)
|
|
{
|
|
//
|
|
if (isBullishDir)
|
|
{
|
|
//
|
|
// Bullish FVG ...
|
|
if (zone == NULL)
|
|
{
|
|
//
|
|
zone = pivot.state.bullishFairValueGaps[i];
|
|
|
|
//
|
|
bool isBreaked = CheckZoneBreak(
|
|
forDir,
|
|
bar,
|
|
breakerBar,
|
|
zone //
|
|
);
|
|
if (isBreaked)
|
|
{
|
|
idx = i;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
bool isNewer = ((int)zone.From() - (int)bar.time) > ((int)pivot.state.bullishFairValueGaps[i].From() - (int)bar.time);
|
|
if (isNewer)
|
|
{
|
|
//
|
|
zone = pivot.state.bullishFairValueGaps[i];
|
|
|
|
//
|
|
bool isBreaked = CheckZoneBreak(
|
|
forDir,
|
|
bar,
|
|
breakerBar,
|
|
zone //
|
|
);
|
|
if (isBreaked)
|
|
{
|
|
idx = i;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
// Bearish FVG ...
|
|
if (zone == NULL)
|
|
{
|
|
//
|
|
zone = pivot.state.bearishFairValueGaps[i];
|
|
|
|
//
|
|
bool isBreaked = CheckZoneBreak(
|
|
forDir,
|
|
bar,
|
|
breakerBar,
|
|
zone //
|
|
);
|
|
if (isBreaked)
|
|
{
|
|
idx = i;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
bool isNewer = ((int)zone.From() - (int)bar.time) > ((int)pivot.state.bearishFairValueGaps[i].From() - (int)bar.time);
|
|
if (isNewer)
|
|
{
|
|
//
|
|
zone = pivot.state.bearishFairValueGaps[i];
|
|
|
|
//
|
|
bool isBreaked = CheckZoneBreak(
|
|
forDir,
|
|
bar,
|
|
breakerBar,
|
|
zone //
|
|
);
|
|
if (isBreaked)
|
|
{
|
|
idx = i;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
result =
|
|
breakerBar.IsValid() &&
|
|
IsValidIndex(idx) &&
|
|
zone.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Check an FVG is Breaked or not ...
|
|
*
|
|
* @param forDir: ENUM_X_DIRECTION member, Market Structure Direction ...
|
|
* @param bar: XOHCL instance ...
|
|
* @param breakerBar: XOHCL instance, Breaker Bar ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool CheckZoneBreak(
|
|
ENUM_X_DIRECTION forDir,
|
|
XOHCL &bar,
|
|
XOHCL &breakerBar,
|
|
XCFVG *&zone //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
breakerBar.Clean();
|
|
|
|
//
|
|
result = bar.IsValid() &&
|
|
zone.IsValid() &&
|
|
forDir != X_DIRECTION_ALL &&
|
|
forDir != X_DIRECTION_NONE;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int start = bar.Index();
|
|
int end = iBarShift(
|
|
bar.symbol,
|
|
bar.period,
|
|
zone.From());
|
|
for (int i = start; i < end; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
result = iBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
i //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
if (IsBullish(forDir))
|
|
{
|
|
//
|
|
// Bullish Break ...
|
|
result = iBar.low < zone.Upper() &&
|
|
iBar.high > zone.Upper() &&
|
|
iBar.GetDown() < zone.Upper() &&
|
|
iBar.GetUp() > zone.Upper() &&
|
|
iBar.IsBullish();
|
|
}
|
|
else
|
|
{
|
|
//
|
|
// Bearish Break ...
|
|
result = iBar.low < zone.Lower() &&
|
|
iBar.high > zone.Lower() &&
|
|
iBar.GetDown() < zone.Lower() &&
|
|
iBar.GetUp() > zone.Lower() &&
|
|
iBar.IsBearish();
|
|
}
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
//
|
|
breakerBar = iBar;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
result = breakerBar.IsValid();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Detect most Upper and Lower Order Blocks ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DetectOrderBlocks(
|
|
XCOrderBlock *bullOBBoundary,
|
|
XCOrderBlock *bearOBBoundary,
|
|
XCOrderBlock *&bullOB,
|
|
XCOrderBlock *&bearOB,
|
|
XOHCL &bar,
|
|
XPOIState &state //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = bar.IsValid() &&
|
|
state.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XCOrderBlock *mBullOB = NULL;
|
|
if (bullOB == NULL)
|
|
{
|
|
//
|
|
for (int i = 0; i < state.CountBullishOrderBlocks(); i++)
|
|
{
|
|
//
|
|
XCOrderBlock *ob = state.bullishOrderBlocks[i];
|
|
bool isPricePassed = bar.low > ob.Upper();
|
|
if (isPricePassed)
|
|
{
|
|
//
|
|
bool isBoundaryPassed =
|
|
bullOBBoundary == NULL
|
|
? true
|
|
: ob.Lower() < bullOBBoundary.Upper();
|
|
if (isBoundaryPassed)
|
|
{
|
|
//
|
|
if (mBullOB == NULL)
|
|
{
|
|
mBullOB = ob;
|
|
}
|
|
else
|
|
{
|
|
//
|
|
bool isRefined =
|
|
mBullOB.Upper() < ob.Upper();
|
|
if (isRefined)
|
|
{
|
|
mBullOB = ob;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (mBullOB != NULL)
|
|
{
|
|
bullOB = mBullOB;
|
|
}
|
|
}
|
|
|
|
//
|
|
XCOrderBlock *mBearOB = NULL;
|
|
if (bearOB == NULL)
|
|
{
|
|
//
|
|
for (int i = 0; i < state.CountBearishOrderBlocks(); i++)
|
|
{
|
|
//
|
|
XCOrderBlock *ob = state.bearishOrderBlocks[i];
|
|
bool isPricePassed = bar.high < ob.Lower();
|
|
if (isPricePassed)
|
|
{
|
|
//
|
|
bool isBoundaryPassed =
|
|
bearOBBoundary == NULL
|
|
? true
|
|
: ob.Upper() > bearOBBoundary.Lower();
|
|
if (isBoundaryPassed)
|
|
{
|
|
//
|
|
if (mBearOB == NULL)
|
|
{
|
|
mBearOB = ob;
|
|
}
|
|
else
|
|
{
|
|
//
|
|
bool isRefined =
|
|
mBearOB.Lower() > ob.Lower();
|
|
if (isRefined)
|
|
{
|
|
mBearOB = ob;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (mBearOB != NULL)
|
|
{
|
|
bearOB = mBearOB;
|
|
}
|
|
}
|
|
|
|
//
|
|
result = bullOB != NULL &&
|
|
bearOB != NULL;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Drawings ...
|
|
|
|
/**
|
|
* Draw Order Flow ...
|
|
*/
|
|
void RedrawOrderFlow(
|
|
bool forceClearDraws = true,
|
|
bool forceDrawSamePeriod = true,
|
|
bool drawOrderFlow = true,
|
|
bool drawOrderFlowState = true,
|
|
bool drawOnlyLastOrderFlow = false,
|
|
bool drawOnlyLastOrderFlowState = true,
|
|
//
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
//
|
|
// Ignores List ...
|
|
bool ignoreSwingHighs = false,
|
|
bool ignoreSwingLows = false,
|
|
bool ignoreSupportZones = false,
|
|
bool ignoreResistanceZones = false,
|
|
bool ignoreSupplyZones = false,
|
|
bool ignoreDemandZones = false,
|
|
bool ignoreBullishOrderBlocks = false,
|
|
bool ignoreBearishOrderBlocks = false,
|
|
bool ignoreBullishFairValueGaps = false,
|
|
bool ignoreBearishFairValueGaps = false,
|
|
bool ignoreBullishRejectionBars = false,
|
|
bool ignoreBearishRejectionBars = false,
|
|
bool ignoreBullishMomentumBars = false,
|
|
bool ignoreBearishMomentumBars = false,
|
|
//
|
|
// States Drawing ...
|
|
bool drawVisionState = false,
|
|
bool drawConsolidationState = false,
|
|
bool drawVerificationState = false,
|
|
bool drawAnalyseState = false,
|
|
bool drawDecisionState = false,
|
|
bool drawTriggerState = false //
|
|
)
|
|
{
|
|
//
|
|
if (forceClearDraws)
|
|
{
|
|
ClearDraws();
|
|
}
|
|
|
|
//
|
|
if (!drawOrderFlow ||
|
|
!HasValidOrderFlow())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int orderFlowCount = ArraySize(mOrderFlow);
|
|
for (int i = 0; i < orderFlowCount; i++)
|
|
{
|
|
//
|
|
bool isLast = i == orderFlowCount - 1;
|
|
bool canDraw =
|
|
!drawOnlyLastOrderFlow ||
|
|
(isLast &&
|
|
drawOnlyLastOrderFlow);
|
|
if (!canDraw)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
XPVPivot iPivot = mOrderFlow[i];
|
|
|
|
//
|
|
XCXPVPivotObject *iObj;
|
|
iObj = new XCXPVPivotObject();
|
|
bool isCreated = iObj.Create(
|
|
mPOIDrawer.ChartIdentification(),
|
|
mPOIDrawer.SubWindowIdentification(),
|
|
iPivot //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
//
|
|
bool canDrawState =
|
|
drawOrderFlowState &&
|
|
(!drawOnlyLastOrderFlowState ||
|
|
(isLast &&
|
|
drawOnlyLastOrderFlowState));
|
|
if (canDrawState)
|
|
{
|
|
//
|
|
CustomStateDrawing(
|
|
iPivot.state,
|
|
forceDrawSamePeriod,
|
|
forDir,
|
|
ignoreSwingHighs,
|
|
ignoreSwingLows,
|
|
ignoreSupportZones,
|
|
ignoreResistanceZones,
|
|
ignoreSupplyZones,
|
|
ignoreDemandZones,
|
|
ignoreBullishOrderBlocks,
|
|
ignoreBearishOrderBlocks,
|
|
ignoreBullishFairValueGaps,
|
|
ignoreBearishFairValueGaps,
|
|
ignoreBullishRejectionBars,
|
|
ignoreBearishRejectionBars,
|
|
ignoreBullishMomentumBars,
|
|
ignoreBearishMomentumBars //
|
|
);
|
|
}
|
|
|
|
//
|
|
if (iPivot.IsPeak())
|
|
{
|
|
//
|
|
iObj.PivotWidth(1);
|
|
iObj.PivotFill(false);
|
|
iObj.PivotColor(clrAqua);
|
|
iObj.PivotStyle(STYLE_SOLID);
|
|
}
|
|
|
|
//
|
|
if (iPivot.IsVale())
|
|
{
|
|
//
|
|
iObj.PivotWidth(1);
|
|
iObj.PivotFill(false);
|
|
iObj.PivotStyle(STYLE_SOLID);
|
|
iObj.PivotColor(clrMagenta);
|
|
}
|
|
|
|
//
|
|
AddObjectIfNotExists(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Draw States ...
|
|
|
|
//
|
|
// Vision ...
|
|
if (drawVisionState)
|
|
{
|
|
//
|
|
CustomStateDrawing(
|
|
mVisionState,
|
|
false,
|
|
forDir,
|
|
ignoreSwingHighs,
|
|
ignoreSwingLows,
|
|
ignoreSupportZones,
|
|
ignoreResistanceZones,
|
|
ignoreSupplyZones,
|
|
ignoreDemandZones,
|
|
ignoreBullishOrderBlocks,
|
|
ignoreBearishOrderBlocks,
|
|
ignoreBullishFairValueGaps,
|
|
ignoreBearishFairValueGaps,
|
|
ignoreBullishRejectionBars,
|
|
ignoreBearishRejectionBars,
|
|
ignoreBullishMomentumBars,
|
|
ignoreBearishMomentumBars //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Consolidation ...
|
|
if (drawConsolidationState)
|
|
{
|
|
//
|
|
CustomStateDrawing(
|
|
mConsolidationState,
|
|
false,
|
|
forDir,
|
|
ignoreSwingHighs,
|
|
ignoreSwingLows,
|
|
ignoreSupportZones,
|
|
ignoreResistanceZones,
|
|
ignoreSupplyZones,
|
|
ignoreDemandZones,
|
|
ignoreBullishOrderBlocks,
|
|
ignoreBearishOrderBlocks,
|
|
ignoreBullishFairValueGaps,
|
|
ignoreBearishFairValueGaps,
|
|
ignoreBullishRejectionBars,
|
|
ignoreBearishRejectionBars,
|
|
ignoreBullishMomentumBars,
|
|
ignoreBearishMomentumBars //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Verification ...
|
|
if (drawVerificationState)
|
|
{
|
|
//
|
|
CustomStateDrawing(
|
|
mVerificationState,
|
|
false,
|
|
forDir,
|
|
ignoreSwingHighs,
|
|
ignoreSwingLows,
|
|
ignoreSupportZones,
|
|
ignoreResistanceZones,
|
|
ignoreSupplyZones,
|
|
ignoreDemandZones,
|
|
ignoreBullishOrderBlocks,
|
|
ignoreBearishOrderBlocks,
|
|
ignoreBullishFairValueGaps,
|
|
ignoreBearishFairValueGaps,
|
|
ignoreBullishRejectionBars,
|
|
ignoreBearishRejectionBars,
|
|
ignoreBullishMomentumBars,
|
|
ignoreBearishMomentumBars //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Analyse ...
|
|
if (drawAnalyseState)
|
|
{
|
|
//
|
|
CustomStateDrawing(
|
|
mAnalyseState,
|
|
false,
|
|
forDir,
|
|
ignoreSwingHighs,
|
|
ignoreSwingLows,
|
|
ignoreSupportZones,
|
|
ignoreResistanceZones,
|
|
ignoreSupplyZones,
|
|
ignoreDemandZones,
|
|
ignoreBullishOrderBlocks,
|
|
ignoreBearishOrderBlocks,
|
|
ignoreBullishFairValueGaps,
|
|
ignoreBearishFairValueGaps,
|
|
ignoreBullishRejectionBars,
|
|
ignoreBearishRejectionBars,
|
|
ignoreBullishMomentumBars,
|
|
ignoreBearishMomentumBars //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Decision ...
|
|
if (drawDecisionState)
|
|
{
|
|
//
|
|
CustomStateDrawing(
|
|
mDecisionState,
|
|
false,
|
|
forDir,
|
|
ignoreSwingHighs,
|
|
ignoreSwingLows,
|
|
ignoreSupportZones,
|
|
ignoreResistanceZones,
|
|
ignoreSupplyZones,
|
|
ignoreDemandZones,
|
|
ignoreBullishOrderBlocks,
|
|
ignoreBearishOrderBlocks,
|
|
ignoreBullishFairValueGaps,
|
|
ignoreBearishFairValueGaps,
|
|
ignoreBullishRejectionBars,
|
|
ignoreBearishRejectionBars,
|
|
ignoreBullishMomentumBars,
|
|
ignoreBearishMomentumBars //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Trigger ...
|
|
if (drawTriggerState)
|
|
{
|
|
//
|
|
CustomStateDrawing(
|
|
mTriggerState,
|
|
false,
|
|
forDir,
|
|
ignoreSwingHighs,
|
|
ignoreSwingLows,
|
|
ignoreSupportZones,
|
|
ignoreResistanceZones,
|
|
ignoreSupplyZones,
|
|
ignoreDemandZones,
|
|
ignoreBullishOrderBlocks,
|
|
ignoreBearishOrderBlocks,
|
|
ignoreBullishFairValueGaps,
|
|
ignoreBearishFairValueGaps,
|
|
ignoreBullishRejectionBars,
|
|
ignoreBearishRejectionBars,
|
|
ignoreBullishMomentumBars,
|
|
ignoreBearishMomentumBars //
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Custom Drawing State ...
|
|
*
|
|
* @param state: XPOIState instance reference, Specified Which state to Draw ...
|
|
* @param forceDrawSamePeriod: Boolean ...
|
|
*/
|
|
void CustomStateDrawing(
|
|
XPOIState &state,
|
|
bool forceDrawSamePeriod = false,
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
//
|
|
// Ignores List ...
|
|
bool ignoreSwingHighs = false,
|
|
bool ignoreSwingLows = false,
|
|
bool ignoreSupportZones = false,
|
|
bool ignoreResistanceZones = false,
|
|
bool ignoreSupplyZones = false,
|
|
bool ignoreDemandZones = false,
|
|
bool ignoreBullishOrderBlocks = false,
|
|
bool ignoreBearishOrderBlocks = false,
|
|
bool ignoreBullishFairValueGaps = false,
|
|
bool ignoreBearishFairValueGaps = false,
|
|
bool ignoreBullishRejectionBars = false,
|
|
bool ignoreBearishRejectionBars = false,
|
|
bool ignoreBullishMomentumBars = false,
|
|
bool ignoreBearishMomentumBars = false //
|
|
)
|
|
{
|
|
//
|
|
XPOIState tmpState = state;
|
|
if (forceDrawSamePeriod)
|
|
{
|
|
//
|
|
int count = 0;
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
count = state.CountSwingHighs();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCSwing iSwing = state.swingHighs[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iSwing.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.swingHighs,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountSwingLows();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCSwing iSwing = state.swingLows[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iSwing.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.swingLows,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountBullishMomentumBars();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCMomentumBar iMomentum = state.bullishMomentumBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iMomentum.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.bullishMomentumBars,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountBearishMomentumBars();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCMomentumBar iMomentum = state.bearishMomentumBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iMomentum.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.bearishMomentumBars,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountBullishRejectionBars();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCRejectionBar iRejection = state.bullishRejectionBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iRejection.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.bullishRejectionBars,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountBearishRejectionBars();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCRejectionBar iRejection = state.bearishRejectionBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iRejection.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.bearishRejectionBars,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountSupportZones();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCSupportZone iZone = state.supportZones[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.supportZones,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountResistanceZones();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCResistanceZone iZone = state.resistanceZones[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.resistanceZones,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountSupplyZones();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCSupplyZone iZone = state.supplyZones[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.supplyZones,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountDemandZones();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCDemandZone iZone = state.demandZones[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.demandZones,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountBullishOrderBlocks();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCOrderBlock iZone = state.bullishOrderBlocks[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.bullishOrderBlocks,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountBearishOrderBlocks();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCOrderBlock iZone = state.bearishOrderBlocks[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.bearishOrderBlocks,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountBullishFairValueGaps();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCFVG iZone = state.bullishFairValueGaps[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillStartBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.bullishFairValueGaps,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
count = state.CountBearishFairValueGaps();
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCFVG iZone = state.bearishFairValueGaps[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillStartBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
bool isSamePeriod = iBar.period == period;
|
|
if (!isSamePeriod)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
tmpState.bearishFairValueGaps,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
bool drawSwingHighs = true;
|
|
bool drawSwingLows = true;
|
|
bool drawSupportZones = true;
|
|
bool drawResistanceZones = true;
|
|
bool drawSupplyZones = true;
|
|
bool drawDemandZones = true;
|
|
bool drawBullishOrderBlocks = true;
|
|
bool drawBearishOrderBlocks = true;
|
|
bool drawBullishFairValueGaps = true;
|
|
bool drawBearishFairValueGaps = true;
|
|
bool drawBullishRejectionBars = true;
|
|
bool drawBearishRejectionBars = true;
|
|
bool drawBullishMomentumBars = true;
|
|
bool drawBearishMomentumBars = true;
|
|
|
|
//
|
|
// Change Drawing Specs Conditions based on
|
|
// Provided Direction ...
|
|
if (forDir == X_DIRECTION_BULLISH)
|
|
{
|
|
//
|
|
drawSwingLows = true;
|
|
drawDemandZones = true;
|
|
drawSupportZones = true;
|
|
drawBullishOrderBlocks = true;
|
|
drawBullishFairValueGaps = true;
|
|
drawBullishRejectionBars = true;
|
|
drawBullishMomentumBars = true;
|
|
|
|
//
|
|
drawSwingHighs = false;
|
|
drawSupplyZones = false;
|
|
drawResistanceZones = false;
|
|
drawBearishOrderBlocks = false;
|
|
drawBearishFairValueGaps = false;
|
|
drawBearishRejectionBars = false;
|
|
drawBearishMomentumBars = false;
|
|
}
|
|
else if (forDir == X_DIRECTION_BEARISH)
|
|
{
|
|
//
|
|
drawSwingLows = false;
|
|
drawDemandZones = false;
|
|
drawSupportZones = false;
|
|
drawBullishOrderBlocks = false;
|
|
drawBullishFairValueGaps = false;
|
|
drawBullishRejectionBars = false;
|
|
drawBullishMomentumBars = false;
|
|
|
|
//
|
|
drawSwingHighs = true;
|
|
drawSupplyZones = true;
|
|
drawResistanceZones = true;
|
|
drawBearishOrderBlocks = true;
|
|
drawBearishFairValueGaps = true;
|
|
drawBearishRejectionBars = true;
|
|
drawBearishMomentumBars = true;
|
|
}
|
|
|
|
//
|
|
// Apply Ignore List ...
|
|
|
|
//
|
|
if (ignoreSwingHighs)
|
|
{
|
|
drawSwingHighs = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreSwingLows)
|
|
{
|
|
drawSwingLows = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreSupportZones)
|
|
{
|
|
drawSupportZones = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreResistanceZones)
|
|
{
|
|
drawResistanceZones = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreSupplyZones)
|
|
{
|
|
drawSupplyZones = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreDemandZones)
|
|
{
|
|
drawDemandZones = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreBullishOrderBlocks)
|
|
{
|
|
drawBullishOrderBlocks = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreBearishOrderBlocks)
|
|
{
|
|
drawBearishOrderBlocks = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreBullishFairValueGaps)
|
|
{
|
|
drawBullishFairValueGaps = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreBearishFairValueGaps)
|
|
{
|
|
drawBearishFairValueGaps = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreBullishRejectionBars)
|
|
{
|
|
drawBullishRejectionBars = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreBearishRejectionBars)
|
|
{
|
|
drawBearishRejectionBars = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreBullishMomentumBars)
|
|
{
|
|
drawBullishMomentumBars = false;
|
|
}
|
|
|
|
//
|
|
if (ignoreBearishMomentumBars)
|
|
{
|
|
drawBearishMomentumBars = false;
|
|
}
|
|
|
|
//
|
|
DrawState(
|
|
tmpState, // State ...
|
|
true, // Update To of all Drawings Till now ...
|
|
drawSwingHighs, // Draw SwingHighs ..
|
|
drawSwingLows, // Draw SwingLows ..
|
|
drawSupportZones, // Draw SupportZones ..
|
|
drawResistanceZones, // Draw ResistanceZones ..
|
|
drawSupplyZones, // Draw SupplyZones ..
|
|
drawDemandZones, // Draw DemandZones ..
|
|
drawBullishOrderBlocks, // Draw BullishOrderBlocks ..
|
|
drawBearishOrderBlocks, // Draw BearishOrderBlocks ..
|
|
drawBullishFairValueGaps, // Draw BullishFairValueGaps ..
|
|
drawBearishFairValueGaps, // Draw BearishFairValueGaps ..
|
|
drawBullishRejectionBars, // Draw BullishRejectionBars ..
|
|
drawBearishRejectionBars, // Draw BearishRejectionBars ..
|
|
drawBullishMomentumBars, // Draw BullishMomentumBars ..
|
|
drawBearishMomentumBars, // Draw BearishMomentumBars ..
|
|
true // Draw Ticks Zone ...
|
|
);
|
|
}
|
|
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
|
|
/**
|
|
* Initial Required Indicators Helper ...
|
|
*/
|
|
void InitialHelpers()
|
|
{
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
// Short ...
|
|
ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period
|
|
ENUM_TIMEFRAMES scPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Medium ...
|
|
ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period
|
|
ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Long ...
|
|
ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period
|
|
ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// Hind ...
|
|
ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period
|
|
ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
|
|
|
|
//
|
|
// XPV ...
|
|
XPVInputs xpvInputs;
|
|
|
|
//
|
|
xpvInputs.Default();
|
|
|
|
//
|
|
xpvInputs.scMethod = scMethod;
|
|
xpvInputs.scPeriod = scPeriod;
|
|
xpvInputs.mcMethod = mcMethod;
|
|
xpvInputs.mcPeriod = mcPeriod;
|
|
xpvInputs.lcMethod = lcMethod;
|
|
xpvInputs.lcPeriod = lcPeriod;
|
|
xpvInputs.hcMethod = hcMethod;
|
|
xpvInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
xpvInputs.showPeaksAndVales = true;
|
|
xpvInputs.showLevels = false;
|
|
xpvInputs.showConsolidations = false;
|
|
xpvInputs.showFibo1Levels = false;
|
|
xpvInputs.showFibo2Levels = false;
|
|
xpvInputs.showFibo3Levels = false;
|
|
xpvInputs.showFibo4Levels = false;
|
|
xpvInputs.showFibo5Levels = false;
|
|
|
|
//
|
|
// X3MA ...
|
|
X3MAInputs x3maInputs;
|
|
|
|
//
|
|
x3maInputs.Default();
|
|
|
|
//
|
|
// x3maInputs.fastLength = 10;
|
|
// x3maInputs.midLength = 25;
|
|
// x3maInputs.slowLength = 50;
|
|
|
|
//
|
|
x3maInputs.showFast = true;
|
|
x3maInputs.showMid = false;
|
|
x3maInputs.showSlow = false;
|
|
|
|
//
|
|
// X3VWAP ...
|
|
X3VWAPInputs x3vwapInputs;
|
|
|
|
//
|
|
x3vwapInputs.Default();
|
|
|
|
//
|
|
// x3vwapInputs.fastLength = 10;
|
|
// x3vwapInputs.midLength = 25;
|
|
// x3vwapInputs.slowLength = 50;
|
|
|
|
//
|
|
x3vwapInputs.showFast = true;
|
|
x3vwapInputs.showMid = true;
|
|
x3vwapInputs.showSlow = true;
|
|
|
|
//
|
|
// XCHSAR ...
|
|
XCHSARInputs xchsarInputs;
|
|
|
|
//
|
|
xchsarInputs.Default();
|
|
|
|
//
|
|
xchsarInputs.scMethod = scMethod;
|
|
xchsarInputs.scPeriod = scPeriod;
|
|
xchsarInputs.mcMethod = mcMethod;
|
|
xchsarInputs.mcPeriod = mcPeriod;
|
|
xchsarInputs.lcMethod = lcMethod;
|
|
xchsarInputs.lcPeriod = lcPeriod;
|
|
xchsarInputs.hcMethod = hcMethod;
|
|
xchsarInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
xchsarInputs.showCurrent = true;
|
|
xchsarInputs.showShort = false;
|
|
xchsarInputs.showMedium = false;
|
|
xchsarInputs.showLong = false;
|
|
xchsarInputs.showHind = false;
|
|
|
|
//
|
|
// Initialize Cycle Helpers ...
|
|
|
|
//
|
|
mTriggerCycleHelper = new XC121SMCCycleHelper();
|
|
mTriggerCycleHelper.Init(
|
|
symbol,
|
|
PERIOD_M1,
|
|
xpvInputs,
|
|
x3maInputs,
|
|
x3vwapInputs,
|
|
xchsarInputs //
|
|
);
|
|
|
|
//
|
|
mDecisionCycleHelper = new XC121SMCCycleHelper();
|
|
mDecisionCycleHelper.Init(
|
|
symbol,
|
|
PERIOD_M5,
|
|
xpvInputs,
|
|
x3maInputs,
|
|
x3vwapInputs,
|
|
xchsarInputs //
|
|
);
|
|
|
|
//
|
|
mAnalyseCycleHelper = new XC121SMCCycleHelper();
|
|
mAnalyseCycleHelper.Init(
|
|
symbol,
|
|
PERIOD_M15,
|
|
xpvInputs,
|
|
x3maInputs,
|
|
x3vwapInputs,
|
|
xchsarInputs //
|
|
);
|
|
|
|
//
|
|
mVerificationCycleHelper = new XC121SMCCycleHelper();
|
|
mVerificationCycleHelper.Init(
|
|
symbol,
|
|
PERIOD_M30,
|
|
xpvInputs,
|
|
x3maInputs,
|
|
x3vwapInputs,
|
|
xchsarInputs //
|
|
);
|
|
|
|
//
|
|
mConsolidationCycleHelper = new XC121SMCCycleHelper();
|
|
mConsolidationCycleHelper.Init(
|
|
symbol,
|
|
PERIOD_H1,
|
|
xpvInputs,
|
|
x3maInputs,
|
|
x3vwapInputs,
|
|
xchsarInputs //
|
|
);
|
|
|
|
//
|
|
mVisionCycleHelper = new XC121SMCCycleHelper();
|
|
mVisionCycleHelper.Init(
|
|
symbol,
|
|
PERIOD_H4,
|
|
xpvInputs,
|
|
x3maInputs,
|
|
x3vwapInputs,
|
|
xchsarInputs //
|
|
);
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
// |