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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user