last ...
This commit is contained in:
@@ -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,7 +749,15 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
XC121SMCCycleHelper *pivotHelper, // XPV Helper ...
|
||||
XPVPivot &orderFlow[], // OrderFlows ...
|
||||
ENUM_X_DIRECTION &orderFlowDirection, // Order Flow Direction ...
|
||||
int maxAllowedLoopbackBars = 576 //
|
||||
//
|
||||
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