last ...
This commit is contained in:
@@ -1402,6 +1402,208 @@ class XCBarAnalyser : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Pin Bar or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
* @param dir: ENUM_X_DIRECTION member ...
|
||||
* @param extend: Integer ...
|
||||
* @param shadowPercent: Double ...
|
||||
* @param bodyPercent: Double ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsPinBar(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
int extend = 1,
|
||||
double shadowPercent = 65,
|
||||
double bodyPercent = 25 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = bar.IsValid() &&
|
||||
bar.Index() > 0 &&
|
||||
bodyPercent > 0 &&
|
||||
shadowPercent > 0 &&
|
||||
bodyPercent < shadowPercent;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Chack Range Extends ...
|
||||
if (extend > 0)
|
||||
{
|
||||
//
|
||||
result = HasExtendedRange(
|
||||
bar,
|
||||
extend //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Body ...
|
||||
double rangePercent = GetBarRangePercent(bar);
|
||||
|
||||
//
|
||||
double body = bar.GetBody();
|
||||
double highShadow = bar.GetHighShadow();
|
||||
double lowShadow = bar.GetLowShadow();
|
||||
|
||||
//
|
||||
// Check Body ...
|
||||
result = body / rangePercent >= bodyPercent;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isPassedHighShadow =
|
||||
highShadow / rangePercent >= shadowPercent;
|
||||
bool isPassedLowShadow =
|
||||
lowShadow / rangePercent >= shadowPercent;
|
||||
result =
|
||||
isPassedLowShadow ||
|
||||
isPassedHighShadow;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
dir = isPassedLowShadow
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decision Bar (Pin, Momentum or Rejection) ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
* @param dir: ENUM_X_DIRECTION member ...
|
||||
* @param extend: Integer ...
|
||||
* @param shadowForPinAndRejectionBarPercent: Double ...
|
||||
* @param bodyForPinBarPercent: Double ...
|
||||
* @param bodyForEngulfBarPercent: Double ...
|
||||
* @param bodyForMomentumBarPercent: Double ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsDecisionBar(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
int extend = 1,
|
||||
double shadowForPinAndRejectionBarPercent = 65,
|
||||
double bodyForPinBarPercent = 25,
|
||||
double bodyForEngulfBarPercent = 65,
|
||||
double bodyForMomentumBarPercent = 70 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = bar.IsValid() &&
|
||||
bar.Index() > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Pin Bar ...
|
||||
ENUM_X_DIRECTION pinDir;
|
||||
bool isPiBar = IsPinBar(
|
||||
bar,
|
||||
pinDir,
|
||||
extend,
|
||||
shadowForPinAndRejectionBarPercent,
|
||||
bodyForPinBarPercent //
|
||||
);
|
||||
|
||||
//
|
||||
// Engulfing Bar ...
|
||||
ENUM_X_DIRECTION engulfDir;
|
||||
bool isEngulfBar = IsEngulfBar(
|
||||
bar,
|
||||
engulfDir,
|
||||
extend,
|
||||
bodyForEngulfBarPercent //
|
||||
);
|
||||
|
||||
//
|
||||
// Momentum Bar ...
|
||||
ENUM_X_DIRECTION momentumDir;
|
||||
bool isMomentumBar = IsMomentumBar(
|
||||
bar,
|
||||
momentumDir,
|
||||
extend,
|
||||
bodyForMomentumBarPercent //
|
||||
);
|
||||
|
||||
//
|
||||
// Rejection Bar ...
|
||||
ENUM_X_DIRECTION rejectionDir;
|
||||
bool isRejectionBar = IsRejectionBar(
|
||||
bar,
|
||||
rejectionDir,
|
||||
extend,
|
||||
shadowForPinAndRejectionBarPercent //
|
||||
);
|
||||
|
||||
//
|
||||
result = isPiBar ||
|
||||
isEngulfBar ||
|
||||
isMomentumBar ||
|
||||
isRejectionBar;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
if (isPiBar)
|
||||
{
|
||||
dir = pinDir;
|
||||
}
|
||||
else if (isEngulfBar)
|
||||
{
|
||||
dir = engulfDir;
|
||||
}
|
||||
else if (isMomentumBar)
|
||||
{
|
||||
dir = momentumDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = rejectionDir;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsBullish(dir) ||
|
||||
IsBearish(dir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Support and Resistance Zones ...
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5"
|
||||
#include "../Libraries/x-121.smc.lib.mq5"
|
||||
|
||||
//
|
||||
@@ -191,6 +192,10 @@ class XC121SMCCycleHelper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Bar Analyser Class Instance ...
|
||||
mBarAnalyser = new XCBarAnalyser();
|
||||
|
||||
//
|
||||
// Set Chart Style ...
|
||||
ApplyChartStyle();
|
||||
@@ -327,12 +332,23 @@ class XC121SMCCycleHelper : public XCBase
|
||||
}
|
||||
|
||||
//
|
||||
int barIndex = bar.Index();
|
||||
XOHCL mBar;
|
||||
result = GetBar(
|
||||
bar,
|
||||
mBar //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int barIndex = mBar.Index();
|
||||
double sar = mXCHSARHelper.GetC(barIndex);
|
||||
bool isBullish = sar > 0 &&
|
||||
sar < bar.low;
|
||||
sar < mBar.low;
|
||||
bool isBearish = sar > 0 &&
|
||||
sar > bar.high;
|
||||
sar > mBar.high;
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (!result)
|
||||
@@ -351,8 +367,8 @@ class XC121SMCCycleHelper : public XCBase
|
||||
//
|
||||
XOHCL iBar;
|
||||
canContinue = iBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
mBar.symbol,
|
||||
mBar.period,
|
||||
barIndex //
|
||||
);
|
||||
if (!canContinue)
|
||||
@@ -377,7 +393,7 @@ class XC121SMCCycleHelper : public XCBase
|
||||
if (isSarChanged)
|
||||
{
|
||||
//
|
||||
changeBar = iBar;
|
||||
result = iBar.GetNextBar(changeBar);
|
||||
canContinue = false;
|
||||
break;
|
||||
}
|
||||
@@ -390,6 +406,102 @@ class XC121SMCCycleHelper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Last Decision Bar ( Rejection, Pin, Momentum ) ...
|
||||
*
|
||||
* @param decisionBar: XOHCL instance, Holds Decision Bar ...
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Bar Direction ...
|
||||
* @param bar: XOHCL instance, represents Current Bar for Loopback ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectNearestDecisionBar(
|
||||
XOHCL &decisionBar,
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XOHCL &bar //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
decisionBar.Clean();
|
||||
|
||||
//
|
||||
result =
|
||||
bar.IsValid() &&
|
||||
forDir != X_DIRECTION_ALL &&
|
||||
forDir != X_DIRECTION_NONE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL mBar;
|
||||
result = GetBar(
|
||||
bar,
|
||||
mBar //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int barIndex = mBar.Index();
|
||||
bool isBullish = IsBullish(forDir);
|
||||
|
||||
//
|
||||
bool canContinue = true;
|
||||
while (canContinue)
|
||||
{
|
||||
//
|
||||
barIndex++;
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
canContinue = iBar.Init(
|
||||
mBar.symbol,
|
||||
mBar.period,
|
||||
barIndex //
|
||||
);
|
||||
if (!canContinue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION decisionDir;
|
||||
bool isDecisionBar = mBarAnalyser
|
||||
.IsDecisionBar(
|
||||
iBar,
|
||||
decisionDir //
|
||||
);
|
||||
if (isDecisionBar)
|
||||
{
|
||||
//
|
||||
if (decisionDir == forDir)
|
||||
{
|
||||
//
|
||||
decisionBar = mBar;
|
||||
canContinue = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
canContinue = !decisionBar.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
result = decisionBar
|
||||
.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Virtuals ...
|
||||
|
||||
@@ -401,6 +513,7 @@ class XC121SMCCycleHelper : public XCBase
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XCBarAnalyser *mBarAnalyser;
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
@@ -410,6 +523,14 @@ class XC121SMCCycleHelper : public XCBase
|
||||
*/
|
||||
void DeInit()
|
||||
{
|
||||
//
|
||||
delete mXPVHelper;
|
||||
delete mX3MAHelper;
|
||||
delete mX3VWAPHelper;
|
||||
delete mXCHSARHelper;
|
||||
|
||||
//
|
||||
delete mBarAnalyser;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,4 +586,93 @@ class XC121SMCCycleHelper : public XCBase
|
||||
ChartSetInteger(chartId, CHART_COLOR_CHART_LINE, mLineColor);
|
||||
ChartSetInteger(chartId, CHART_COLOR_VOLUME, mVolumesColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Symbol ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetSymbol()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
result = mXPVHelper.GetSymbol();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve TimeFrame (Period) ...
|
||||
*
|
||||
* @return ( ENUM_TIMEFRAMES )
|
||||
*/
|
||||
ENUM_TIMEFRAMES GetPeriod()
|
||||
{
|
||||
//
|
||||
ENUM_TIMEFRAMES result = NULL;
|
||||
|
||||
//
|
||||
result = mXPVHelper.GetPeriod();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Specified Bar ...
|
||||
*
|
||||
* @param source: XOHCL instance, Source Bar ...
|
||||
* @param bar: XOHCL instance, Dest Bar ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetBar(
|
||||
XOHCL &source,
|
||||
XOHCL &bar //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid(symbol) &&
|
||||
IsValid(period) &&
|
||||
source.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int index = iBarShift(
|
||||
symbol,
|
||||
period,
|
||||
source.time //
|
||||
);
|
||||
result = bar.Init(
|
||||
symbol,
|
||||
period,
|
||||
index //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -527,6 +527,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
int samePivots = 40;
|
||||
int requiredPivots = 10;
|
||||
|
||||
//
|
||||
bool useVisionState = false;
|
||||
bool useConsolidationState = false;
|
||||
bool useVerificationState = false;
|
||||
bool useAnalyseState = false;
|
||||
bool useDecisionState = true;
|
||||
bool useTriggerState = false;
|
||||
|
||||
//
|
||||
DetectOrderFlow(
|
||||
cIndex,
|
||||
@@ -534,7 +542,15 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
requiredPivots,
|
||||
mTriggerCycleHelper,
|
||||
mOrderFlow,
|
||||
mOrderFlowDir //
|
||||
mOrderFlowDir,
|
||||
//
|
||||
// Filling Pivot State ...
|
||||
useVisionState, // Use Vision State ...
|
||||
useConsolidationState, // Use Consolidation State ...
|
||||
useVerificationState, // Use Verification State ...
|
||||
useAnalyseState, // Use Analyse State ...
|
||||
useDecisionState, // Use Decision State ...
|
||||
useTriggerState // Use Trigger State ...
|
||||
);
|
||||
|
||||
//
|
||||
@@ -567,6 +583,51 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Last Sar Change ...
|
||||
string iVLineName = sarChangeBar.GetTag("XSAR");
|
||||
CChartObjectVLine *iVLineObj;
|
||||
iVLineObj = new CChartObjectVLine();
|
||||
result = iVLineObj.Create(
|
||||
ChartID(),
|
||||
iVLineName,
|
||||
0,
|
||||
sarChangeBar.time //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
iVLineObj.Color(clrYellow);
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Nearest Momentum or Rejection Bar ...
|
||||
XOHCL decisionBar;
|
||||
result = mDecisionCycleHelper.DetectNearestDecisionBar(
|
||||
decisionBar,
|
||||
marketStructureDir,
|
||||
cBar //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Last Decision Bar ...
|
||||
string iVLineNameDecision = decisionBar.GetTag("XDECISION");
|
||||
CChartObjectVLine *iVLineDecisionObj;
|
||||
iVLineDecisionObj = new CChartObjectVLine();
|
||||
result = iVLineDecisionObj.Create(
|
||||
ChartID(),
|
||||
iVLineNameDecision,
|
||||
0,
|
||||
decisionBar.time //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
iVLineDecisionObj.Color(clrYellow);
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Remove This ...
|
||||
bool ignoreSwingHighs = true;
|
||||
@@ -688,6 +749,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
XC121SMCCycleHelper *pivotHelper, // XPV Helper ...
|
||||
XPVPivot &orderFlow[], // OrderFlows ...
|
||||
ENUM_X_DIRECTION &orderFlowDirection, // Order Flow Direction ...
|
||||
//
|
||||
bool useVisionState = true, // Use Vision State ...
|
||||
bool useConsolidationState = true, // Use Consolidation State ...
|
||||
bool useVerificationState = true, // Use Verification State ...
|
||||
bool useAnalyseState = true, // Use Analyse State ...
|
||||
bool useDecisionState = true, // Use Decision State ...
|
||||
bool useTriggerState = true, // Use Trigger State ...
|
||||
//
|
||||
int maxAllowedLoopbackBars = 576 //
|
||||
)
|
||||
{
|
||||
@@ -975,12 +1044,12 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
FillPivotSate(
|
||||
i,
|
||||
false, // Use Vision State ...
|
||||
false, // Use Consolidation State ...
|
||||
false, // Use Verification State ...
|
||||
false, // Use Analyse State ...
|
||||
true, // Use Decision State ...
|
||||
false // Use Trigger State ...
|
||||
useVisionState, // Use Vision State ...
|
||||
useConsolidationState, // Use Consolidation State ...
|
||||
useVerificationState, // Use Verification State ...
|
||||
useAnalyseState, // Use Analyse State ...
|
||||
useDecisionState, // Use Decision State ...
|
||||
useTriggerState // Use Trigger State ...
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user