last ...
This commit is contained in:
@@ -3132,4 +3132,4 @@ class XCX121Helper : public XCBase
|
||||
int mRSIHandler;
|
||||
};
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
@@ -148,7 +148,6 @@ struct XSTRCCIConditions
|
||||
// XSTR ...
|
||||
|
||||
double strBuffer[];
|
||||
double atrBuffer[];
|
||||
double vidyaBuffer[];
|
||||
double strUpBuffer[];
|
||||
double strMidBuffer[];
|
||||
@@ -168,7 +167,24 @@ struct XSTRCCIConditions
|
||||
bool isStrSwitchedToBearish;
|
||||
|
||||
//
|
||||
// XOCS ...
|
||||
// XOSCS ...
|
||||
|
||||
double acBuffer[];
|
||||
double adBuffer[];
|
||||
double atrBuffer[];
|
||||
double cciBuffer[];
|
||||
double rsiBuffer[];
|
||||
double mfiBuffer[];
|
||||
double rviBuffer[];
|
||||
double adxBuffer[];
|
||||
double adxpBuffer[];
|
||||
double adxnBuffer[];
|
||||
double macdBuffer[];
|
||||
double momentumBuffer[];
|
||||
double rviSignalBuffer[];
|
||||
double macdSignalBuffer[];
|
||||
double stochasticBuffer[];
|
||||
double stochasticSignalBuffer[];
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
@@ -403,6 +419,720 @@ class XCXSTRCCIHelper : XCBase
|
||||
// Deconstructor ...
|
||||
~XCXSTRCCIHelper()
|
||||
{
|
||||
//
|
||||
mInputs.Clean();
|
||||
|
||||
//
|
||||
ZeroMemory(strHelper);
|
||||
ZeroMemory(ocsHelper);
|
||||
|
||||
//
|
||||
IndicatorRelease(acHandler);
|
||||
IndicatorRelease(adHandler);
|
||||
IndicatorRelease(adxHandler);
|
||||
IndicatorRelease(atrHandler);
|
||||
IndicatorRelease(cciHandler);
|
||||
IndicatorRelease(rsiHandler);
|
||||
IndicatorRelease(mfiHandler);
|
||||
IndicatorRelease(rviHandler);
|
||||
IndicatorRelease(macdHandler);
|
||||
IndicatorRelease(momentumHandler);
|
||||
IndicatorRelease(stochasticHandler);
|
||||
}
|
||||
|
||||
//
|
||||
string GetSymbol()
|
||||
{
|
||||
return mSymbol;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_TIMEFRAMES GetPeriod()
|
||||
{
|
||||
return mPeriod;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Initialize Indicator Helper ...
|
||||
*
|
||||
* @param symbol: String, Symbol ...
|
||||
* @param period: ENUM_TIMEFRAMES member, Period ...
|
||||
* @param inputs: XSTRCCIInputs instance, Indicator Inputs ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XSTRCCIInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid(symbol) &&
|
||||
IsValid(period) &&
|
||||
inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
// Setting Inputs ...
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
// Initial Helpers ...
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
strHelper = new XCX121XSTRHelper();
|
||||
result =
|
||||
result &&
|
||||
strHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.strInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// XOSC ...
|
||||
ocsHelper = new XCX121XOCSHelper();
|
||||
result =
|
||||
result &&
|
||||
ocsHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs //
|
||||
);
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
ZeroMemory(strHelper);
|
||||
ZeroMemory(ocsHelper);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// OSCILLATORS Viewers ...
|
||||
|
||||
//
|
||||
// AC ...
|
||||
if (mInputs.showAC)
|
||||
{
|
||||
//
|
||||
acHandler = iAC(
|
||||
symbol,
|
||||
period //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
acHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// AD ...
|
||||
if (mInputs.showAD)
|
||||
{
|
||||
//
|
||||
adHandler = iAD(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.adAppliedTo //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
adHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// ADX ...
|
||||
if (mInputs.showADX)
|
||||
{
|
||||
//
|
||||
adxHandler = iADX(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.adxLength //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
adxHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// ATR ...
|
||||
if (mInputs.showATR)
|
||||
{
|
||||
//
|
||||
atrHandler = iATR(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.atrLength //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
atrHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// CCI ...
|
||||
if (mInputs.showCCI)
|
||||
{
|
||||
//
|
||||
cciHandler = iCCI(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.cciLength,
|
||||
mInputs.oscsInputs.cciAppliedTo //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
cciHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// RSI ...
|
||||
if (mInputs.showRSI)
|
||||
{
|
||||
//
|
||||
rsiHandler = iRSI(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.rsiLength,
|
||||
mInputs.oscsInputs.rsiAppliedTo //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
rsiHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// MFI ...
|
||||
if (mInputs.showMFI)
|
||||
{
|
||||
//
|
||||
mfiHandler = iMFI(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.mfiLength,
|
||||
mInputs.oscsInputs.mfiAppliedTo //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
mfiHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// RVI ...
|
||||
if (mInputs.showRVI)
|
||||
{
|
||||
//
|
||||
rviHandler = iRVI(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.rviLength //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
rviHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// MACD ...
|
||||
if (mInputs.showMACD)
|
||||
{
|
||||
//
|
||||
macdHandler = iMACD(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.macdFastLength,
|
||||
mInputs.oscsInputs.macdSlowLength,
|
||||
mInputs.oscsInputs.macdSignalLength,
|
||||
mInputs.oscsInputs.macdAppliedTo //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
macdHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// Momentum ...
|
||||
if (mInputs.showMomentum)
|
||||
{
|
||||
//
|
||||
momentumHandler = iMomentum(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.momentumLength,
|
||||
mInputs.oscsInputs.momentumAppliedTo //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
momentumHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// Stochastic ...
|
||||
if (mInputs.showStochastic)
|
||||
{
|
||||
//
|
||||
stochasticHandler = iStochastic(
|
||||
symbol,
|
||||
period,
|
||||
mInputs.oscsInputs.stochasticKLength,
|
||||
mInputs.oscsInputs.stochasticDLength,
|
||||
mInputs.oscsInputs.stochasticSmoothingLength,
|
||||
mInputs.oscsInputs.stochasticSmoothingMethod,
|
||||
mInputs.oscsInputs.stochasticAppliedTo //
|
||||
);
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
stochasticHandler != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//
|
||||
// If Result is False, Cleanup Resources ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mInputs.Clean();
|
||||
|
||||
//
|
||||
ZeroMemory(strHelper);
|
||||
ZeroMemory(ocsHelper);
|
||||
|
||||
//
|
||||
IndicatorRelease(acHandler);
|
||||
IndicatorRelease(adHandler);
|
||||
IndicatorRelease(adxHandler);
|
||||
IndicatorRelease(atrHandler);
|
||||
IndicatorRelease(cciHandler);
|
||||
IndicatorRelease(rsiHandler);
|
||||
IndicatorRelease(mfiHandler);
|
||||
IndicatorRelease(rviHandler);
|
||||
IndicatorRelease(macdHandler);
|
||||
IndicatorRelease(momentumHandler);
|
||||
IndicatorRelease(stochasticHandler);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Conditions Readers ...
|
||||
|
||||
/**
|
||||
* Retrieve Conditions ...
|
||||
*
|
||||
* @param conditions: Argument 1
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param loopback: int, Loopback looking for others ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetSTRConditions(
|
||||
X121XSTRConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = strHelper.GetConditions(
|
||||
conditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Conditions ...
|
||||
*
|
||||
* @param conditions: Argument 1
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param loopback: int, Loopback looking for others ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetOSCSConditions(
|
||||
X121XOCSConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ocsHelper.GetConditions(
|
||||
conditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Others ...
|
||||
|
||||
//
|
||||
void Free()
|
||||
{
|
||||
//
|
||||
strHelper.Free();
|
||||
ocsHelper.Free();
|
||||
}
|
||||
|
||||
//
|
||||
bool GetConditions(
|
||||
XSTRCCIConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
if (loopback < 5)
|
||||
{
|
||||
loopback = 5;
|
||||
}
|
||||
|
||||
//
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
conditions.symbol = mSymbol;
|
||||
conditions.period = mPeriod;
|
||||
conditions.time = TimeCurrent();
|
||||
|
||||
//
|
||||
int zIndex = barIndex;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
XOHCL cBar;
|
||||
XOHCL pBar;
|
||||
|
||||
//
|
||||
X121XSTRConditions xstrConditions;
|
||||
X121XOCSConditions xocsConditions;
|
||||
|
||||
//
|
||||
result = zBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
zIndex //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
zBar.GetPreviousBar(cBar);
|
||||
result =
|
||||
result &&
|
||||
cBar.GetPreviousBar(pBar);
|
||||
|
||||
//
|
||||
// Conditions Retriever ...
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
result =
|
||||
result &&
|
||||
GetSTRConditions(
|
||||
xstrConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
// XOSCS ...
|
||||
result =
|
||||
result &&
|
||||
GetOSCSConditions(
|
||||
xocsConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
|
||||
//
|
||||
xocsConditions.Clean();
|
||||
xstrConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Fill X121 Conditions Reference by Using
|
||||
// Retrieved Conditions ...
|
||||
|
||||
//
|
||||
int cIDX = 1;
|
||||
int pIDX = cIDX + 1;
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.vidyaBuffer,
|
||||
conditions.vidyaBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.strBuffer,
|
||||
conditions.strBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.strMidBuffer,
|
||||
conditions.strMidBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.strUpBuffer,
|
||||
conditions.strUpBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.strDownBuffer,
|
||||
conditions.strDownBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.strPriceBuffer,
|
||||
conditions.strPriceBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.strStateBuffer,
|
||||
conditions.strStateBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.strSMLowBuffer,
|
||||
conditions.strSMLowBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.strSMHighBuffer,
|
||||
conditions.strSMHighBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xstrConditions.strMidStateBuffer,
|
||||
conditions.strMidStateBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
conditions.isStrBullish = xstrConditions.isStrBullish;
|
||||
conditions.isStrBearish = xstrConditions.isStrBearish;
|
||||
conditions.isStrSwitchedToBullish = xstrConditions.isStrSwitchedToBullish;
|
||||
conditions.isStrSwitchedToBearish = xstrConditions.isStrSwitchedToBearish;
|
||||
|
||||
//
|
||||
// XOSCS ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.acBuffer,
|
||||
conditions.acBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.adBuffer,
|
||||
conditions.adBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.atrBuffer,
|
||||
conditions.atrBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.cciBuffer,
|
||||
conditions.cciBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.rsiBuffer,
|
||||
conditions.rsiBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.mfiBuffer,
|
||||
conditions.mfiBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.rviBuffer,
|
||||
conditions.rviBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.adxBuffer,
|
||||
conditions.adxBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.adxpBuffer,
|
||||
conditions.adxpBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.adxnBuffer,
|
||||
conditions.adxnBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.macdBuffer,
|
||||
conditions.macdBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.momentumBuffer,
|
||||
conditions.momentumBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.rviSignalBuffer,
|
||||
conditions.rviSignalBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.macdSignalBuffer,
|
||||
conditions.macdSignalBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.stochasticBuffer,
|
||||
conditions.stochasticBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xocsConditions.stochasticSignalBuffer,
|
||||
conditions.stochasticSignalBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
// Cleanup Resource ...
|
||||
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
|
||||
//
|
||||
xstrConditions.Clean();
|
||||
xocsConditions.Clean();
|
||||
|
||||
//
|
||||
Free();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user