Files
MQL5Data/Documents/BKP/x-121.smc.test.strategy.FULL.class.mq5
T
2024-11-28 07:16:23 +03:30

2830 lines
73 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 "../../Helpers/x-saherelm.x3ma.helper.mq5"
#include "../../Helpers/x-saherelm.x3vwap.helper.mq5"
#include "../../Helpers/x-saherelm.xchsar.helper.mq5"
#include "../../Helpers/x-saherelm.xpv.helper.mq5"
#include "../Classes/x-121.smc.base.strategy.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 xpvHelper;
delete x3maHelper;
delete xchsarHelper;
delete x3vwapHelper;
}
/**
* 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;
//
datetime cTime = TimeCurrent();
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
// Retrieve Bars ...
//
// Zero Bar ...
XOHCL zBar;
result = zBar.Init(
_symbol,
_period,
zIndex //
);
if (!result)
{
return result;
}
//
// Last Bar ...
XOHCL cBar;
result = cBar.Init(
_symbol,
_period,
cIndex //
);
if (!result)
{
return result;
}
//
// Previous Bar ...
XOHCL pBar;
result = pBar.Init(
_symbol,
_period,
pIndex //
);
if (!result)
{
return result;
}
//
// Prepare Areas ...
double bid = GetBid(_symbol);
//
// Check Momentum Bar ...
ENUM_X_DIRECTION momentumCBarDir;
bool isCMomentumBar = mBarAnalyser.IsMomentumBar(
cBar,
momentumCBarDir //
);
bool isCBullishMomentumBar =
isCMomentumBar &&
IsBullish(momentumCBarDir);
bool isCBearishMomentumBar =
isCMomentumBar &&
IsBearish(momentumCBarDir);
//
// Check Momentum Bar ...
ENUM_X_DIRECTION momentumPBarDir;
bool isPMomentumBar = mBarAnalyser.IsMomentumBar(
pBar,
momentumPBarDir //
);
bool isPBullishMomentumBar =
isPMomentumBar &&
IsBullish(momentumPBarDir);
bool isPBearishMomentumBar =
isPMomentumBar &&
IsBearish(momentumPBarDir);
//
// Check Rejection Bar ...
ENUM_X_DIRECTION rejectionCBarDir;
bool isCRejectionBar = mBarAnalyser.IsRejectionBar(
cBar,
rejectionCBarDir //
);
bool isCBullishRejectionBar =
isCRejectionBar &&
IsBullish(rejectionCBarDir);
bool isCBearishRejectionBar =
isCRejectionBar &&
IsBearish(rejectionCBarDir);
//
// Check Rejection Bar ...
ENUM_X_DIRECTION rejectionPBarDir;
bool isPRejectionBar = mBarAnalyser.IsRejectionBar(
pBar,
rejectionPBarDir //
);
bool isPBullishRejectionBar =
isPRejectionBar &&
IsBullish(rejectionPBarDir);
bool isPBearishRejectionBar =
isPRejectionBar &&
IsBearish(rejectionPBarDir);
//
// Check Engulfing ...
ENUM_X_DIRECTION engulfCBarDir;
bool isCEngulfed = mBarAnalyser.IsEngulfBar(
cBar,
engulfCBarDir //
);
bool isCBullishEngulfed =
isCEngulfed &&
IsBullish(engulfCBarDir);
bool isCBearishEngulfed =
isCEngulfed &&
IsBearish(engulfCBarDir);
//
// Check Engulfing ...
ENUM_X_DIRECTION engulfPBarDir;
bool isPEngulfed = mBarAnalyser.IsEngulfBar(
pBar,
engulfPBarDir //
);
bool isPBullishEngulfed =
isPEngulfed &&
IsBullish(engulfPBarDir);
bool isPBearishEngulfed =
isPEngulfed &&
IsBearish(engulfPBarDir);
//
bool isCRMEBullish =
//
isCBullishEngulfed
//
||
//
isCBullishMomentumBar
//
||
//
isCBullishRejectionBar
//
;
//
bool isPRMEBullish =
//
isPBullishEngulfed
//
||
//
isPBullishMomentumBar
//
||
//
isPBullishRejectionBar
//
;
//
bool isCRMEBearish =
//
isCBearishEngulfed
//
||
//
isCBearishMomentumBar
//
||
//
isCBearishRejectionBar
//
;
//
bool isPRMEBearish =
//
isPBearishEngulfed
//
||
//
isPBearishMomentumBar
//
||
//
isPBearishRejectionBar
//
;
//
bool isSpreadPassed = IsSpreadPass();
result = isSpreadPassed;
if (!result)
{
return result;
}
//
// Try to Implement SMC Based Conditions ...
result = DetectConditions(conditions);
if (!result)
{
return result;
}
//
// Validate Order Flow ...
bool isValidOrderFlow = HasValidOrderFlow();
result = isValidOrderFlow;
if (!result)
{
return result;
}
//
XPVPivot lastPivot;
result = GetLastItem(
lastPivot,
mOrderFlow //
);
if (!result)
{
return result;
}
//
// Detect Fair Value Gaps ...
XCBasePOI *mPOIs[];
bool hasPOI = FindPOIInPivot(
mPOIs,
X_POI_SWING_HIGH,
lastPivot,
mVisionPOIState //
);
// TODO:
//
bool isOrderFlowBullish = IsBullish(mOrderFlowDir);
//
// Check Parabolic Sar is in Order of Order Flow ...
bool isPSarInDirectionOfOrderFlow =
isOrderFlowBullish
? conditions.xchsarConditions.cSars[0] < cBar.low &&
conditions.xchsarConditions.cSars[1] >= pBar.low
: conditions.xchsarConditions.cSars[0] > cBar.high &&
conditions.xchsarConditions.cSars[1] <= pBar.high;
//
// Check BOS or CHOCH Happens ...
bool hasBOS =
isOrderFlowBullish
?
//
// Price Close Over Pivot's High ...
cBar.IsBullish() &&
cBar.close > lastPivot.upper &&
(pBar.close < lastPivot.upper ||
pBar.low < lastPivot.upper)
//
:
//
// Price Must Close Under Pivots Low ...
cBar.IsBearish() &&
cBar.close < lastPivot.lower &&
(pBar.close > lastPivot.lower ||
pBar.high > lastPivot.lower)
//
;
//
if (hasBOS)
{
mLastBOSOn = TimeCurrent();
}
bool hasCHOCH =
isOrderFlowBullish
?
//
// Price Close Under Pivot's Low ...
cBar.IsBearish() &&
cBar.close < lastPivot.lower &&
(pBar.close > lastPivot.lower ||
pBar.high > lastPivot.lower)
//
:
//
// Price Must Close Over Pivots High ...
cBar.IsBullish() &&
cBar.close > lastPivot.upper &&
(pBar.close < lastPivot.upper ||
pBar.low < lastPivot.upper)
//
;
//
// Check PSar is Equals to Peak or Vale ...
bool isSAREqualsToPeak =
conditions.xchsarConditions.cSars[0] == conditions.xpvConditions.peaks[1];
bool isSAREqualsToVale =
conditions.xchsarConditions.cSars[0] == conditions.xpvConditions.vales[1];
//
bool hasNewPeak =
conditions.xpvConditions.peaks[0] != conditions.xpvConditions.peaks[1];
bool hasNewPeakOverLast =
hasNewPeak &&
conditions.xpvConditions.peaks[0] > conditions.xpvConditions.peaks[1];
bool hasNewPeakUnderLast =
hasNewPeak &&
conditions.xpvConditions.peaks[0] < conditions.xpvConditions.peaks[1];
//
bool hasNewVale =
conditions.xpvConditions.vales[0] != conditions.xpvConditions.vales[1];
bool hasNewValeOverLast =
hasNewVale &&
conditions.xpvConditions.vales[0] > conditions.xpvConditions.vales[1];
bool hasNewValeUnderLast =
hasNewVale &&
conditions.xpvConditions.vales[0] < conditions.xpvConditions.vales[1];
//
// START Signalling ...
//
//
// BOS Signals ...
bool has_BOS_Long = false;
bool has_BOS_Short = false;
//
// CHOCH Signals ...
bool has_CHOCH_Long = false;
bool has_CHOCH_Short = false;
//
// SAR Signals ...
bool has_SAR_Long = false;
bool has_SAR_Short = false;
//
// PULLBACK Signals ...
bool has_PULLBK_Long = false;
bool has_PULLBK_Short = false;
//
// PV Signals ...
bool has_PV_Long = false;
bool has_PV_Short = false;
//
// BOS Signals ...
//
has_BOS_Long =
//
hasBOS &&
isOrderFlowBullish &&
isCRMEBullish &&
cBar.IsBullish() &&
conditions.xchsarConditions.cSars[0] < cBar.low
//
;
//
if (has_BOS_Long)
{
//
selectedSL = cBar.low;
provider = ToString(X_121_SMC_PROVIDER_BOS);
}
//
has_BOS_Short =
//
hasBOS &&
!isOrderFlowBullish &&
isCRMEBearish &&
cBar.IsBearish() &&
conditions.xchsarConditions.cSars[0] > cBar.high
//
;
if (has_BOS_Short)
{
//
selectedSL = cBar.high;
provider = ToString(X_121_SMC_PROVIDER_BOS);
}
//
// CHOCH Signals ...
//
has_CHOCH_Long =
//
hasCHOCH &&
isCRMEBullish &&
cBar.IsBullish() &&
!isOrderFlowBullish &&
conditions.xchsarConditions.cSars[0] < cBar.low
//
;
if (has_CHOCH_Long)
{
//
selectedSL = cBar.low;
provider = ToString(X_121_SMC_PROVIDER_CHOCH);
}
//
has_CHOCH_Short =
//
hasCHOCH &&
isCRMEBearish &&
cBar.IsBearish() &&
isOrderFlowBullish &&
conditions.xchsarConditions.cSars[0] > cBar.high
//
;
if (has_CHOCH_Short)
{
//
selectedSL = cBar.high;
provider = ToString(X_121_SMC_PROVIDER_CHOCH);
}
//
// SAR Signals ...
//
has_SAR_Long =
//
isSAREqualsToVale &&
isOrderFlowBullish &&
isPSarInDirectionOfOrderFlow
//
;
if (has_SAR_Long)
{
//
provider = ToString(X_121_SMC_PROVIDER_SAR);
selectedSL = conditions.xchsarConditions.cSars[0];
}
//
has_SAR_Short =
//
isSAREqualsToPeak &&
!isOrderFlowBullish &&
isPSarInDirectionOfOrderFlow
//
;
if (has_SAR_Short)
{
//
provider = ToString(X_121_SMC_PROVIDER_SAR);
selectedSL = conditions.xchsarConditions.cSars[0];
}
//
// PULLBK Signals ...
//
has_PULLBK_Long =
//
isCRMEBullish &&
isPSarInDirectionOfOrderFlow &&
(cBar.low < conditions.x3maConditions.fasts[0] &&
cBar.GetDown() > conditions.x3maConditions.fasts[0])
//
;
if (has_PULLBK_Long)
{
//
selectedSL = cBar.low;
provider = ToString(X_121_SMC_PROVIDER_PULLBK);
}
//
has_PULLBK_Short =
//
isCRMEBearish &&
isPSarInDirectionOfOrderFlow &&
(cBar.high > conditions.x3maConditions.fasts[0] &&
cBar.GetUp() < conditions.x3maConditions.fasts[0])
//
;
if (has_PULLBK_Short)
{
//
selectedSL = cBar.high;
provider = ToString(X_121_SMC_PROVIDER_PULLBK);
}
//
// PV Signals ...
//
has_PV_Long =
//
isCRMEBullish &&
isOrderFlowBullish &&
!hasNewValeUnderLast &&
cBar.low == conditions.xpvConditions.vales[0]
//
;
if (has_PV_Long)
{
//
selectedSL = cBar.low;
provider = ToString(X_121_SMC_PROVIDER_PV);
}
//
has_PV_Short =
//
isCRMEBearish &&
!isOrderFlowBullish &&
!hasNewPeakOverLast &&
cBar.high == conditions.xpvConditions.peaks[0]
//
;
if (has_PV_Short)
{
//
selectedSL = cBar.high;
provider = ToString(X_121_SMC_PROVIDER_PV);
}
//
// END Signalling ...
//
//
// Combine all Signals Conditions ...
//
hasLong =
//
has_BOS_Long
//
||
//
has_CHOCH_Long
//
||
//
has_SAR_Long
//
||
//
has_PULLBK_Long
//
||
//
has_PV_Long
//
;
//
hasShort =
//
has_BOS_Short
//
||
//
has_CHOCH_Short
//
||
//
has_SAR_Short
//
||
//
has_PULLBK_Short
//
||
//
has_PV_Short
//
;
//
result = hasLong ||
hasShort;
//
// Reset Order Flow ...
if (hasCHOCH && !result)
{
ResetOrderFlow();
}
else if (hasBOS && !result)
{
UpdateOrderFlow();
}
//
// 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,
//
false, // Vision State ...
false, // Analyse State ...
false // Trigger State ...
);
DrawSignal(signal);
ClearDraws();
//
ResetOrderFlow();
}
//
hasLong = false;
hasShort = false;
}
//
return result;
}
/**
* Customize Strategy Identifier ...
*/
string GetTag() override
{
return X121SMCStrategyToken;
}
//
// Protected ...
protected:
//
//
// Props ...
//
// XPV ...
XPVInputs xpvInputs;
XCXPVHelper *xpvHelper;
//
// X3MA ...
X3MAInputs x3maInputs;
XCX3MAHelper *x3maHelper;
//
// X3VWAP ...
X3VWAPInputs x3vwapInputs;
XCX3VWAPHelper *x3vwapHelper;
//
// XCHSAR ...
XCHSARInputs xchsarInputs;
XCXCHSARHelper *xchsarHelper;
//
XPVPivot mOrderFlow[];
ENUM_X_DIRECTION mOrderFlowDir;
//
// Holds Last CHOCH and BOS time ...
datetime mLastBOSOn;
datetime mLastCHOCHOn;
//
// 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;
//
conditions.symbol = symbol;
conditions.period = period;
conditions.time = TimeCurrent();
//
int conditionsLoopback = 7;
//
// XPV ...
result = xpvHelper.GetConditions(
conditions.xpvConditions,
cIndex,
conditionsLoopback //
);
if (!result)
{
return result;
}
//
// X3MA ...
result = x3maHelper.GetConditions(
conditions.x3maConditions,
cIndex,
conditionsLoopback //
);
if (!result)
{
return result;
}
//
// X3VWAP ...
result = x3vwapHelper.GetConditions(
conditions.x3vwapConditions,
cIndex,
conditionsLoopback //
);
if (!result)
{
return result;
}
//
// XCHSAR ...
result = xchsarHelper.GetConditions(
conditions.xchsarConditions,
cIndex,
conditionsLoopback //
);
if (!result)
{
return result;
}
//
// Only Detect Order Flow when there isn't ...
if (ArraySize(mOrderFlow) == 0 ||
mOrderFlowDir == X_DIRECTION_NONE)
{
//
int samePivots = 40;
int requiredPivots = 10;
//
DetectOrderFlow(
cIndex,
samePivots,
requiredPivots,
mOrderFlow,
mOrderFlowDir //
);
//
result = IsValidSize(ArraySize(mOrderFlow));
if (!result)
{
return result;
}
}
//
if (result)
{
//
int lastPivotIDX = ArraySize(mOrderFlow) - 1;
if (IsValidSize(lastPivotIDX))
{
//
FillPivotSate(
lastPivotIDX,
true, // Use Vision State ...
true, // Use Analyse State ...
false // Use Trigger State ...
);
}
}
//
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 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,
XPVPivot &orderFlow[], // OrderFlows ...
ENUM_X_DIRECTION &orderFlowDirection, // Order Flow Direction ...
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;
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 = xpvHelper.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 = xpvHelper.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,
true, // Use Vision State ...
true, // Use Analyse State ...
false // 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 useAnalyseState = true, // Use Analyse 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 mTriggerState;
if (useTriggerState &&
mTriggerPOIState.HasChild())
{
//
DetectPivotPOIs(
mOrderFlow[pivotIDX],
mTriggerPOIState,
mTriggerState,
lookupSwingHighs,
lookupSwingLows,
lookupSupportZones,
lookupResistanceZones,
lookupSupplyZones,
lookupDemandZones,
lookupBullishOrderBlocks,
lookupBearishOrderBlocks,
lookupBullishFairValueGaps,
lookupBearishFairValueGaps,
lookupBullishRejectionBars,
lookupBearishRejectionBars,
lookupBullishMomentumBars,
lookupBearishMomentumBars //
);
//
if (mTriggerState.HasChild())
{
mTriggerState.Fill(mOrderFlow[pivotIDX].state);
}
}
//
// Analyse ...
XPOIState mAnalyseState;
if (useAnalyseState &&
mAnalysePOIState.HasChild())
{
//
DetectPivotPOIs(
mOrderFlow[pivotIDX],
mAnalysePOIState,
mAnalyseState,
lookupSwingHighs,
lookupSwingLows,
lookupSupportZones,
lookupResistanceZones,
lookupSupplyZones,
lookupDemandZones,
lookupBullishOrderBlocks,
lookupBearishOrderBlocks,
lookupBullishFairValueGaps,
lookupBearishFairValueGaps,
lookupBullishRejectionBars,
lookupBearishRejectionBars,
lookupBullishMomentumBars,
lookupBearishMomentumBars //
);
//
if (mAnalyseState.HasChild())
{
mAnalyseState.Fill(mOrderFlow[pivotIDX].state);
}
}
//
// Vision ...
XPOIState mVisionState;
if (useVisionState &&
mVisionPOIState.HasChild())
{
//
DetectPivotPOIs(
mOrderFlow[pivotIDX],
mVisionPOIState,
mVisionState,
lookupSwingHighs,
lookupSwingLows,
lookupSupportZones,
lookupResistanceZones,
lookupSupplyZones,
lookupDemandZones,
lookupBullishOrderBlocks,
lookupBearishOrderBlocks,
lookupBullishFairValueGaps,
lookupBearishFairValueGaps,
lookupBullishRejectionBars,
lookupBearishRejectionBars,
lookupBullishMomentumBars,
lookupBearishMomentumBars //
);
//
if (mVisionState.HasChild())
{
mVisionState.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 = mTriggerPOIDetector.TicksRangeZoneLevel();
int ticksRange = mTriggerPOIDetector.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();
}
bool FindPOIInPivot(
XCBasePOI *&pois[],
ENUM_XPOIS type,
XPVPivot &pivot,
XPOIState &state,
ENUM_X_DIRECTION dir = X_DIRECTION_NONE //
)
{
//
bool result = false;
//
Clean(pois);
//
// Validate Inputs ...
result =
//
type != X_POI_NONE &&
pivot.IsValid() &&
state.IsValid() &&
state.HasChild()
//
;
if (!result)
{
return result;
}
//
int swingHighsCunt = state.CountSwingHighs();
int swingLowsCunt = state.CountSwingLows();
int bullishMomentumBarsCunt = state.CountBullishMomentumBars();
int bearishMomentumBarsCunt = state.CountBearishMomentumBars();
int bullishRejectionBarsCunt = state.CountBullishRejectionBars();
int bearishRejectionBarsCunt = state.CountBearishRejectionBars();
int supportZonesCunt = state.CountSupportZones();
int resistanceZonesCunt = state.CountResistanceZones();
int supplyZonesCunt = state.CountSupplyZones();
int demandZonesCunt = state.CountDemandZones();
int bullishOrderBlocksCunt = state.CountBullishOrderBlocks();
int bearishOrderBlocksCunt = state.CountBearishOrderBlocks();
int bullishFairValueGapsCunt = state.CountBullishFairValueGaps();
int bearishFairValueGapsCunt = state.CountBearishFairValueGaps();
//
switch (type)
{
//
case X_POI_MOMENTUM_BAR: {
//
// Validate Direction ...
result = HasDirection(dir);
if (!result)
{
return result;
}
//
bool isBullishDir = IsBullish(dir);
//
// Validate State POI(s) ...
result =
isBullishDir
? IsValidSize(bullishMomentumBarsCunt)
: IsValidSize(bearishMomentumBarsCunt);
if (!result)
{
break;
}
//
if (isBullishDir)
{
//
for (int i = 0; i < bullishMomentumBarsCunt; i++)
{
//
}
}
else
{
//
for (int i = 0; i < bullishMomentumBarsCunt; i++)
{
//
}
}
//
break;
};
//
case X_POI_REJECTION_BAR: {
//
// Validate Direction ...
result = HasDirection(dir);
if (!result)
{
return result;
}
//
bool isBullishDir = IsBullish(dir);
//
// Validate State POI(s) ...
result =
isBullishDir
? IsValidSize(bullishMomentumBarsCunt)
: IsValidSize(bearishMomentumBarsCunt);
if (!result)
{
break;
}
//
if (isBullishDir)
{
//
for (int i = 0; i < bullishMomentumBarsCunt; i++)
{
//
}
}
else
{
//
for (int i = 0; i < bullishMomentumBarsCunt; i++)
{
//
}
}
//
break;
};
//
case X_POI_SWING_HIGH:
break;
//
case X_POI_SWING_LOW:
break;
//
case X_POI_SUPPORT_ZONE:
break;
//
case X_POI_RESISTANCE_ZONE:
break;
//
case X_POI_SUPPLY_ZONE:
break;
//
case X_POI_DEMAND_ZONE:
break;
//
case X_POI_BULLISH_ORDERBLOCK:
break;
//
case X_POI_BEARISH_ORDERBLOCK:
break;
//
case X_POI_BULLISH_FVG:
break;
//
case X_POI_BEARISH_FVG:
break;
}
//
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 drawAnalyseState = 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);
}
}
//
// Vision ...
if (drawVisionState)
{
//
CustomStateDrawing(
mTriggerPOIState,
false,
forDir,
ignoreSwingHighs,
ignoreSwingLows,
ignoreSupportZones,
ignoreResistanceZones,
ignoreSupplyZones,
ignoreDemandZones,
ignoreBullishOrderBlocks,
ignoreBearishOrderBlocks,
ignoreBullishFairValueGaps,
ignoreBearishFairValueGaps,
ignoreBullishRejectionBars,
ignoreBearishRejectionBars,
ignoreBullishMomentumBars,
ignoreBearishMomentumBars //
);
}
//
// Analyse ...
if (drawAnalyseState)
{
//
CustomStateDrawing(
mAnalysePOIState,
false,
forDir,
ignoreSwingHighs,
ignoreSwingLows,
ignoreSupportZones,
ignoreResistanceZones,
ignoreSupplyZones,
ignoreDemandZones,
ignoreBullishOrderBlocks,
ignoreBearishOrderBlocks,
ignoreBullishFairValueGaps,
ignoreBearishFairValueGaps,
ignoreBullishRejectionBars,
ignoreBearishRejectionBars,
ignoreBullishMomentumBars,
ignoreBearishMomentumBars //
);
}
//
// Trigger ...
if (drawTriggerState)
{
//
CustomStateDrawing(
mVisionPOIState,
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.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;
//
xpvHelper = new XCXPVHelper();
xpvHelper.Init(
symbol,
period,
xpvInputs //
);
//
// X3MA ...
//
x3maInputs.Default();
//
x3maInputs.showFast = true;
x3maInputs.showMid = false;
x3maInputs.showSlow = false;
//
x3maHelper = new XCX3MAHelper();
x3maHelper.Init(
symbol,
period,
x3maInputs //
);
//
// X3VWAP ...
//
x3vwapInputs.Default();
//
x3vwapInputs.showFast = true;
x3vwapInputs.showMid = true;
x3vwapInputs.showSlow = true;
//
x3vwapHelper = new XCX3VWAPHelper();
x3vwapHelper.Init(
symbol,
period,
x3vwapInputs //
);
//
// XCHCHSAR ...
//
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;
//
xchsarHelper = new XCXCHSARHelper();
xchsarHelper.Init(
symbol,
period,
xchsarInputs //
);
}
//
};
//