1725 lines
39 KiB
Plaintext
1725 lines
39 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 X121 SMC Signal Class
|
|
// -------------------------------------------------
|
|
// Name: X
|
|
// Description: provide all Signalling functions ...
|
|
//
|
|
//
|
|
// 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 "../../Libraries/x-trade.lib"
|
|
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
|
#include "../Libraries/x-121.smc.lib.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
struct X121SMCStrategyXOBPVSignalConditions
|
|
{
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
string symbol;
|
|
ENUM_TIMEFRAMES period;
|
|
|
|
//
|
|
double sl;
|
|
double target;
|
|
ENUM_X_DIRECTION dir;
|
|
ENUM_X_POSITION_TYPES type;
|
|
|
|
//
|
|
// Setup Props ...
|
|
|
|
//
|
|
datetime setupTime;
|
|
datetime triggerTime;
|
|
|
|
//
|
|
double pivot;
|
|
double point;
|
|
|
|
//
|
|
XCOrderBlock *bullishOBs[];
|
|
XCOrderBlock *bearishOBs[];
|
|
|
|
//
|
|
// Constructor ...
|
|
X121SMCStrategyXOBPVSignalConditions()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
/**
|
|
* Cleaning Up ...
|
|
*/
|
|
void Clean()
|
|
{
|
|
//
|
|
sl = 0;
|
|
target = 0;
|
|
|
|
//
|
|
dir = X_DIRECTION_NONE;
|
|
type = X_POSITION_TYPE_NONE;
|
|
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
setupTime = NULL;
|
|
triggerTime = NULL;
|
|
|
|
//
|
|
ExtensionClean();
|
|
}
|
|
|
|
/**
|
|
* Check Condition is Setting Up ...
|
|
*
|
|
* @param dir: ENUM_X_DIRECTION member, Setting Up Direction ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool IsSetuped()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = IsValid(setupTime) &&
|
|
HasDirection(dir);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Calculate Setup Age ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int GetSetupAge()
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
if (!IsSetuped())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = (int)(TimeCurrent() - setupTime) / PeriodSeconds(period);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Detect How we Can Trigger Signal ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool CanTrigger()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
sl > 0 &&
|
|
IsValid(symbol) &&
|
|
IsValid(period) &&
|
|
IsValid(triggerTime) &&
|
|
type != X_POSITION_TYPE_ALL &&
|
|
type != X_POSITION_TYPE_NONE
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Extensions ...
|
|
|
|
/**
|
|
* Clean Additional Properties ...
|
|
*/
|
|
void ExtensionClean()
|
|
{
|
|
//
|
|
pivot = 0;
|
|
point = 0;
|
|
|
|
//
|
|
Clean(bullishOBs);
|
|
Clean(bearishOBs);
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
int CountBullishOBs()
|
|
{
|
|
return ArraySize(bullishOBs);
|
|
}
|
|
|
|
//
|
|
bool HasBullishOBs()
|
|
{
|
|
return IsValidSize(CountBullishOBs());
|
|
}
|
|
|
|
//
|
|
int CountBearishOBs()
|
|
{
|
|
return ArraySize(bearishOBs);
|
|
}
|
|
|
|
//
|
|
bool HasBearishOBs()
|
|
{
|
|
return IsValidSize(CountBearishOBs());
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// Signaller Data Sources ...
|
|
X121SMCStrategyXOBPVSignalConditions mXOBPVConditions;
|
|
X121SMCStrategyXOBPVSignalConditions mXOBPVConditionsCollection[];
|
|
|
|
//
|
|
// Extension Functions ...
|
|
|
|
//
|
|
// Detect Setup Conditions ...
|
|
bool DetectX121SMCXOBPVSignalSetup(
|
|
string _symbol,
|
|
ENUM_TIMEFRAMES _period,
|
|
//
|
|
X121SMCStrategyXOBPVSignalConditions &conditions,
|
|
//
|
|
XC121SMCCycleHelper *triggerCycleHelper,
|
|
XC121SMCCycleHelper *decisionCycleHelper,
|
|
XC121SMCCycleHelper *analyseCycleHelper,
|
|
XC121SMCCycleHelper *verificationCycleHelper,
|
|
XC121SMCCycleHelper *consolidationCycleHelper,
|
|
XC121SMCCycleHelper *visionCycleHelper
|
|
//
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
bool isBullish = false;
|
|
bool isBearish = false;
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
int ppIndex = pIndex + 1;
|
|
|
|
//
|
|
int loopback = 10;
|
|
|
|
//
|
|
string symbol = _symbol;
|
|
ENUM_TIMEFRAMES period = _period;
|
|
|
|
//
|
|
conditions.symbol = symbol;
|
|
conditions.period = period;
|
|
|
|
//
|
|
XOHCL zBar;
|
|
result = decisionCycleHelper.GetBar(
|
|
zBar,
|
|
zIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL cBar;
|
|
result = decisionCycleHelper.GetBar(
|
|
cBar,
|
|
cIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL pBar;
|
|
result = decisionCycleHelper.GetBar(
|
|
pBar,
|
|
pIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double ask = GetAsk(symbol);
|
|
double bid = GetBid(symbol);
|
|
datetime cTime = TimeCurrent();
|
|
double points = GetPoints(symbol);
|
|
|
|
//
|
|
int swingLoopback = 3;
|
|
double ll = cBar.FindLowest(swingLoopback, MODE_LOW);
|
|
double hh = cBar.FindHighest(swingLoopback, MODE_HIGH);
|
|
double llDown = cBar.FindLowesttDown(swingLoopback);
|
|
double hhUp = cBar.FindHighestUp(swingLoopback);
|
|
|
|
//
|
|
// Cycles Conditions ...
|
|
|
|
//
|
|
// Trigger ...
|
|
ENUM_XPOI_EVENTS triggerPoiEvents[];
|
|
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
|
|
X121SMCCycleConditions triggerConditions;
|
|
result = triggerCycleHelper.GetConditions(
|
|
triggerCycleEvents,
|
|
triggerPoiEvents,
|
|
triggerConditions,
|
|
zIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Decision ...
|
|
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
|
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
|
X121SMCCycleConditions decisionConditions;
|
|
result = decisionCycleHelper.GetConditions(
|
|
decisionCycleEvents,
|
|
decisionPoiEvents,
|
|
decisionConditions,
|
|
zIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Analyse ...
|
|
ENUM_XPOI_EVENTS analysePoiEvents[];
|
|
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
|
|
X121SMCCycleConditions analyseConditions;
|
|
result = analyseCycleHelper.GetConditions(
|
|
analyseCycleEvents,
|
|
analysePoiEvents,
|
|
analyseConditions,
|
|
zIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Verification ...
|
|
ENUM_XPOI_EVENTS verificationPoiEvents[];
|
|
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
|
|
X121SMCCycleConditions verificationConditions;
|
|
result = verificationCycleHelper.GetConditions(
|
|
verificationCycleEvents,
|
|
verificationPoiEvents,
|
|
verificationConditions,
|
|
zIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Consolidation ...
|
|
ENUM_XPOI_EVENTS consolidationPoiEvents[];
|
|
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
|
|
X121SMCCycleConditions consolidationConditions;
|
|
result = consolidationCycleHelper.GetConditions(
|
|
consolidationCycleEvents,
|
|
consolidationPoiEvents,
|
|
consolidationConditions,
|
|
zIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Vision ...
|
|
ENUM_XPOI_EVENTS visionPoiEvents[];
|
|
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
|
|
X121SMCCycleConditions visionConditions;
|
|
result = visionCycleHelper.GetConditions(
|
|
visionCycleEvents,
|
|
visionPoiEvents,
|
|
visionConditions,
|
|
zIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Cycles POI States ...
|
|
XPOIState triggerState = triggerConditions.state;
|
|
XPOIState decisionState = decisionConditions.state;
|
|
XPOIState analyseState = analyseConditions.state;
|
|
XPOIState verificationState = verificationConditions.state;
|
|
XPOIState consolidationState = consolidationConditions.state;
|
|
XPOIState visionState = visionConditions.state;
|
|
|
|
//
|
|
// Cycle X121Conditions ...
|
|
X121Conditions triggerXOBPVConditions = triggerConditions.x121Conditions;
|
|
X121Conditions decisionXOBPVConditions = decisionConditions.x121Conditions;
|
|
X121Conditions analyseXOBPVConditions = analyseConditions.x121Conditions;
|
|
X121Conditions verificationXOBPVConditions = verificationConditions.x121Conditions;
|
|
X121Conditions consolidationXOBPVConditions = consolidationConditions.x121Conditions;
|
|
X121Conditions visionXOBPVConditions = visionConditions.x121Conditions;
|
|
|
|
//
|
|
// Setup Conditions ...
|
|
|
|
//
|
|
// Detect Trend ...
|
|
|
|
//
|
|
// Consolidation ...
|
|
ENUM_X_DIRECTION consolidationTrendDir;
|
|
bool hasConsolidationTrend =
|
|
consolidationCycleHelper
|
|
.DetectMarketStructure(
|
|
consolidationTrendDir //
|
|
);
|
|
bool hasConsolidationBullishTrend =
|
|
hasConsolidationTrend &&
|
|
IsBullish(consolidationTrendDir);
|
|
bool hasConsolidationBearishTrend =
|
|
hasConsolidationTrend &&
|
|
IsBearish(consolidationTrendDir);
|
|
|
|
//
|
|
// Verification ...
|
|
ENUM_X_DIRECTION verificationTrendDir;
|
|
bool hasVerificationTrend =
|
|
verificationCycleHelper
|
|
.DetectMarketStructure(
|
|
verificationTrendDir //
|
|
);
|
|
bool hasVerificationBullishTrend =
|
|
hasVerificationTrend &&
|
|
IsBullish(verificationTrendDir);
|
|
bool hasVerificationBearishTrend =
|
|
hasVerificationTrend &&
|
|
IsBearish(verificationTrendDir);
|
|
|
|
//
|
|
// Analyse ...
|
|
ENUM_X_DIRECTION analyseTrendDir;
|
|
bool hasAnalyseTrend =
|
|
analyseCycleHelper
|
|
.DetectMarketStructure(
|
|
analyseTrendDir //
|
|
);
|
|
bool hasAnalyseBullishTrend =
|
|
hasAnalyseTrend &&
|
|
IsBullish(analyseTrendDir);
|
|
bool hasAnalyseBearishTrend =
|
|
hasAnalyseTrend &&
|
|
IsBearish(analyseTrendDir);
|
|
|
|
//
|
|
// Decision ...
|
|
ENUM_X_DIRECTION decisionTrendDir;
|
|
bool hasDecisionTrend =
|
|
decisionCycleHelper
|
|
.DetectMarketStructure(
|
|
decisionTrendDir //
|
|
);
|
|
bool hasDecisionBullishTrend =
|
|
hasDecisionTrend &&
|
|
IsBullish(decisionTrendDir);
|
|
bool hasDecisionBearishTrend =
|
|
hasDecisionTrend &&
|
|
IsBearish(decisionTrendDir);
|
|
|
|
//
|
|
// Detect Bar State ...
|
|
|
|
//
|
|
// PinBar ...
|
|
ENUM_X_DIRECTION cBarPinDir;
|
|
bool isCBarPin = decisionCycleHelper
|
|
.mBarAnalyser
|
|
.IsPinBar(
|
|
cBar,
|
|
cBarPinDir,
|
|
1 //
|
|
);
|
|
bool isCBarBullishPin =
|
|
isCBarPin &&
|
|
IsBullish(cBarPinDir);
|
|
bool isCBarBearishPin =
|
|
isCBarPin &&
|
|
IsBearish(cBarPinDir);
|
|
|
|
//
|
|
// Engulf ...
|
|
ENUM_X_DIRECTION cBarEngulfDir;
|
|
bool isCBarEngulfed = decisionCycleHelper
|
|
.mBarAnalyser
|
|
.IsEngulfBar(
|
|
cBar,
|
|
cBarEngulfDir,
|
|
0 // Extended ...
|
|
);
|
|
bool isCBarBullishEngulfed =
|
|
isCBarEngulfed &&
|
|
IsBullish(cBarEngulfDir);
|
|
bool isCBarBearishEngulfed =
|
|
isCBarEngulfed &&
|
|
IsBearish(cBarEngulfDir);
|
|
|
|
//
|
|
// Momentum ...
|
|
ENUM_X_DIRECTION cBarMomentumDir;
|
|
bool isCBarMomentum = decisionCycleHelper
|
|
.mBarAnalyser
|
|
.IsMomentumBar(
|
|
cBar,
|
|
cBarMomentumDir,
|
|
0 // Extended ...
|
|
);
|
|
bool isCBarBullishMomentum =
|
|
isCBarMomentum &&
|
|
IsBullish(cBarMomentumDir);
|
|
bool isCBarBearishMomentum =
|
|
isCBarMomentum &&
|
|
IsBearish(cBarMomentumDir);
|
|
|
|
//
|
|
// Reject ...
|
|
ENUM_X_DIRECTION cBarRejectDir;
|
|
bool isCBarRejected = decisionCycleHelper
|
|
.mBarAnalyser
|
|
.IsRejectionBar(
|
|
cBar,
|
|
cBarRejectDir,
|
|
0 // Extended ...
|
|
);
|
|
bool isCBarBullishRejected =
|
|
isCBarRejected &&
|
|
IsBullish(cBarRejectDir);
|
|
bool isCBarBearishRejected =
|
|
isCBarRejected &&
|
|
IsBearish(cBarRejectDir);
|
|
|
|
//
|
|
// Pull Back ...
|
|
ENUM_X_DIRECTION cBarPullbackDir;
|
|
bool isCBarPullbacked =
|
|
decisionCycleHelper
|
|
.mBarAnalyser
|
|
.HasPullBack(
|
|
cBarPullbackDir,
|
|
cBar //
|
|
);
|
|
bool isCBarBullishPullbacked =
|
|
isCBarPullbacked &&
|
|
IsBullish(cBarPullbackDir);
|
|
bool isCBarBearishPullbacked =
|
|
isCBarPullbacked &&
|
|
IsBearish(cBarPullbackDir);
|
|
|
|
//
|
|
// HH/LL Break ...
|
|
|
|
//
|
|
bool isCBarBreaksUpHH = IsBarBreak(
|
|
hh,
|
|
X_DIRECTION_BULLISH,
|
|
cBar //
|
|
);
|
|
|
|
//
|
|
bool isCBarBreaksDownLL = IsBarBreak(
|
|
hh,
|
|
X_DIRECTION_BEARISH,
|
|
cBar //
|
|
);
|
|
|
|
//
|
|
// Bars Pattern and Power and Pressures ...
|
|
|
|
//
|
|
bool hasCBarBullishPattern =
|
|
decisionCycleHelper
|
|
.mBarAnalyser
|
|
.HasBullishPattern(
|
|
cBar,
|
|
2 //
|
|
);
|
|
|
|
//
|
|
bool hasCBarBearishPattern =
|
|
decisionCycleHelper
|
|
.mBarAnalyser
|
|
.HasBearishPattern(
|
|
cBar,
|
|
2 //
|
|
);
|
|
|
|
//
|
|
bool isCBarHasBullishPower =
|
|
decisionCycleHelper
|
|
.mBarAnalyser
|
|
.HasBullishPower(
|
|
cBar,
|
|
2 //
|
|
);
|
|
|
|
//
|
|
bool isCBarHasBearishPower =
|
|
decisionCycleHelper
|
|
.mBarAnalyser
|
|
.HasBearishPower(
|
|
cBar,
|
|
2 //
|
|
);
|
|
|
|
//
|
|
bool isCBarHasBullishPressure =
|
|
decisionCycleHelper
|
|
.mBarAnalyser
|
|
.HasBullishPressure(
|
|
cBar,
|
|
2 //
|
|
);
|
|
|
|
//
|
|
bool isCBarHasBearishPressure =
|
|
decisionCycleHelper
|
|
.mBarAnalyser
|
|
.HasBearishPressure(
|
|
cBar,
|
|
2 //
|
|
);
|
|
|
|
//
|
|
// Bar Checking Summary ...
|
|
|
|
//
|
|
// Bullish ...
|
|
bool isCBarBullishFormed =
|
|
//
|
|
(
|
|
//
|
|
hasCBarBullishPattern &&
|
|
isCBarHasBullishPower &&
|
|
isCBarHasBullishPressure
|
|
//
|
|
)
|
|
//
|
|
||
|
|
//
|
|
(
|
|
//
|
|
isCBarBullishPin ||
|
|
isCBarBreaksUpHH ||
|
|
isCBarBullishEngulfed ||
|
|
isCBarBullishMomentum ||
|
|
isCBarBullishRejected
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Bearish ...
|
|
bool isCBarBearishFormed =
|
|
//
|
|
(
|
|
//
|
|
hasCBarBearishPattern &&
|
|
isCBarHasBearishPower &&
|
|
isCBarHasBearishPressure
|
|
//
|
|
)
|
|
//
|
|
||
|
|
//
|
|
(
|
|
//
|
|
isCBarBearishPin ||
|
|
isCBarBreaksDownLL ||
|
|
isCBarBearishEngulfed ||
|
|
isCBarBearishMomentum ||
|
|
isCBarBearishRejected
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Detect Order Block ...
|
|
|
|
//
|
|
bool hasBullishOrderBlocks = conditions.HasBullishOBs();
|
|
int bullishOrderBlocksCount = conditions.CountBullishOBs();
|
|
|
|
//
|
|
bool hasBearishOrderBlocks = conditions.HasBearishOBs();
|
|
int bearishOrderBlocksCount = conditions.CountBearishOBs();
|
|
|
|
//
|
|
bool hasOrderBlocks = hasBullishOrderBlocks &&
|
|
hasBearishOrderBlocks;
|
|
if (!hasOrderBlocks)
|
|
{
|
|
//
|
|
XCOrderBlock *bullishOBs[];
|
|
XCOrderBlock *bearishOBs[];
|
|
bool hasOrderBlocks = visionCycleHelper.DetectOrderBlocks(
|
|
bullishOBs,
|
|
bearishOBs //
|
|
);
|
|
|
|
//
|
|
if (!hasBullishOrderBlocks)
|
|
{
|
|
//
|
|
Copy(
|
|
bullishOBs,
|
|
conditions.bullishOBs //
|
|
);
|
|
}
|
|
|
|
//
|
|
if (!hasBearishOrderBlocks)
|
|
{
|
|
//
|
|
Copy(
|
|
bearishOBs,
|
|
conditions.bearishOBs //
|
|
);
|
|
}
|
|
|
|
//
|
|
hasBullishOrderBlocks = conditions.HasBullishOBs();
|
|
bullishOrderBlocksCount = conditions.CountBullishOBs();
|
|
|
|
//
|
|
hasBearishOrderBlocks = conditions.HasBearishOBs();
|
|
bearishOrderBlocksCount = conditions.CountBearishOBs();
|
|
}
|
|
|
|
//
|
|
bool hasOldestBullishOB = false;
|
|
bool hasYoungestBullishOB = false;
|
|
XCOrderBlock *oldestBullishOB = NULL;
|
|
XCOrderBlock *youngestBullishOB = NULL;
|
|
if (hasBullishOrderBlocks)
|
|
{
|
|
//
|
|
XCZone *zones[];
|
|
bool isConverted = ToZone(
|
|
conditions.bullishOBs,
|
|
zones //
|
|
);
|
|
|
|
//
|
|
int oldestIDX = GetOldest(zones);
|
|
hasOldestBullishOB = IsValidIndex(oldestIDX);
|
|
if (hasOldestBullishOB)
|
|
{
|
|
oldestBullishOB = conditions.bullishOBs[oldestIDX];
|
|
}
|
|
|
|
//
|
|
int youngestIDX = GetYoungest(zones);
|
|
hasYoungestBullishOB = IsValidIndex(youngestIDX);
|
|
if (hasYoungestBullishOB)
|
|
{
|
|
youngestBullishOB = conditions.bullishOBs[youngestIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
bool hasOldestBearishOB = false;
|
|
bool hasYoungestBearishOB = false;
|
|
XCOrderBlock *oldestBearishOB = NULL;
|
|
XCOrderBlock *youngestBearishOB = NULL;
|
|
if (hasBearishOrderBlocks)
|
|
{
|
|
//
|
|
XCZone *zones[];
|
|
bool isConverted = ToZone(
|
|
conditions.bearishOBs,
|
|
zones //
|
|
);
|
|
|
|
//
|
|
int oldestIDX = GetOldest(zones);
|
|
hasOldestBearishOB = IsValidIndex(oldestIDX);
|
|
if (hasOldestBearishOB)
|
|
{
|
|
oldestBearishOB = conditions.bearishOBs[oldestIDX];
|
|
}
|
|
|
|
//
|
|
int youngestIDX = GetYoungest(zones);
|
|
hasYoungestBearishOB = IsValidIndex(youngestIDX);
|
|
if (hasYoungestBearishOB)
|
|
{
|
|
youngestBearishOB = conditions.bearishOBs[youngestIDX];
|
|
}
|
|
}
|
|
|
|
//
|
|
bool hasPriceInsideOB = false;
|
|
XCOrderBlock *priceInsideOB = NULL;
|
|
|
|
//
|
|
if (!hasPriceInsideOB &&
|
|
hasBullishOrderBlocks)
|
|
{
|
|
//
|
|
for (int i = 0; i < bullishOrderBlocksCount; i++)
|
|
{
|
|
//
|
|
XCOrderBlock *iOb = conditions.bullishOBs[i];
|
|
|
|
//
|
|
bool isInside = IsPriceInsideZone(
|
|
decisionXOBPVConditions.valesBuffer[1],
|
|
(XCZone *)iOb //
|
|
);
|
|
if (isInside)
|
|
{
|
|
//
|
|
hasPriceInsideOB = true;
|
|
priceInsideOB = iOb;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (!hasPriceInsideOB &&
|
|
hasBearishOrderBlocks)
|
|
{
|
|
//
|
|
for (int i = 0; i < bearishOrderBlocksCount; i++)
|
|
{
|
|
//
|
|
XCOrderBlock *iOb = conditions.bearishOBs[i];
|
|
|
|
//
|
|
bool isInside = IsPriceInsideZone(
|
|
decisionXOBPVConditions.peaksBuffer[1],
|
|
(XCZone *)iOb //
|
|
);
|
|
if (isInside)
|
|
{
|
|
//
|
|
hasPriceInsideOB = true;
|
|
priceInsideOB = iOb;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
XStateZones obState;
|
|
bool hasOBState = false;
|
|
XOHCL priceInsideOBBreakerBar;
|
|
if (hasPriceInsideOB)
|
|
{
|
|
//
|
|
XOHCL toBar;
|
|
XOHCL fromBar;
|
|
ENUM_X_DIRECTION forDir =
|
|
priceInsideOB.IsBullish()
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
bool hasBreakerBar = HasBreakerBar(
|
|
toBar,
|
|
fromBar,
|
|
priceInsideOBBreakerBar,
|
|
forDir,
|
|
priceInsideOB.GetSymbol(),
|
|
priceInsideOB.GetPeriod(),
|
|
(XCZone *)priceInsideOB //
|
|
);
|
|
if (hasBreakerBar)
|
|
{
|
|
//
|
|
CalculateStateZones(
|
|
obState,
|
|
consolidationState,
|
|
priceInsideOB.Upper(),
|
|
priceInsideOB.Lower(),
|
|
priceInsideOBBreakerBar.time //
|
|
);
|
|
}
|
|
|
|
//
|
|
hasOBState = obState.IsValid();
|
|
}
|
|
|
|
//
|
|
bool isSameCyclesPeak =
|
|
//
|
|
triggerXOBPVConditions.peaksBuffer[1] == decisionXOBPVConditions.peaksBuffer[1] &&
|
|
decisionXOBPVConditions.peaksBuffer[1] == analyseXOBPVConditions.peaksBuffer[1] &&
|
|
analyseXOBPVConditions.peaksBuffer[1] == verificationXOBPVConditions.peaksBuffer[1] &&
|
|
verificationXOBPVConditions.peaksBuffer[1] == consolidationXOBPVConditions.peaksBuffer[1]
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isSameCyclesVale =
|
|
//
|
|
triggerXOBPVConditions.valesBuffer[1] == decisionXOBPVConditions.valesBuffer[1] &&
|
|
decisionXOBPVConditions.valesBuffer[1] == analyseXOBPVConditions.valesBuffer[1] &&
|
|
analyseXOBPVConditions.valesBuffer[1] == verificationXOBPVConditions.valesBuffer[1] &&
|
|
verificationXOBPVConditions.valesBuffer[1] == consolidationXOBPVConditions.valesBuffer[1]
|
|
//
|
|
;
|
|
|
|
//
|
|
bool hasSameCyclesPV =
|
|
hasOBState &&
|
|
hasPriceInsideOB &&
|
|
(isSameCyclesPeak ||
|
|
isSameCyclesVale);
|
|
|
|
//
|
|
// DRAW ...
|
|
//
|
|
|
|
//
|
|
XCBaseObject *drawnObjects[];
|
|
|
|
//
|
|
if (hasBullishOrderBlocks)
|
|
{
|
|
//
|
|
for (int i = 0; i < bullishOrderBlocksCount; i++)
|
|
{
|
|
//
|
|
XCOrderBlock *iOb = conditions.bullishOBs[i];
|
|
|
|
//
|
|
XCBullishOrderBlockObject *iObObj;
|
|
bool isCreated = visionCycleHelper
|
|
.mPOIDrawer
|
|
.CreateBullishOrderBlock(
|
|
iOb,
|
|
iObObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
//
|
|
Add(
|
|
(XCBaseObject *)iObObj,
|
|
drawnObjects //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (hasBearishOrderBlocks)
|
|
{
|
|
//
|
|
for (int i = 0; i < bearishOrderBlocksCount; i++)
|
|
{
|
|
//
|
|
XCOrderBlock *iOb = conditions.bearishOBs[i];
|
|
|
|
//
|
|
XCBearishOrderBlockObject *iObObj;
|
|
bool isCreated = visionCycleHelper
|
|
.mPOIDrawer
|
|
.CreateBearishOrderBlock(
|
|
iOb,
|
|
iObObj //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
//
|
|
Add(
|
|
(XCBaseObject *)iObObj,
|
|
drawnObjects //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// if (hasOldestBullishOB)
|
|
// {
|
|
// //
|
|
// XCBullishOrderBlockObject *iObj;
|
|
// bool isCreated = visionCycleHelper
|
|
// .mPOIDrawer
|
|
// .CreateBullishOrderBlock(
|
|
// oldestBullishOB,
|
|
// iObj //
|
|
// );
|
|
// if (isCreated)
|
|
// {
|
|
// }
|
|
// }
|
|
|
|
// //
|
|
// if (hasYoungestBullishOB)
|
|
// {
|
|
// //
|
|
// XCBullishOrderBlockObject *iObj;
|
|
// bool isCreated = visionCycleHelper
|
|
// .mPOIDrawer
|
|
// .CreateBullishOrderBlock(
|
|
// youngestBullishOB,
|
|
// iObj //
|
|
// );
|
|
// if (isCreated)
|
|
// {
|
|
// }
|
|
// }
|
|
|
|
// //
|
|
// if (hasOldestBearishOB)
|
|
// {
|
|
// //
|
|
// XCBearishOrderBlockObject *iObj;
|
|
// bool isCreated = visionCycleHelper
|
|
// .mPOIDrawer
|
|
// .CreateBearishOrderBlock(
|
|
// oldestBearishOB,
|
|
// iObj //
|
|
// );
|
|
// if (isCreated)
|
|
// {
|
|
// }
|
|
// }
|
|
|
|
// //
|
|
// if (hasYoungestBearishOB)
|
|
// {
|
|
// //
|
|
// XCBearishOrderBlockObject *iObj;
|
|
// bool isCreated = visionCycleHelper
|
|
// .mPOIDrawer
|
|
// .CreateBearishOrderBlock(
|
|
// youngestBearishOB,
|
|
// iObj //
|
|
// );
|
|
// if (isCreated)
|
|
// {
|
|
// }
|
|
// }
|
|
|
|
//
|
|
if (hasPriceInsideOB)
|
|
{
|
|
//
|
|
bool isBullish = priceInsideOB.IsBullish();
|
|
|
|
//
|
|
bool isCreated = false;
|
|
XCBaseObject *iObObj = NULL;
|
|
if (isBullish)
|
|
{
|
|
//
|
|
XCBullishOrderBlockObject *iObj;
|
|
isCreated = visionCycleHelper
|
|
.mPOIDrawer
|
|
.CreateBullishOrderBlock(
|
|
priceInsideOB,
|
|
iObj //
|
|
);
|
|
|
|
//
|
|
if (isCreated)
|
|
{
|
|
//
|
|
iObj.ZoneColor(clrYellow);
|
|
iObObj = (XCBaseObject *)iObj;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
XCBearishOrderBlockObject *iObj;
|
|
isCreated = visionCycleHelper
|
|
.mPOIDrawer
|
|
.CreateBearishOrderBlock(
|
|
priceInsideOB,
|
|
iObj //
|
|
);
|
|
|
|
//
|
|
if (isCreated)
|
|
{
|
|
//
|
|
iObj.ZoneColor(clrOrangeRed);
|
|
iObObj = (XCBaseObject *)iObj;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isCreated)
|
|
{
|
|
//
|
|
Add(
|
|
iObObj,
|
|
drawnObjects //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (hasOBState)
|
|
{
|
|
//
|
|
XCBaseObject *stateObjects[];
|
|
int stateObjectsCount = consolidationCycleHelper
|
|
.mPOIDrawer
|
|
.DrawStateZones(
|
|
obState,
|
|
stateObjects //
|
|
);
|
|
if (IsValidSize(stateObjectsCount))
|
|
{
|
|
//
|
|
Copy(
|
|
stateObjects,
|
|
drawnObjects,
|
|
false //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
int drawnCount = ArraySize(drawnObjects);
|
|
if (IsValidSize(drawnCount))
|
|
{
|
|
}
|
|
|
|
//
|
|
//
|
|
//
|
|
|
|
//
|
|
// Summarize Conditions ...
|
|
|
|
//
|
|
bool isCondition1Bullish =
|
|
//
|
|
hasSameCyclesPV &&
|
|
isCBarBullishFormed &&
|
|
priceInsideOB.IsBullish() &&
|
|
//
|
|
(decisionXOBPVConditions.isBreakedUpPrevSar ||
|
|
decisionXOBPVConditions.isBreakedUpPrevStr ||
|
|
decisionXOBPVConditions.isVWapMaxBreakedUp ||
|
|
decisionXOBPVConditions.isBreakedUpPrevCheMax ||
|
|
decisionXOBPVConditions.isBreakedUpPrevAtrLower) &&
|
|
//
|
|
(decisionXOBPVConditions.isSarSwitchedToBullish ||
|
|
decisionXOBPVConditions.isStrSwitchedToBullish ||
|
|
decisionXOBPVConditions.isCheSwitchedToBullish ||
|
|
decisionXOBPVConditions.isVWapSwitchedToBullishState ||
|
|
decisionXOBPVConditions.isVWapSwitchedToBullishOrdered)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isCondition1Bearish =
|
|
//
|
|
hasSameCyclesPV &&
|
|
isCBarBearishFormed &&
|
|
priceInsideOB.IsBearish() &&
|
|
//
|
|
(decisionXOBPVConditions.isBreakedDownPrevSar ||
|
|
decisionXOBPVConditions.isBreakedDownPrevStr ||
|
|
decisionXOBPVConditions.isVWapMinBreakedDown ||
|
|
decisionXOBPVConditions.isBreakedDownPrevCheMin ||
|
|
decisionXOBPVConditions.isBreakedDownPrevAtrUpper) &&
|
|
//
|
|
(decisionXOBPVConditions.isSarSwitchedToBearish ||
|
|
decisionXOBPVConditions.isStrSwitchedToBearish ||
|
|
decisionXOBPVConditions.isCheSwitchedToBearish ||
|
|
decisionXOBPVConditions.isVWapSwitchedToBearishState ||
|
|
decisionXOBPVConditions.isVWapSwitchedToBearishOrdered)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool hasCondition1 = isCondition1Bullish ||
|
|
isCondition1Bearish;
|
|
if (hasCondition1)
|
|
{
|
|
//
|
|
ENUM_X_DIRECTION pzDir =
|
|
isCondition1Bullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
|
|
//
|
|
double point = GetEntry(
|
|
conditions.symbol,
|
|
pzDir //
|
|
);
|
|
|
|
//
|
|
// Manipulate Conditions Point ...
|
|
|
|
//
|
|
conditions.point = point;
|
|
|
|
//
|
|
// Manipulate Conditions Pivot ...
|
|
|
|
//
|
|
conditions.pivot =
|
|
isCondition1Bullish
|
|
? priceInsideOB.Upper()
|
|
: priceInsideOB.Lower();
|
|
}
|
|
|
|
//
|
|
//
|
|
//
|
|
|
|
//
|
|
isBullish =
|
|
//
|
|
isCondition1Bullish
|
|
//
|
|
;
|
|
|
|
//
|
|
isBearish =
|
|
//
|
|
isCondition1Bearish
|
|
//
|
|
;
|
|
|
|
//
|
|
result = isBullish ||
|
|
isBearish;
|
|
if (!result)
|
|
{
|
|
//
|
|
// Cleanup Arrays ...
|
|
ArrayFree(triggerPoiEvents);
|
|
ArrayFree(triggerCycleEvents);
|
|
ArrayFree(decisionPoiEvents);
|
|
ArrayFree(decisionCycleEvents);
|
|
ArrayFree(analysePoiEvents);
|
|
ArrayFree(analyseCycleEvents);
|
|
ArrayFree(verificationPoiEvents);
|
|
ArrayFree(verificationCycleEvents);
|
|
ArrayFree(consolidationPoiEvents);
|
|
ArrayFree(consolidationCycleEvents);
|
|
ArrayFree(visionPoiEvents);
|
|
ArrayFree(visionCycleEvents);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
conditions.setupTime = cTime;
|
|
conditions.dir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
|
|
//
|
|
// Cleanup Arrays ...
|
|
ArrayFree(triggerPoiEvents);
|
|
ArrayFree(triggerCycleEvents);
|
|
ArrayFree(decisionPoiEvents);
|
|
ArrayFree(decisionCycleEvents);
|
|
ArrayFree(analysePoiEvents);
|
|
ArrayFree(analyseCycleEvents);
|
|
ArrayFree(verificationPoiEvents);
|
|
ArrayFree(verificationCycleEvents);
|
|
ArrayFree(consolidationPoiEvents);
|
|
ArrayFree(consolidationCycleEvents);
|
|
ArrayFree(visionPoiEvents);
|
|
ArrayFree(visionCycleEvents);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Detect Trigger Conditions ...
|
|
bool DetectX121SMCXOBPVSignalTrigger(
|
|
//
|
|
X121SMCStrategyXOBPVSignalConditions &conditions,
|
|
//
|
|
string _symbol,
|
|
ENUM_TIMEFRAMES _period,
|
|
//
|
|
XC121SMCCycleHelper *triggerCycleHelper,
|
|
XC121SMCCycleHelper *decisionCycleHelper,
|
|
XC121SMCCycleHelper *analyseCycleHelper,
|
|
XC121SMCCycleHelper *verificationCycleHelper,
|
|
XC121SMCCycleHelper *consolidationCycleHelper,
|
|
XC121SMCCycleHelper *visionCycleHelper,
|
|
//
|
|
int maxAllowedSetupAge = 60 //
|
|
//
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = conditions.IsSetuped();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
datetime setupTime = conditions.setupTime;
|
|
ENUM_X_DIRECTION setupDir = conditions.dir;
|
|
|
|
//
|
|
bool isBullish = IsBullish(setupDir);
|
|
bool isBearish = IsBearish(setupDir);
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
int ppIndex = pIndex + 1;
|
|
|
|
//
|
|
int loopback = 10;
|
|
|
|
//
|
|
string symbol = _symbol;
|
|
ENUM_TIMEFRAMES period = _period;
|
|
|
|
//
|
|
XOHCL zBar;
|
|
result = decisionCycleHelper.GetBar(
|
|
zBar,
|
|
zIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL cBar;
|
|
result = decisionCycleHelper.GetBar(
|
|
cBar,
|
|
cIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL pBar;
|
|
result = decisionCycleHelper.GetBar(
|
|
pBar,
|
|
pIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double ask = GetAsk(symbol);
|
|
double bid = GetBid(symbol);
|
|
datetime cTime = TimeCurrent();
|
|
double points = GetPoints(symbol);
|
|
|
|
//
|
|
int swingLoopback = 9;
|
|
double ll = cBar.FindLowest(swingLoopback, MODE_LOW);
|
|
double hh = cBar.FindHighest(swingLoopback, MODE_HIGH);
|
|
double llDown = cBar.FindLowesttDown(swingLoopback);
|
|
double hhUp = cBar.FindHighestUp(swingLoopback);
|
|
|
|
//
|
|
// Cycles Conditions ...
|
|
|
|
//
|
|
// Decision ...
|
|
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
|
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
|
X121SMCCycleConditions decisionConditions;
|
|
result = decisionCycleHelper.GetConditions(
|
|
decisionCycleEvents,
|
|
decisionPoiEvents,
|
|
decisionConditions,
|
|
zIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Cycles POI States ...
|
|
XPOIState decisionState = decisionConditions.state;
|
|
|
|
//
|
|
// Cycle X121Conditions ...
|
|
X121Conditions decisionXOBPVConditions = decisionConditions.x121Conditions;
|
|
|
|
//
|
|
// Trigger Conditions ...
|
|
|
|
//
|
|
// Slopes ...
|
|
|
|
//
|
|
bool isRsiSlopeBullish = decisionXOBPVConditions.isRsiSlopeBullish;
|
|
bool isStrSlopeBullish = decisionXOBPVConditions.isStrSlopeBullish;
|
|
bool isAtrUpperSlopeBullish = decisionXOBPVConditions.isAtrUpperSlopeBullish;
|
|
bool isAtrLowerSlopeBullish = decisionXOBPVConditions.isAtrLowerSlopeBullish;
|
|
bool isVwapFastSlopeBullish = decisionXOBPVConditions.isVwapFastSlopeBullish;
|
|
bool isVwapMidSlopeBullish = decisionXOBPVConditions.isVwapMidSlopeBullish;
|
|
bool isVwapSlowSlopeBullish = decisionXOBPVConditions.isVwapSlowSlopeBullish;
|
|
|
|
//
|
|
bool isRsiSlopeBearish = decisionXOBPVConditions.isRsiSlopeBearish;
|
|
bool isStrSlopeBearish = decisionXOBPVConditions.isStrSlopeBearish;
|
|
bool isAtrUpperSlopeBearish = decisionXOBPVConditions.isAtrUpperSlopeBearish;
|
|
bool isAtrLowerSlopeBearish = decisionXOBPVConditions.isAtrLowerSlopeBearish;
|
|
bool isVwapFastSlopeBearish = decisionXOBPVConditions.isVwapFastSlopeBearish;
|
|
bool isVwapMidSlopeBearish = decisionXOBPVConditions.isVwapMidSlopeBearish;
|
|
bool isVwapSlowSlopeBearish = decisionXOBPVConditions.isVwapSlowSlopeBearish;
|
|
|
|
//
|
|
bool isSlopesBullish =
|
|
isRsiSlopeBullish &&
|
|
isStrSlopeBullish &&
|
|
isAtrUpperSlopeBullish &&
|
|
isAtrLowerSlopeBullish &&
|
|
isVwapFastSlopeBullish &&
|
|
isVwapMidSlopeBullish &&
|
|
isVwapSlowSlopeBullish;
|
|
|
|
//
|
|
bool isSlopesBearish =
|
|
isRsiSlopeBearish &&
|
|
isStrSlopeBearish &&
|
|
isAtrUpperSlopeBearish &&
|
|
isAtrLowerSlopeBearish &&
|
|
isVwapFastSlopeBearish &&
|
|
isVwapMidSlopeBearish &&
|
|
isVwapSlowSlopeBearish;
|
|
|
|
//
|
|
double point = conditions.point;
|
|
bool isPointBreaked = IsBarBreak(
|
|
point,
|
|
setupDir,
|
|
cBar //
|
|
);
|
|
|
|
//
|
|
// Summary ...
|
|
|
|
//
|
|
isBullish =
|
|
//
|
|
isBullish // &&
|
|
// isPointBreaked &&
|
|
// isSlopesBullish
|
|
//
|
|
;
|
|
|
|
//
|
|
isBearish =
|
|
//
|
|
isBearish // &&
|
|
// isPointBreaked &&
|
|
// isSlopesBearish
|
|
//
|
|
;
|
|
|
|
//
|
|
result = isBullish ||
|
|
isBearish;
|
|
if (!result)
|
|
{
|
|
//
|
|
// Cleanup Setup Conditions ...
|
|
int setupAge = conditions.GetSetupAge();
|
|
if (IsValidSize(setupAge) &&
|
|
IsValidSize(maxAllowedSetupAge) &&
|
|
setupAge >= maxAllowedSetupAge)
|
|
{
|
|
conditions.Clean();
|
|
}
|
|
|
|
//
|
|
// Cleanup Arrays ...
|
|
ArrayFree(decisionPoiEvents);
|
|
ArrayFree(decisionCycleEvents);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Detect Nearest Pivot Point ...
|
|
|
|
//
|
|
double entry = GetEntry(
|
|
conditions.symbol,
|
|
setupDir //
|
|
);
|
|
|
|
//
|
|
double sls[];
|
|
Add(
|
|
conditions.pivot,
|
|
sls //
|
|
);
|
|
|
|
//
|
|
double iAtr = decisionConditions.x121Conditions.atrBuffer[1];
|
|
iAtr *= 1.5;
|
|
|
|
//
|
|
double slsMin = GetMin(sls);
|
|
double slsMax = GetMax(sls);
|
|
|
|
//
|
|
double sl = isBullish
|
|
? slsMin - iAtr
|
|
: slsMax + iAtr;
|
|
double risk = MathAbs(entry - sl);
|
|
|
|
//
|
|
// Filling Conditions Props ...
|
|
conditions.sl = sl;
|
|
// conditions.target = target;
|
|
conditions.triggerTime = cTime;
|
|
conditions.type = isBullish
|
|
? X_POSITION_TYPE_LONG
|
|
: X_POSITION_TYPE_SHORT;
|
|
|
|
//
|
|
// Cleanup Arrays ...
|
|
ArrayFree(decisionPoiEvents);
|
|
ArrayFree(decisionCycleEvents);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool DetectX121SMCXOBPVGuards(
|
|
X121SMCGuard &guards[],
|
|
const XPosition &positions[],
|
|
XC121SMCCycleHelper *triggerCycleHelper,
|
|
XC121SMCCycleHelper *decisionCycleHelper,
|
|
XC121SMCCycleHelper *analyseCycleHelper,
|
|
XC121SMCCycleHelper *verificationCycleHelper,
|
|
XC121SMCCycleHelper *consolidationCycleHelper,
|
|
XC121SMCCycleHelper *visionCycleHelper //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string provider = ToString(X_121_SMC_PROVIDER_X);
|
|
|
|
//
|
|
// result = DetectX121SMCGuards(
|
|
// provider,
|
|
// guards,
|
|
// positions,
|
|
// triggerCycleHelper,
|
|
// decisionCycleHelper,
|
|
// analyseCycleHelper,
|
|
// verificationCycleHelper,
|
|
// consolidationCycleHelper,
|
|
// visionCycleHelper //
|
|
// );
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int AddX121SMCXOBPVConditionsIfNotExists(
|
|
X121SMCStrategyXOBPVSignalConditions &item,
|
|
X121SMCStrategyXOBPVSignalConditions &items[],
|
|
int maxAllowed = 10 //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
bool isSetuped = IsValid(item.setupTime) &&
|
|
HasDirection(item.dir);
|
|
if (!isSetuped)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(items);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
// Copy Original Items ...
|
|
X121SMCStrategyXOBPVSignalConditions tmpItems[];
|
|
Copy(
|
|
items,
|
|
tmpItems //
|
|
);
|
|
|
|
//
|
|
// Prese Item Data ...
|
|
bool isBullish = IsBullish(item.dir);
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
X121SMCStrategyXOBPVSignalConditions iItem = tmpItems[i];
|
|
|
|
//
|
|
bool canRemove = item.dir == iItem.dir &&
|
|
item.pivot == iItem.pivot;
|
|
if (canRemove)
|
|
{
|
|
//
|
|
ArrayRemove(
|
|
items,
|
|
i,
|
|
1 //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
Clean(tmpItems);
|
|
}
|
|
|
|
//
|
|
AddRef(
|
|
item,
|
|
items //
|
|
);
|
|
|
|
//
|
|
// Remove Olds ...
|
|
CleanupArray(
|
|
items,
|
|
maxAllowed //
|
|
);
|
|
|
|
//
|
|
result = ArraySize(items);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int DrawX121SMCXOBPVConditions(
|
|
X121SMCStrategyXOBPVSignalConditions &conditions,
|
|
XCBaseObject *&drawnObjects[],
|
|
XCPOIDrawer *drawer //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
Clean(drawnObjects);
|
|
|
|
//
|
|
if (drawer == NULL)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool isSetuped = conditions.IsSetuped();
|
|
if (!isSetuped)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|