3014 lines
154 KiB
Plaintext
3014 lines
154 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.xchvwap.helper.mq5"
|
|
#include "../../Helpers/x-saherelm.xpv.helper.mq5"
|
|
#include "../Classes/x-121.smc.base.strategy.class.mq5"
|
|
|
|
//
|
|
// Helper(s) ...
|
|
|
|
//
|
|
// 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();
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
void ~XCX121SMCTestStrategy()
|
|
{
|
|
//
|
|
delete pvHelper;
|
|
delete chvwapHelper;
|
|
}
|
|
|
|
//
|
|
// Overrides Actions ...
|
|
|
|
//
|
|
// 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();
|
|
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;
|
|
|
|
//
|
|
bool isAllowLong = AllowLong();
|
|
bool isAllowShort = AllowShort();
|
|
result = isAllowLong || isAllowShort;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
;
|
|
}
|
|
|
|
//
|
|
// Start Calculations ...
|
|
|
|
//
|
|
string _symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES _period = GetPeriod();
|
|
|
|
//
|
|
double points = GetPoints(_symbol);
|
|
double pip = GetPipPrice(_symbol);
|
|
double pip2 = 2 * pip;
|
|
double pip3 = 3 * pip;
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
int ppIndex = pIndex + 1;
|
|
|
|
//
|
|
int loopback = 7;
|
|
int dest = cIndex + loopback;
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
conditions.Clean();
|
|
conditions.time = cTime;
|
|
conditions.symbol = _symbol;
|
|
conditions.period = _period;
|
|
|
|
//
|
|
// 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;
|
|
}
|
|
|
|
//
|
|
bool isSpreadPassed = IsSpreadPass();
|
|
result = isSpreadPassed;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Ticks States ...
|
|
bool isTicksBullish = IsTicksBullish();
|
|
bool isTicksBearish = IsTicksBearish();
|
|
bool isTicksHasMomentum = IsTicksHasMomentum();
|
|
|
|
//
|
|
bool isBarDeetected = DetectBar();
|
|
|
|
//
|
|
// Reading Indicator's Conditions ...
|
|
XCHVWAPConditions chvwapConditions;
|
|
chvwapHelper.GetConditions(
|
|
chvwapConditions,
|
|
cIndex,
|
|
loopback //
|
|
);
|
|
|
|
//
|
|
result =
|
|
conditions.supplyZone.IsValid() ||
|
|
conditions.demandZone.IsValid();
|
|
if (!result)
|
|
{
|
|
//
|
|
DetectMarketConditions();
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// TODO: Update Conditions Zones To Time ...
|
|
|
|
//
|
|
bool isBullish =
|
|
//
|
|
false
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isBearish =
|
|
//
|
|
(
|
|
//
|
|
// Common Conditions ...
|
|
//
|
|
// Check Break of Zone ...
|
|
// isBreaked &&
|
|
//
|
|
// Bar Trend ...
|
|
cBar.IsBearish() &&
|
|
(
|
|
// cBar.IsShootingStar() ||
|
|
cBar.IsBearishDecision() ||
|
|
cBar.IsBearishEngulfing() ||
|
|
cBar.IsBearishMarubozu() ||
|
|
cBar.HasStrongHighShadow())
|
|
//
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
if (isBullish || isBearish)
|
|
{
|
|
//
|
|
double pvPOIss[];
|
|
DetectPVPOIs(
|
|
pvPOIss //
|
|
);
|
|
|
|
//
|
|
hasLong = isBullish;
|
|
hasShort = isBearish;
|
|
Print("");
|
|
}
|
|
|
|
//
|
|
result = hasLong ||
|
|
hasShort;
|
|
if (!result)
|
|
{
|
|
conditions.Clean();
|
|
}
|
|
|
|
//
|
|
// 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 //
|
|
);
|
|
|
|
//
|
|
double slCandidates[];
|
|
|
|
//
|
|
double selectedSL =
|
|
hasLong
|
|
? GetMin(slCandidates)
|
|
: GetMax(slCandidates);
|
|
sl =
|
|
hasLong
|
|
? selectedSL - pip3
|
|
: selectedSL + pip3;
|
|
|
|
//
|
|
// 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.pushers = pushers;
|
|
signal.provider = GetTag();
|
|
signal.time = TimeCurrent();
|
|
signal.period = _5MState.period;
|
|
|
|
//
|
|
result = PrepareSignal(signal);
|
|
|
|
//
|
|
hasLong = false;
|
|
hasShort = false;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Customize Strategy Identifier ...
|
|
string GetTag() override
|
|
{
|
|
return X121SMCSUPDEMStrategyToken;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
|
|
//
|
|
// Props ...
|
|
XOHCL dailyHHBar;
|
|
XOHCL dailyLLBar;
|
|
XZone dailyMiddleZone;
|
|
|
|
//
|
|
// XPV ...
|
|
XPVInputs pvInputs;
|
|
XSCXPVHelper *pvHelper;
|
|
|
|
//
|
|
// XCHVWAP ...
|
|
XCHVWAPInputs chvwapInputs;
|
|
XSCXCHVWAPHelper *chvwapHelper;
|
|
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
|
|
/**
|
|
* Initial Required Indicators Helper ...
|
|
*/
|
|
void InitialHelpers()
|
|
{
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
// Short ...
|
|
ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_MANUALLY; // How to Find Period
|
|
ENUM_TIMEFRAMES scPeriod = PERIOD_M5; // Time Period
|
|
|
|
//
|
|
// Medium ...
|
|
ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_MANUALLY; // How to Find Period
|
|
ENUM_TIMEFRAMES mcPeriod = PERIOD_M15; // Time Period
|
|
|
|
//
|
|
// Long ...
|
|
ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_MANUALLY; // How to Find Period
|
|
ENUM_TIMEFRAMES lcPeriod = PERIOD_M30; // Time Period
|
|
|
|
//
|
|
// Hind ...
|
|
ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_MANUALLY; // How to Find Period
|
|
ENUM_TIMEFRAMES hcPeriod = PERIOD_H1; // Time Period
|
|
|
|
//
|
|
// XPV ...
|
|
|
|
//
|
|
pvInputs.Default();
|
|
|
|
//
|
|
pvInputs.scMethod = scMethod;
|
|
pvInputs.scPeriod = scPeriod;
|
|
pvInputs.mcMethod = mcMethod;
|
|
pvInputs.mcPeriod = mcPeriod;
|
|
pvInputs.lcMethod = lcMethod;
|
|
pvInputs.lcPeriod = lcPeriod;
|
|
pvInputs.hcMethod = hcMethod;
|
|
pvInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
pvInputs.showPeaksAndVales = false;
|
|
pvInputs.showLevels = false;
|
|
pvInputs.showConsolidations = false;
|
|
pvInputs.showFibo1Levels = false;
|
|
pvInputs.showFibo2Levels = false;
|
|
pvInputs.showFibo3Levels = false;
|
|
pvInputs.showFibo4Levels = false;
|
|
pvInputs.showFibo5Levels = false;
|
|
|
|
//
|
|
pvHelper = new XSCXPVHelper();
|
|
pvHelper.Init(
|
|
symbol,
|
|
period,
|
|
pvInputs //
|
|
);
|
|
|
|
//
|
|
// XCHVWAP ...
|
|
|
|
//
|
|
chvwapInputs.Default();
|
|
|
|
//
|
|
chvwapInputs.scMethod = scMethod;
|
|
chvwapInputs.scPeriod = scPeriod;
|
|
chvwapInputs.mcMethod = mcMethod;
|
|
chvwapInputs.mcPeriod = mcPeriod;
|
|
chvwapInputs.lcMethod = lcMethod;
|
|
chvwapInputs.lcPeriod = lcPeriod;
|
|
chvwapInputs.hcMethod = hcMethod;
|
|
chvwapInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
chvwapInputs.showShort = true;
|
|
chvwapInputs.showMedium = true;
|
|
chvwapInputs.showLong = true;
|
|
chvwapInputs.showHind = true;
|
|
|
|
//
|
|
chvwapHelper = new XSCXCHVWAPHelper();
|
|
chvwapHelper.Init(
|
|
symbol,
|
|
period,
|
|
chvwapInputs //
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Detect Direction of VWAP ...
|
|
*
|
|
* @param onlyOrders: Boolean ...
|
|
* @param onlyCrosses: Boolean ...
|
|
|
|
* @return ( bool )
|
|
*/
|
|
ENUM_X_DIRECTION DetectVWAPDirection(
|
|
bool onlyOrders = false, //
|
|
bool onlyCrosses = true //
|
|
)
|
|
{
|
|
//
|
|
ENUM_X_DIRECTION result = X_DIRECTION_NONE;
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
|
|
//
|
|
int loopback = 7;
|
|
int dest = cIndex + loopback;
|
|
string symbol = GetSymbol();
|
|
datetime cTime = TimeCurrent();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
// Reading Indicator's Conditions ...
|
|
XCHVWAPConditions chvwapConditions;
|
|
chvwapHelper.GetConditions(
|
|
chvwapConditions,
|
|
cIndex,
|
|
loopback //
|
|
);
|
|
|
|
//
|
|
bool isBullishOrdered =
|
|
//
|
|
// chvwapConditions.s[0] > chvwapConditions.m[0] &&
|
|
chvwapConditions.m[0] > chvwapConditions.l[0] &&
|
|
chvwapConditions.l[0] > chvwapConditions.h[0]
|
|
//
|
|
;
|
|
//
|
|
bool isBullishOrderedPrev =
|
|
//
|
|
// chvwapConditions.s[1] > chvwapConditions.m[1] &&
|
|
chvwapConditions.m[1] > chvwapConditions.l[1] &&
|
|
chvwapConditions.l[1] > chvwapConditions.h[1]
|
|
//
|
|
;
|
|
bool isBullishState =
|
|
//
|
|
// chvwapHelper.IsBullish(chvwapConditions.sState[0]) &&
|
|
chvwapHelper.IsBullish(chvwapConditions.mState[0]) &&
|
|
chvwapHelper.IsBullish(chvwapConditions.lState[0]) &&
|
|
chvwapHelper.IsBullish(chvwapConditions.hState[0])
|
|
//
|
|
;
|
|
bool isBullishStatePrev =
|
|
//
|
|
// chvwapHelper.IsBullish(chvwapConditions.sState[1]) &&
|
|
chvwapHelper.IsBullish(chvwapConditions.mState[1]) &&
|
|
chvwapHelper.IsBullish(chvwapConditions.lState[1]) &&
|
|
chvwapHelper.IsBullish(chvwapConditions.hState[1])
|
|
//
|
|
;
|
|
bool isBullishDirection =
|
|
isBullishState &&
|
|
isBullishOrdered;
|
|
bool isBullishDirectionPrev =
|
|
isBullishStatePrev &&
|
|
isBullishOrderedPrev;
|
|
|
|
//
|
|
bool isBearishOrdered =
|
|
//
|
|
// chvwapConditions.s[0] < chvwapConditions.m[0] &&
|
|
chvwapConditions.m[0] < chvwapConditions.l[0] &&
|
|
chvwapConditions.l[0] < chvwapConditions.h[0]
|
|
//
|
|
;
|
|
//
|
|
bool isBearishOrderedPrev =
|
|
//
|
|
// chvwapConditions.s[1] < chvwapConditions.m[1] &&
|
|
chvwapConditions.m[1] < chvwapConditions.l[1] &&
|
|
chvwapConditions.l[1] < chvwapConditions.h[1]
|
|
//
|
|
;
|
|
bool isBearishState =
|
|
//
|
|
// chvwapHelper.IsBearish(chvwapConditions.sState[0]) &&
|
|
chvwapHelper.IsBearish(chvwapConditions.mState[0]) &&
|
|
chvwapHelper.IsBearish(chvwapConditions.lState[0]) &&
|
|
chvwapHelper.IsBearish(chvwapConditions.hState[0])
|
|
//
|
|
;
|
|
bool isBearishStatePrev =
|
|
//
|
|
// chvwapHelper.IsBearish(chvwapConditions.sState[1]) &&
|
|
chvwapHelper.IsBearish(chvwapConditions.mState[1]) &&
|
|
chvwapHelper.IsBearish(chvwapConditions.lState[1]) &&
|
|
chvwapHelper.IsBearish(chvwapConditions.hState[1])
|
|
//
|
|
;
|
|
bool isBearishDirection =
|
|
isBearishState &&
|
|
isBearishOrdered;
|
|
bool isBearishDirectionPrev =
|
|
isBearishStatePrev &&
|
|
isBearishOrderedPrev;
|
|
|
|
//
|
|
if (onlyOrders)
|
|
{
|
|
//
|
|
if (onlyCrosses)
|
|
{
|
|
//
|
|
if (isBullishOrdered &&
|
|
!isBullishOrderedPrev)
|
|
{
|
|
result = X_DIRECTION_BULLISH;
|
|
}
|
|
else if (isBearishOrdered &&
|
|
!isBearishOrdered)
|
|
{
|
|
result = X_DIRECTION_BEARISH;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
if (isBullishOrdered)
|
|
{
|
|
result = X_DIRECTION_BULLISH;
|
|
}
|
|
else if (isBearishOrdered)
|
|
{
|
|
result = X_DIRECTION_BEARISH;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
if (onlyCrosses)
|
|
{
|
|
//
|
|
if (isBullishDirection &&
|
|
!isBullishDirectionPrev)
|
|
{
|
|
result = X_DIRECTION_BULLISH;
|
|
}
|
|
else if (isBearishDirection &&
|
|
!isBearishDirectionPrev)
|
|
{
|
|
result = X_DIRECTION_BEARISH;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
if (isBullishDirection)
|
|
{
|
|
result = X_DIRECTION_BULLISH;
|
|
}
|
|
else if (isBearishDirection)
|
|
{
|
|
result = X_DIRECTION_BEARISH;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Detect XPV POIs ...
|
|
*
|
|
* @param hhs: Double array ...
|
|
* @param lls: Double array ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int DetectPVPOIs(
|
|
double &values[] //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
Clean(values);
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
|
|
//
|
|
int requiredCount = 10;
|
|
long chartID = ChartIdentification();
|
|
int subWindow = SubWindowIdentification();
|
|
|
|
//
|
|
int loopback = 300;
|
|
int dest = cIndex + loopback;
|
|
string symbol = GetSymbol();
|
|
datetime cTime = TimeCurrent();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
XOHCL cBar;
|
|
bool isInited = cBar.Init(
|
|
symbol,
|
|
period,
|
|
cIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XPVConditions pvConditions;
|
|
pvHelper.GetConditions(
|
|
pvConditions,
|
|
cIndex,
|
|
loopback //
|
|
);
|
|
|
|
//
|
|
// Find POI ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
int iCount = 0;
|
|
double iValue = pvConditions.sCHHs[i];
|
|
|
|
//
|
|
// Peaks ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.peaks[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Values ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.vales[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistance ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.resistances[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Support ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.supports[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Short Cycle Highest Highs ...
|
|
for (int j = i + 1; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.sCHHs[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Short Cycle Lowest Low ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.sCLLs[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Medium Cycle Highest Highs ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.mCHHs[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Medium Cycle Lowest Low ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.mCLLs[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Long Cycle Highest Highs ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.lCHHs[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Long Cycle Lowest Low ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.lCLLs[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Hind Cycle Highest Highs ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.hCHHs[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Hind Cycle Lowest Low ...
|
|
for (int j = 0; j < loopback; j++)
|
|
{
|
|
//
|
|
double jValue = pvConditions.hCLLs[j];
|
|
|
|
//
|
|
if (jValue == iValue)
|
|
{
|
|
iCount++;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iCount >= requiredCount)
|
|
{
|
|
//
|
|
AddIfNotExists(
|
|
iValue,
|
|
values //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
result = ArraySize(values);
|
|
|
|
//
|
|
bool drawPOIs = true;
|
|
int width = 1;
|
|
ENUM_LINE_STYLE lineStyle = STYLE_DOT;
|
|
color clrResistance = clrOrange;
|
|
color clrSupport = clrTeal;
|
|
|
|
//
|
|
if (drawPOIs &&
|
|
IsValidSize(result))
|
|
{
|
|
//
|
|
for (int i = 0; i < result; i++)
|
|
{
|
|
//
|
|
double iValue = values[i];
|
|
|
|
//
|
|
datetime time1 = (datetime)((int)cBar.time - (2 * PeriodSeconds(cBar.period)));
|
|
datetime time2 = (datetime)((int)cBar.time + (2 * PeriodSeconds(cBar.period)));
|
|
|
|
//
|
|
string hash = "POI_" + ToString(iValue) + "_" + ToString(time1) + ToString(time2);
|
|
hash = ToMD5(hash);
|
|
|
|
//
|
|
string iName = "POI_" + ToString(iValue) + "_" + hash;
|
|
|
|
//
|
|
CChartObjectTrend *iObj;
|
|
iObj = new CChartObjectTrend();
|
|
bool isCreated = iObj.Create(
|
|
chartID,
|
|
iName,
|
|
subWindow,
|
|
time1,
|
|
iValue,
|
|
time2,
|
|
iValue //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
//
|
|
iObj.Width(width);
|
|
iObj.Style(lineStyle);
|
|
|
|
//
|
|
if (iValue > cBar.close)
|
|
{
|
|
iObj.Color(clrResistance);
|
|
}
|
|
else if (iValue < cBar.close)
|
|
{
|
|
iObj.Color(clrSupport);
|
|
}
|
|
|
|
//
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Detect POIs ...
|
|
*/
|
|
void DetectPOIs()
|
|
{
|
|
//
|
|
// 1 Min ...
|
|
// DrawState(_1MState);
|
|
|
|
//
|
|
// 5 Min ...
|
|
// DrawState(_5MState);
|
|
|
|
//
|
|
// 15 Min ...
|
|
// DrawState(_15MState);
|
|
|
|
//
|
|
// 1 Hour ...
|
|
// DrawState(_1HState);
|
|
|
|
//
|
|
// 2 Hour ...
|
|
// DrawState(_2HState);
|
|
|
|
//
|
|
// 4 Hour ...
|
|
// DrawState(_4HState);
|
|
|
|
//
|
|
// 1 Day ...
|
|
// DrawState(_1DState);
|
|
|
|
//
|
|
// Combine ...
|
|
// DrawState(_CombineState);
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
int ppIndex = pIndex + 1;
|
|
|
|
//
|
|
int loopback = 7;
|
|
int dest = cIndex + loopback;
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
// Retrieve Bars ...
|
|
|
|
//
|
|
// Zero Bar ...
|
|
XOHCL zBar;
|
|
bool isInited = zBar.Init(
|
|
symbol,
|
|
period,
|
|
zIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Last Bar ...
|
|
XOHCL cBar;
|
|
isInited = cBar.Init(
|
|
symbol,
|
|
period,
|
|
cIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = 0;
|
|
XPOIState state = _CombineState;
|
|
|
|
//
|
|
//
|
|
// Supply Zones ...
|
|
count = ArraySize(state.supplyZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.supplyZones[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
bool canRefine = CanRefineZone(
|
|
iZone,
|
|
mConditions.supplyZone,
|
|
cBar //
|
|
);
|
|
if (canRefine)
|
|
{
|
|
mConditions.supplyZone = iZone;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Demand Zones ....
|
|
count = ArraySize(state.demandZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.demandZones[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
bool canRefine = CanRefineZone(
|
|
iZone,
|
|
mConditions.demandZone,
|
|
cBar //
|
|
);
|
|
if (canRefine)
|
|
{
|
|
mConditions.demandZone = iZone;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bullish Order Blocks ....
|
|
count = ArraySize(state.bullishOrderBlocks);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.bullishOrderBlocks[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
bool canRefine = CanRefineZone(
|
|
iZone,
|
|
mConditions.bullishOrderBlock,
|
|
cBar //
|
|
);
|
|
if (canRefine)
|
|
{
|
|
mConditions.bullishOrderBlock = iZone;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Order Blocks ....
|
|
count = ArraySize(state.bearishOrderBlocks);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.bearishOrderBlocks[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
bool canRefine = CanRefineZone(
|
|
iZone,
|
|
mConditions.bearishOrderBlock,
|
|
cBar //
|
|
);
|
|
if (canRefine)
|
|
{
|
|
mConditions.bearishOrderBlock = iZone;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bullish Fair Value Gaps ....
|
|
count = ArraySize(state.bullishFVGs);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.bullishFVGs[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
bool canRefine = CanRefineZone(
|
|
iZone,
|
|
mConditions.bullishFVG,
|
|
cBar //
|
|
);
|
|
if (canRefine)
|
|
{
|
|
mConditions.bullishFVG = iZone;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Fair Value Gaps ....
|
|
count = ArraySize(state.bearishFVGs);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.bearishFVGs[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
bool canRefine = CanRefineZone(
|
|
iZone,
|
|
mConditions.bearishFVG,
|
|
cBar //
|
|
);
|
|
if (canRefine)
|
|
{
|
|
mConditions.bearishFVG = iZone;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Support Zones ....
|
|
count = ArraySize(state.supportZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.supportZones[i];
|
|
|
|
//
|
|
bool canRefine =
|
|
//
|
|
!mConditions.support.IsValid()
|
|
? (
|
|
//
|
|
iBar.low < cBar.low &&
|
|
iBar.GetDown() > cBar.high
|
|
//
|
|
)
|
|
: (
|
|
//
|
|
mConditions.support.low < cBar.low &&
|
|
mConditions.support.GetDown() > cBar.high &&
|
|
iBar.low < cBar.low &&
|
|
iBar.GetDown() > cBar.high &&
|
|
iBar.GetDown() - iBar.low < mConditions.support.GetDown() - mConditions.support.low
|
|
//
|
|
)
|
|
//
|
|
;
|
|
if (canRefine)
|
|
{
|
|
mConditions.support = iBar;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistance Zones ....
|
|
count = ArraySize(state.resistanceZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.resistanceZones[i];
|
|
|
|
//
|
|
bool canRefine =
|
|
//
|
|
!mConditions.resistance.IsValid()
|
|
? (
|
|
//
|
|
iBar.GetUp() < cBar.low &&
|
|
iBar.high > cBar.high
|
|
//
|
|
)
|
|
: (
|
|
//
|
|
mConditions.resistance.GetUp() < cBar.low &&
|
|
mConditions.resistance.high > cBar.high &&
|
|
iBar.GetUp() < cBar.low &&
|
|
iBar.high > cBar.high &&
|
|
iBar.high - iBar.GetUp() < mConditions.resistance.high - mConditions.resistance.GetUp()
|
|
//
|
|
)
|
|
//
|
|
;
|
|
if (canRefine)
|
|
{
|
|
mConditions.resistance = iBar;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Momentum Bars ....
|
|
count = ArraySize(state.momentumBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.momentumBars[i];
|
|
bool isBullish = iBar.IsBullish();
|
|
|
|
//
|
|
// Bullish Momentum Bar ....
|
|
if (isBullish)
|
|
{
|
|
//
|
|
bool canRefine = iBar.high < cBar.low;
|
|
if (canRefine)
|
|
{
|
|
mConditions.bullishMomentumBar = iBar;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Momentum Bar ....
|
|
if (!isBullish)
|
|
{
|
|
//
|
|
bool canRefine = iBar.low > cBar.high;
|
|
if (canRefine)
|
|
{
|
|
mConditions.bearishMomentumBar = iBar;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Rejection Bars ...
|
|
count = ArraySize(state.rejectionBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.rejectionBars[i];
|
|
bool isBullish =
|
|
iBar.GetLowShadow() > iBar.GetHighShadow();
|
|
|
|
//
|
|
// Bullish Rejection Bar ....
|
|
if (isBullish)
|
|
{
|
|
//
|
|
bool canRefine = iBar.high < cBar.low;
|
|
if (canRefine)
|
|
{
|
|
mConditions.bullishRejectionBar = iBar;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Rejection Bar ....
|
|
if (!isBullish)
|
|
{
|
|
//
|
|
bool canRefine = iBar.low > cBar.high;
|
|
if (canRefine)
|
|
{
|
|
mConditions.bearishRejectionBar = iBar;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Highs ....
|
|
count = ArraySize(state.swingHighs);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.swingHighs[i];
|
|
|
|
//
|
|
bool canRefine = iBar.high > cBar.high;
|
|
if (canRefine)
|
|
{
|
|
mConditions.swingHigh = iBar;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Lows ....
|
|
count = ArraySize(state.swingLows);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.swingLows[i];
|
|
|
|
//
|
|
bool canRefine = iBar.low > cBar.high;
|
|
if (canRefine)
|
|
{
|
|
mConditions.swingLow = iBar;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Draw Market Conditions ...
|
|
DrawMarketConditions();
|
|
}
|
|
|
|
/**
|
|
* Detect Previous Day Range ...
|
|
*/
|
|
void DetectDailyRange()
|
|
{
|
|
//
|
|
// Detect Daily High / Low and Middle Zones ...
|
|
// Period 5M is Source ...
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
datetime cTime = TimeCurrent();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
// Extract Common Requirements ...
|
|
datetime dailyStartBarTime = iTime(
|
|
symbol,
|
|
PERIOD_D1,
|
|
1 //
|
|
);
|
|
int dailyStartBarIndex = iBarShift(
|
|
symbol,
|
|
period,
|
|
dailyStartBarTime //
|
|
);
|
|
datetime dailyEndBarTime =
|
|
(datetime)((int)dailyStartBarTime + PeriodSeconds(PERIOD_D1) - PeriodSeconds(period));
|
|
int dailyEndBarIndex = iBarShift(
|
|
symbol,
|
|
period,
|
|
dailyEndBarTime //
|
|
);
|
|
int dailyLenght = MathAbs(dailyStartBarIndex - dailyEndBarIndex);
|
|
|
|
//
|
|
// Highest High ...
|
|
int dailyHHBarIndex = iHighest(
|
|
symbol,
|
|
period,
|
|
MODE_HIGH,
|
|
dailyLenght,
|
|
dailyEndBarIndex //
|
|
);
|
|
dailyHHBar.Clean();
|
|
bool isInited = dailyHHBar.Init(
|
|
symbol,
|
|
period,
|
|
dailyHHBarIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Lowest Low ...
|
|
int dailyLLBarIndex = iLowest(
|
|
symbol,
|
|
period,
|
|
MODE_LOW,
|
|
dailyLenght,
|
|
dailyEndBarIndex //
|
|
);
|
|
dailyLLBar.Clean();
|
|
isInited = dailyLLBar.Init(
|
|
symbol,
|
|
period,
|
|
dailyLLBarIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Daily Middle Zone ...
|
|
double range = MathMax(
|
|
(dailyHHBar.high - dailyHHBar.GetUp()),
|
|
(dailyLLBar.GetDown() - dailyLLBar.low));
|
|
|
|
//
|
|
double middle =
|
|
dailyHHBar.GetUp() - ((dailyHHBar.GetUp() - dailyLLBar.GetDown()) / 2);
|
|
|
|
//
|
|
dailyMiddleZone.Clean();
|
|
string middleZonePrefix = "XDailyMiddle_";
|
|
|
|
//
|
|
double upper = middle + (range / 2);
|
|
double lower = middle - (range / 2);
|
|
isInited = dailyMiddleZone.Init(
|
|
upper,
|
|
lower,
|
|
middleZonePrefix,
|
|
dailyStartBarTime,
|
|
cTime //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
DrawDailyRange();
|
|
}
|
|
|
|
/**
|
|
* Detect Market Conditions ...
|
|
*/
|
|
void DetectMarketConditions()
|
|
{
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
int ppIndex = pIndex + 1;
|
|
|
|
//
|
|
int loopback = 7;
|
|
int dest = cIndex + loopback;
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
// Retrieve Bars ...
|
|
|
|
//
|
|
// Zero Bar ...
|
|
XOHCL zBar;
|
|
bool isInited = zBar.Init(
|
|
symbol,
|
|
period,
|
|
zIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Last Bar ...
|
|
XOHCL cBar;
|
|
isInited = cBar.Init(
|
|
symbol,
|
|
period,
|
|
cIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Prev Bar ...
|
|
XOHCL pBar;
|
|
isInited = pBar.Init(
|
|
symbol,
|
|
period,
|
|
pIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
DetectDailyRange();
|
|
|
|
//
|
|
// PV Conditions ...
|
|
XPVConditions pvConditions;
|
|
pvHelper.GetConditions(
|
|
pvConditions,
|
|
cIndex,
|
|
loopback //
|
|
);
|
|
|
|
//
|
|
bool isCloseCrossedOverFib =
|
|
//
|
|
cBar.close > pvConditions.fib3s[0] &&
|
|
pBar.close < pvConditions.fib3s[1] &&
|
|
pBar.close < pvConditions.fib3s[2] &&
|
|
pBar.close < pvConditions.fib3s[3] &&
|
|
pBar.close < pvConditions.fib3s[4] &&
|
|
pBar.close < pvConditions.fib3s[5]
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isCloseCrossedUnderFib =
|
|
//
|
|
cBar.close < pvConditions.fib3s[0] &&
|
|
pBar.close > pvConditions.fib3s[1] &&
|
|
pBar.close > pvConditions.fib3s[2] &&
|
|
pBar.close > pvConditions.fib3s[3] &&
|
|
pBar.close > pvConditions.fib3s[4] &&
|
|
pBar.close > pvConditions.fib3s[5]
|
|
//
|
|
;
|
|
|
|
//
|
|
// VWap Conditions Conditions ...
|
|
XCHVWAPConditions chvwapConditions;
|
|
chvwapHelper.GetConditions(
|
|
chvwapConditions,
|
|
cIndex,
|
|
loopback //
|
|
);
|
|
|
|
//
|
|
ENUM_X_DIRECTION regularVWapDir = DetectVWAPDirection();
|
|
ENUM_X_DIRECTION orderVWapDir = DetectVWAPDirection(true);
|
|
bool isVWapBullish =
|
|
IsBullish(regularVWapDir) ||
|
|
IsBullish(orderVWapDir);
|
|
bool isVWapBearish =
|
|
IsBearish(regularVWapDir) ||
|
|
IsBearish(orderVWapDir);
|
|
|
|
//
|
|
bool isBullish = isVWapBullish &&
|
|
isCloseCrossedOverFib;
|
|
|
|
//
|
|
bool isBearish = isVWapBearish &&
|
|
isCloseCrossedUnderFib;
|
|
|
|
//
|
|
bool result = isBullish || isBearish;
|
|
if (result)
|
|
{
|
|
//
|
|
double iPvPOIs[];
|
|
DetectPVPOIs(iPvPOIs);
|
|
DetectPOIs();
|
|
mConditions.Clean();
|
|
|
|
//
|
|
Print("result");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Specific States on Screen ...
|
|
*
|
|
* @param state: XPOIState instance ...
|
|
*/
|
|
void DrawState(XPOIState &state)
|
|
{
|
|
//
|
|
bool drawSupplyZones = true;
|
|
bool drawDemandZones = true;
|
|
|
|
//
|
|
bool drawBullishOrderBlocks = true;
|
|
bool drawBearishOrderBlocks = true;
|
|
|
|
//
|
|
bool drawBullishFVGs = true;
|
|
bool drawBearishFVGs = true;
|
|
|
|
//
|
|
bool drawBullishMomentumBars = true;
|
|
bool drawBearishMomentumBars = true;
|
|
|
|
//
|
|
bool drawBullishRejectionBars = true;
|
|
bool drawBearishRejectionBars = true;
|
|
|
|
//
|
|
bool drawSwingHighs = true;
|
|
bool drawSwingLows = true;
|
|
|
|
//
|
|
bool drawSupports = true;
|
|
bool drawResistances = true;
|
|
|
|
//
|
|
int count = 0;
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
// Supply Zones ...
|
|
count = ArraySize(state.supplyZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.supplyZones[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawSupplyZones)
|
|
{
|
|
//
|
|
XCSupplyZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSupplyZone(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Demand Zones ....
|
|
count = ArraySize(state.demandZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.demandZones[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawDemandZones)
|
|
{
|
|
//
|
|
XCDemandZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateDemandZone(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bullish Order Blocks ....
|
|
count = ArraySize(state.bullishOrderBlocks);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.bullishOrderBlocks[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawBullishOrderBlocks)
|
|
{
|
|
//
|
|
XCBullishOrderBlockObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishOrderBlock(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Order Blocks ....
|
|
count = ArraySize(state.bearishOrderBlocks);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.bearishOrderBlocks[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawBearishOrderBlocks)
|
|
{
|
|
//
|
|
XCBearishOrderBlockObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishOrderBlock(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bullish Fair Value Gaps ....
|
|
count = ArraySize(state.bullishFVGs);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.bullishFVGs[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawBullishFVGs)
|
|
{
|
|
//
|
|
XCBullishFVGObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishFVG(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Fair Value Gaps ....
|
|
count = ArraySize(state.bearishFVGs);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = state.bearishFVGs[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawBullishFVGs)
|
|
{
|
|
//
|
|
XCBearishFVGObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishFVG(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bullish Momentum Bar ....
|
|
// Bearish Momentum Bar ....
|
|
count = ArraySize(state.momentumBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.momentumBars[i];
|
|
bool isBullish = iBar.IsBullish();
|
|
|
|
//
|
|
// Bullish Rejection Bar ....
|
|
if (isBullish &&
|
|
drawBullishMomentumBars)
|
|
{
|
|
//
|
|
XCBullishMomentumBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishMomentumBar(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (!isBullish &&
|
|
drawBearishMomentumBars)
|
|
{
|
|
//
|
|
// Bearish Rejection Bar ....
|
|
XCBearishMomentumBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishMomentumBar(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Rejection Bars ...
|
|
count = ArraySize(state.rejectionBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.rejectionBars[i];
|
|
bool isBullish =
|
|
iBar.GetLowShadow() > iBar.GetHighShadow();
|
|
|
|
//
|
|
// Bullish Rejection Bar ....
|
|
if (isBullish &&
|
|
drawBullishRejectionBars)
|
|
{
|
|
//
|
|
XCBullishRejectionBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishRejectionBar(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (!isBullish &&
|
|
drawBearishRejectionBars)
|
|
{
|
|
//
|
|
// Bearish Rejection Bar ....
|
|
XCBearishRejectionBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishRejectionBar(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Highs ....
|
|
count = ArraySize(state.swingHighs);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.swingHighs[i];
|
|
|
|
//
|
|
if (drawSwingHighs)
|
|
{
|
|
//
|
|
XCSwingHighObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSwingHigh(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Lows ....
|
|
count = ArraySize(state.swingLows);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.swingLows[i];
|
|
|
|
//
|
|
if (drawSwingLows)
|
|
{
|
|
//
|
|
XCSwingLowObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSwingLow(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Supports ....
|
|
count = ArraySize(state.supportZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.supportZones[i];
|
|
|
|
//
|
|
if (drawSupports)
|
|
{
|
|
//
|
|
XCSupportZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSupportZone(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistances ....
|
|
count = ArraySize(state.resistanceZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = state.resistanceZones[i];
|
|
|
|
//
|
|
if (drawResistances)
|
|
{
|
|
//
|
|
XCResistanceZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Daily Range Zones ...
|
|
*/
|
|
void DrawDailyRange()
|
|
{
|
|
//
|
|
if (!dailyHHBar.IsValid() &&
|
|
!dailyLLBar.IsValid() &&
|
|
!dailyMiddleZone.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool drawDailySupport = true;
|
|
bool drawDailyResistance = true;
|
|
bool drawDailyMiddle = true;
|
|
|
|
//
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
// Daily Support ...
|
|
if (drawDailySupport &&
|
|
dailyLLBar.IsValid())
|
|
{
|
|
//
|
|
XCSupportZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSupportZone(
|
|
dailyLLBar,
|
|
iObj,
|
|
cTime //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Daily Resistance ...
|
|
if (drawDailyResistance &&
|
|
dailyHHBar.IsValid())
|
|
{
|
|
//
|
|
XCResistanceZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
|
dailyHHBar,
|
|
iObj,
|
|
cTime //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Daily Middle ...
|
|
if (drawDailyMiddle &&
|
|
dailyMiddleZone.IsValid())
|
|
{
|
|
//
|
|
XCZoneObject *iObj;
|
|
iObj = new XCZoneObject();
|
|
|
|
//
|
|
string iName = dailyMiddleZone.GetTag();
|
|
bool isCreated = iObj.CreateByZone(
|
|
ChartIdentification(),
|
|
iName,
|
|
SubWindowIdentification(),
|
|
dailyMiddleZone,
|
|
NULL,
|
|
true //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
//
|
|
iObj.ZoneWidth(1);
|
|
iObj.ZoneColor(clrYellow);
|
|
iObj.ZoneStyle(STYLE_DASHDOT);
|
|
|
|
//
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Market Conditions ...
|
|
*/
|
|
void DrawMarketConditions()
|
|
{
|
|
//
|
|
bool tmpDraw = false;
|
|
|
|
//
|
|
bool drawSupplyZone = tmpDraw;
|
|
bool drawDemandZone = tmpDraw;
|
|
|
|
//
|
|
bool drawSupplyZones = tmpDraw;
|
|
bool drawDemandZones = tmpDraw;
|
|
|
|
//
|
|
bool drawBullishOrderBlock = tmpDraw;
|
|
bool drawBearishOrderBlock = tmpDraw;
|
|
|
|
//
|
|
bool drawBullishOrderBlocks = tmpDraw;
|
|
bool drawBearishOrderBlocks = tmpDraw;
|
|
|
|
//
|
|
bool drawBullishFVG = tmpDraw;
|
|
bool drawBearishFVG = tmpDraw;
|
|
|
|
//
|
|
bool drawBullishFVGs = tmpDraw;
|
|
bool drawBearishFVGs = tmpDraw;
|
|
|
|
//
|
|
bool drawBullishMomentumBar = tmpDraw;
|
|
bool drawBearishMomentumBar = tmpDraw;
|
|
|
|
//
|
|
bool drawBullishMomentumBars = tmpDraw;
|
|
bool drawBearishMomentumBars = tmpDraw;
|
|
|
|
//
|
|
bool drawBullishRejectionBar = tmpDraw;
|
|
bool drawBearishRejectionBar = tmpDraw;
|
|
|
|
//
|
|
bool drawBullishRejectionBars = tmpDraw;
|
|
bool drawBearishRejectionBars = tmpDraw;
|
|
|
|
//
|
|
bool drawSwingHigh = tmpDraw;
|
|
bool drawSwingLow = tmpDraw;
|
|
|
|
//
|
|
bool drawSwingHighs = tmpDraw;
|
|
bool drawSwingLows = tmpDraw;
|
|
|
|
//
|
|
bool drawSupport = tmpDraw;
|
|
bool drawResistance = tmpDraw;
|
|
|
|
//
|
|
bool drawSupports = tmpDraw;
|
|
bool drawResistances = tmpDraw;
|
|
|
|
//
|
|
int count = 0;
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
// Supply Zones ...
|
|
if (drawSupplyZone &&
|
|
mConditions.supplyZone.IsValid())
|
|
{
|
|
//
|
|
XCSupplyZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSupplyZone(
|
|
mConditions.supplyZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.supplyZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = mConditions.supplyZones[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawSupplyZones)
|
|
{
|
|
//
|
|
XCSupplyZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSupplyZone(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Demand Zones ....
|
|
if (drawDemandZone &&
|
|
mConditions.demandZone.IsValid())
|
|
{
|
|
//
|
|
XCDemandZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateDemandZone(
|
|
mConditions.demandZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.demandZones);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = mConditions.demandZones[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawDemandZones)
|
|
{
|
|
//
|
|
XCDemandZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateDemandZone(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bullish Order Blocks ....
|
|
if (drawBullishOrderBlock &&
|
|
mConditions.bullishOrderBlock.IsValid())
|
|
{
|
|
//
|
|
XCBullishOrderBlockObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishOrderBlock(
|
|
mConditions.bullishOrderBlock,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.bullishOrderBlocks);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = mConditions.bullishOrderBlocks[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawBullishOrderBlocks)
|
|
{
|
|
//
|
|
XCBullishOrderBlockObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishOrderBlock(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Order Blocks ....
|
|
if (drawBearishOrderBlock &&
|
|
mConditions.bearishOrderBlock.IsValid())
|
|
{
|
|
//
|
|
XCBearishOrderBlockObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishOrderBlock(
|
|
mConditions.bearishOrderBlock,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.bearishOrderBlocks);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = mConditions.bearishOrderBlocks[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawBearishOrderBlocks)
|
|
{
|
|
//
|
|
XCBearishOrderBlockObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishOrderBlock(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bullish Fair Value Gaps ....
|
|
if (drawBullishFVG &&
|
|
mConditions.bullishFVG.IsValid())
|
|
{
|
|
//
|
|
XCBullishFVGObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishFVG(
|
|
mConditions.bullishFVG,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.bullishFVGs);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = mConditions.bullishFVGs[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawBullishFVGs)
|
|
{
|
|
//
|
|
XCBullishFVGObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishFVG(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Fair Value Gaps ....
|
|
if (drawBearishFVG &&
|
|
mConditions.bearishFVG.IsValid())
|
|
{
|
|
//
|
|
XCBearishFVGObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishFVG(
|
|
mConditions.bearishFVG,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.bearishFVGs);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = mConditions.bearishFVGs[i];
|
|
iZone.to = cTime;
|
|
|
|
//
|
|
if (drawBullishFVGs)
|
|
{
|
|
//
|
|
XCBearishFVGObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishFVG(
|
|
iZone,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bullish Momentum Bar ....
|
|
if (drawBullishMomentumBar &&
|
|
mConditions.bullishMomentumBar.IsValid())
|
|
{
|
|
//
|
|
XCBullishMomentumBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishMomentumBar(
|
|
mConditions.bullishMomentumBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.bullishMomentumBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mConditions.bullishMomentumBars[i];
|
|
|
|
//
|
|
if (drawBullishMomentumBars)
|
|
{
|
|
//
|
|
XCBullishMomentumBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishMomentumBar(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Momentum Bar ....
|
|
if (drawBearishMomentumBar &&
|
|
mConditions.bearishMomentumBar.IsValid())
|
|
{
|
|
//
|
|
XCBearishMomentumBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishMomentumBar(
|
|
mConditions.bearishMomentumBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.bearishMomentumBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mConditions.bearishMomentumBars[i];
|
|
|
|
//
|
|
if (drawBearishMomentumBars)
|
|
{
|
|
//
|
|
XCBearishMomentumBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishMomentumBar(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bullish Rejection Bars ...
|
|
if (drawBullishRejectionBars &&
|
|
mConditions.bullishRejectionBar.IsValid())
|
|
{
|
|
//
|
|
XCBullishRejectionBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishRejectionBar(
|
|
mConditions.bullishRejectionBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.bullishRejectionBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mConditions.bullishRejectionBars[i];
|
|
|
|
//
|
|
if (drawBullishRejectionBars)
|
|
{
|
|
//
|
|
XCBullishRejectionBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBullishRejectionBar(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Rejection Bars ...
|
|
if (drawBearishRejectionBars &&
|
|
mConditions.bearishRejectionBar.IsValid())
|
|
{
|
|
//
|
|
XCBearishRejectionBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishRejectionBar(
|
|
mConditions.bearishRejectionBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.bearishRejectionBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mConditions.bearishRejectionBars[i];
|
|
|
|
//
|
|
if (drawBearishRejectionBars)
|
|
{
|
|
//
|
|
XCBearishRejectionBarObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateBearishRejectionBar(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Highs ....
|
|
if (drawSwingHigh &&
|
|
mConditions.swingHigh.IsValid())
|
|
{
|
|
//
|
|
XCSwingHighObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSwingHigh(
|
|
mConditions.swingHigh,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.swingHighs);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mConditions.swingHighs[i];
|
|
|
|
//
|
|
if (drawSwingHighs)
|
|
{
|
|
//
|
|
XCSwingHighObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSwingHigh(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Lows ....
|
|
if (drawSwingLow &&
|
|
mConditions.swingLow.IsValid())
|
|
{
|
|
//
|
|
XCSwingLowObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSwingLow(
|
|
mConditions.swingLow,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.swingLows);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mConditions.swingLows[i];
|
|
|
|
//
|
|
if (drawSwingLows)
|
|
{
|
|
//
|
|
XCSwingLowObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSwingLow(
|
|
iBar,
|
|
iObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Supports ....
|
|
if (drawSupport &&
|
|
mConditions.support.IsValid())
|
|
{
|
|
//
|
|
XCSupportZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSupportZone(
|
|
mConditions.support,
|
|
iObj,
|
|
cTime //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.supports);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mConditions.supports[i];
|
|
|
|
//
|
|
if (drawSupports)
|
|
{
|
|
//
|
|
XCSupportZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateSupportZone(
|
|
iBar,
|
|
iObj,
|
|
cTime //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistances ....
|
|
if (drawResistance &&
|
|
mConditions.resistance.IsValid())
|
|
{
|
|
//
|
|
XCResistanceZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
|
mConditions.resistance,
|
|
iObj,
|
|
cTime //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
count = ArraySize(mConditions.resistances);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mConditions.resistances[i];
|
|
|
|
//
|
|
if (drawResistances)
|
|
{
|
|
//
|
|
XCResistanceZoneObject *iObj;
|
|
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
|
iBar,
|
|
iObj,
|
|
cTime //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
bool DetectBar()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
int ppIndex = pIndex + 1;
|
|
|
|
//
|
|
int loopback = 7;
|
|
int dest = cIndex + loopback;
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
// 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;
|
|
}
|
|
|
|
//
|
|
// Commons ...
|
|
|
|
//
|
|
bool hasExtendedRange = mBarAnalyser.HasExtendedRange(
|
|
cBar,
|
|
3 //
|
|
);
|
|
|
|
//
|
|
bool hasExtendedBody = mBarAnalyser.HasExtendedBody(
|
|
cBar,
|
|
3 //
|
|
);
|
|
|
|
//
|
|
bool isExtendedOr = hasExtendedBody ||
|
|
hasExtendedRange;
|
|
|
|
//
|
|
bool isExtended = mBarAnalyser.IsExtended(
|
|
cBar,
|
|
3 //
|
|
);
|
|
|
|
if (isExtended)
|
|
{
|
|
Print("Bar is Extended ...");
|
|
}
|
|
|
|
//
|
|
// Rejection ...
|
|
|
|
//
|
|
bool isBullishRejectionBar = mBarAnalyser.IsBullishRejectionBar(
|
|
cBar,
|
|
40 //
|
|
);
|
|
|
|
//
|
|
bool isBearishRejectionBar = mBarAnalyser.IsBearishRejectionBar(
|
|
cBar,
|
|
40 //
|
|
);
|
|
|
|
//
|
|
result = isBullishRejectionBar ||
|
|
isBearishRejectionBar;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
Print("Result RejectionBar: ", result);
|
|
}
|
|
|
|
//
|
|
// Momentum ...
|
|
|
|
//
|
|
bool isBullishMomentumBar = mBarAnalyser.IsBullishMomentumBar(
|
|
cBar,
|
|
50 //
|
|
);
|
|
|
|
//
|
|
bool isBearishMomentumBar = mBarAnalyser.IsBearishMomentumBar(
|
|
cBar,
|
|
50 //
|
|
);
|
|
|
|
//
|
|
result = isBullishMomentumBar ||
|
|
isBearishMomentumBar;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
Print("Result MomentumBar: ", result);
|
|
}
|
|
|
|
//
|
|
// Engulfing ...
|
|
|
|
//
|
|
bool isBullishEngulfed = mBarAnalyser.IsBullishEngulfed(
|
|
cBar,
|
|
2 //
|
|
);
|
|
|
|
//
|
|
bool isBearishEngulfed = mBarAnalyser.IsBearishEngulfed(
|
|
cBar,
|
|
2 //
|
|
);
|
|
|
|
//
|
|
result = isBullishEngulfed ||
|
|
isBearishEngulfed;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
Print("Engulfed: ", result);
|
|
}
|
|
|
|
//
|
|
bool hasBullishCHOCH = mBarAnalyser.HasBullishCHOCH(
|
|
cBar,
|
|
3,
|
|
false // Force BODY ...
|
|
);
|
|
|
|
//
|
|
bool hasBearishCHOCH = mBarAnalyser.HasBearishCHOCH(
|
|
cBar,
|
|
3,
|
|
false // Force BODY ...
|
|
);
|
|
|
|
//
|
|
result = hasBullishCHOCH ||
|
|
hasBearishCHOCH;
|
|
if (result)
|
|
{
|
|
Print("CHOCH Happens ...");
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
// |