Files
xMQL5/BKPS/14040218 XCAEA/Helpers/x-saherelm.x121.xoscs.helper.mq5
T
2025-05-08 14:17:59 +03:30

3499 lines
90 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XCX121XOCSHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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 "../Classes/x-saherelm.x-helper.class.mq5"
//
// Buffers ...
enum ENUM_X121_XOSCS_BUFFERS
{
//
// https://www.mql5.com/en/articles/11467 ...
X121_XOSCS_XAC_LINE = 0,
// https://www.mql5.com/en/articles/10993 ...
X121_XOSCS_XAD_LINE = 1,
// https://www.mql5.com/en/articles/10715 ...
X121_XOSCS_XADX_LINE = 2,
X121_XOSCS_XADX_P_LINE = 3,
X121_XOSCS_XADX_N_LINE = 4,
// https://www.mql5.com/en/articles/10748 ...
X121_XOSCS_XATR_LINE = 5,
// https://www.mql5.com/en/articles/10592 ...
X121_XOSCS_XCCI_LINE = 6,
// https://www.mql5.com/en/articles/10528 ...
X121_XOSCS_XRSI_LINE = 7,
// https://www.mql5.com/en/articles/11037 ...
X121_XOSCS_XMFI_LINE = 8,
// https://www.mql5.com/en/articles/11425 ...
X121_XOSCS_XRVI_LINE = 9,
X121_XOSCS_XRVI_S_LINE = 10,
// https://www.mql5.com/en/articles/10674 ...
X121_XOSCS_XMACD_LINE = 11,
X121_XOSCS_XMACD_S_LINE = 12,
// https://www.mql5.com/en/articles/10547 ...
X121_XOSCS_XMOMENTUM_LINE = 13,
// https://www.mql5.com/en/articles/10692 ..
X121_XOSCS_XSTOCHASTIC_LINE = 14,
X121_XOSCS_XSTOCHASTIC_S_LINE = 15,
};
//
// Inputs ...
struct X121XOCSInputs
{
//
// Props ...
//
// Accumulation/Distribution ...
ENUM_APPLIED_VOLUME adAppliedTo; // Applied To
//
// AC ...
int acBullishLevel; // Bullish Level
int acBearishLevel; // Bearish Level
//
// ADX ...
int adxLength; // Length
int adxThreshold; // Big Movement Threshold
//
// ATR ...
int atrLength; // Length
//
// CCI ...
int cciLength; // Length
ENUM_APPLIED_PRICE cciAppliedTo; // Applied To
int cciOBLevel; // Over Bought Level
int cciOSLevel; // Over Sold Level
int cciReversalLevel; // Reversal Level
//
// RSI ...
int rsiLength; // Length
ENUM_APPLIED_PRICE rsiAppliedTo; // Applied To
int rsiOBLevel; // Over Bought Level
int rsiOSLevel; // Over Sold Level
int rsiReversalLevel; // Reversal Level
//
// MFI ...
int mfiLength; // Length
ENUM_APPLIED_VOLUME mfiAppliedTo; // Applied To
int mfiOBLevel; // Over Bought Level
int mfiOSLevel; // Over Sold Level
int mfiReversalLevel; // Reversal Level
//
// RVI ...
int rviLength; // Length
int rviBullishLevel; // Bullish Level
int rviBearishLevel; // Bearish Level
//
// MACD ...
int macdFastLength; // Fast EMA Length
int macdSlowLength; // Slow EMA Length
int macdSignalLength; // Signal Length
ENUM_APPLIED_PRICE macdAppliedTo; // Applied To
int macdBullishLevel; // Bullish Level
int macdBearishLevel; // Bearish Level
//
// Momentum ...
int momentumLength; // Length
ENUM_APPLIED_PRICE momentumAppliedTo; // Applied To
int momentumBullishLevel; // Bullish Level
int momentumBearishLevel; // Bearish Level
//
// Stochastic ...
int stochasticKLength; // K Length (Bars for Calculation)
int stochasticDLength; // D Length (first Smoothing)
int stochasticSmoothingLength; // Smoothing Length
ENUM_MA_METHOD stochasticSmoothingMethod; // Smoothing Method
ENUM_STO_PRICE stochasticAppliedTo; // Applied To
int stochasticOBLevel; // Over Bought Level
int stochasticOSLevel; // Over Sold Level
int stochasticReversalLevel; // Reversal Level
//
// Presentation ...
int startCalculationForLastBars; // Calculate Last n Bars
//
// Constructor(s) ...
X121XOCSInputs()
{
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
// Accumulation/Distribution ...
adAppliedTo = VOLUME_TICK; // Applied To
//
// AC ...
acBullishLevel = 0;
acBearishLevel = 0;
//
// ADX ...
adxLength = 0; // Length
adxThreshold = 0; // Big Movement Threshold
//
// ATR ...
atrLength = 0; // Length
//
// CCI ...
cciLength = 0; // Length
cciAppliedTo = PRICE_TYPICAL; // Applied To
cciOBLevel = 100; // Over Bought Level
cciOSLevel = -100; // Over Sold Level
cciReversalLevel = 0; // Reversal Level
//
// RSI ...
rsiLength = 0; // Length
rsiAppliedTo = PRICE_CLOSE; // Applied To
rsiOBLevel = 0; // Over Bought Level
rsiOSLevel = 0; // Over Sold Level
rsiReversalLevel = 0; // Reversal Level
//
// MFI ...
mfiLength = 0; // Length
mfiAppliedTo = VOLUME_TICK; // Applied To
mfiOBLevel = 0; // Over Bought Level
mfiOSLevel = 0; // Over Sold Level
mfiReversalLevel = 0; // Reversal Level
//
// RVI ...
rviLength = 0; // Length
rviBullishLevel = 0; // Bullish Level
rviBearishLevel = 0; // Bearish Level
//
// MACD ...
macdFastLength = 0; // Fast EMA Length
macdSlowLength = 0; // Slow EMA Length
macdSignalLength = 0; // Signal Length
macdAppliedTo = PRICE_CLOSE; // Applied To
macdBullishLevel = 0; // Bullish Level
macdBearishLevel = 0; // Bearish Level
//
// Momentum ...
momentumLength = 0; // Length
momentumAppliedTo = PRICE_CLOSE; // Applied To
momentumBullishLevel = 0; // Bullish Level
momentumBearishLevel = 0; // Bearish Level
//
// Stochastic ...
stochasticKLength = 0; // K Length (Bars for Calculation)
stochasticDLength = 0; // D Length (first Smoothing)
stochasticSmoothingLength = 0; // Smoothing Length
stochasticSmoothingMethod = MODE_SMA; // Smoothing Method
stochasticAppliedTo = STO_LOWHIGH; // Applied To
stochasticOBLevel = 0; // Over Bought Level
stochasticOSLevel = 0; // Over Sold Level
stochasticReversalLevel = 0; // Reversal Level
//
// Presentation ...
startCalculationForLastBars = 0; // Calculate Last n Bars
//
ZeroMemory(this);
}
//
// Default ...
void Default()
{
//
// Accumulation/Distribution ...
adAppliedTo = VOLUME_TICK; // Applied To
//
// AC ...
acBullishLevel = 0;
acBearishLevel = 0;
//
// ADX ...
adxLength = 14; // Length
adxThreshold = 25; // Big Movement Threshold
//
// ATR ...
atrLength = 14; // Length
//
// CCI ...
cciLength = 14; // Length
cciAppliedTo = PRICE_TYPICAL; // Applied To
cciOBLevel = 100; // Over Bought Level
cciOSLevel = -100; // Over Sold Level
cciReversalLevel = 0; // Reversal Level
//
// RSI ...
rsiLength = 14; // Length
rsiAppliedTo = PRICE_CLOSE; // Applied To
rsiOBLevel = 70; // Over Bought Level
rsiOSLevel = 30; // Over Sold Level
rsiReversalLevel = 50; // Reversal Level
//
// MFI ...
mfiLength = 14; // Length
mfiAppliedTo = VOLUME_TICK; // Applied To
mfiOBLevel = 80; // Over Bought Level
mfiOSLevel = 20; // Over Sold Level
mfiReversalLevel = 50; // Reversal Level
//
// RVI ...
rviLength = 14; // Length
rviBullishLevel = 0; // Bullish Level
rviBearishLevel = 0; // Bearish Level
//
// MACD ...
macdFastLength = 12; // Fast EMA Length
macdSlowLength = 26; // Slow EMA Length
macdSignalLength = 9; // Signal Length
macdAppliedTo = PRICE_CLOSE; // Applied To
macdBullishLevel = 0; // Bullish Level
macdBearishLevel = 0; // Bearish Level
//
// Momentum ...
momentumLength = 14; // Length
momentumAppliedTo = PRICE_CLOSE; // Applied To
momentumBullishLevel = 100; // Bullish Level
momentumBearishLevel = 100; // Bearish Level
//
// Stochastic ...
stochasticKLength = 5; // K Length (Bars for Calculation)
stochasticDLength = 3; // D Length (first Smoothing)
stochasticSmoothingLength = 3; // Smoothing Length
stochasticSmoothingMethod = MODE_SMA; // Smoothing Method
stochasticAppliedTo = STO_LOWHIGH; // Applied To
stochasticOBLevel = 80; // Over Bought Level
stochasticOSLevel = 20; // Over Sold Level
stochasticReversalLevel = 50; // Reversal Level
//
// Presentation ...
startCalculationForLastBars = 1000; // Calculate Last n Bars
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
adxLength > 0 &&
adxThreshold > 0 &&
//
atrLength > 0 &&
//
cciLength > 0 &&
cciOBLevel > 0 &&
cciOSLevel != 0 &&
cciOBLevel > cciReversalLevel &&
cciOSLevel < cciReversalLevel &&
//
rsiLength > 0 &&
rsiOBLevel > 0 &&
rsiOSLevel > 0 &&
rsiReversalLevel > 0 &&
rsiOBLevel > rsiReversalLevel &&
rsiOSLevel < rsiReversalLevel &&
//
mfiLength > 0 &&
mfiOBLevel > 0 &&
mfiOSLevel > 0 &&
mfiReversalLevel > 0 &&
mfiOBLevel > mfiReversalLevel &&
mfiOSLevel < mfiReversalLevel &&
//
rviLength > 0 &&
//
macdFastLength > 0 &&
macdSlowLength > 0 &&
macdSignalLength > 0 &&
macdFastLength < macdSlowLength &&
//
stochasticKLength > 0 &&
stochasticDLength > 0 &&
stochasticSmoothingLength > 0 &&
stochasticOBLevel > 0 &&
stochasticOSLevel > 0 &&
stochasticReversalLevel > 0 &&
stochasticOBLevel > stochasticReversalLevel &&
stochasticOSLevel < stochasticReversalLevel &&
//
momentumLength > 0
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(adxLength, atrLength);
result = MathMax(result, cciLength);
result = MathMax(result, rsiLength);
result = MathMax(result, mfiLength);
result = MathMax(result, rviLength);
result = MathMax(result, momentumLength);
result = MathMax(result, macdFastLength);
result = MathMax(result, macdSlowLength);
result = MathMax(result, macdSignalLength);
result = MathMax(result, stochasticKLength);
result = MathMax(result, stochasticDLength);
result = MathMax(result, stochasticSmoothingLength);
//
return result;
}
};
//
// Conditions ...
struct X121XOCSConditions
{
//
// Common ...
string symbol;
ENUM_TIMEFRAMES period;
datetime time;
//
// Buffers ...
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[];
//
// Values ...
//
double adxThreshold; // Big Movement Threshold
double cciOBLevel; // Over Bought Level
double cciOSLevel; // Over Sold Level
double cciReversalLevel; // Reversal Level
double rsiOBLevel; // Over Bought Level
double rsiOSLevel; // Over Sold Level
double rsiReversalLevel; // Reversal Level
double mfiOBLevel; // Over Bought Level
double mfiOSLevel; // Over Sold Level
double mfiReversalLevel; // Reversal Level
double rviBullishLevel; // Bullish Level
double rviBearishLevel; // Bearish Level
double macdBullishLevel; // Bullish Level
double macdBearishLevel; // Bearish Level
double momentumBullishLevel; // Bullish Level
double momentumBearishLevel; // Bearish Level
double stochasticOBLevel; // Over Bought Level
double stochasticOSLevel; // Over Sold Level
double stochasticReversalLevel; // Reversal Level
//
// Conditions ...
//
// AC ...
//
bool isACBullish;
bool isACBearish;
//
bool isACSwitchedToBullish;
bool isACSwitchedToBearish;
//
bool isACOverMax;
bool isACUnderMin;
//
// AD ...
//
bool isADBiggerLast;
bool isADLesserLast;
//
bool isADOverMax;
bool isADUnderMin;
//
// ADX ...
//
bool isADXBiggerLast;
bool isADXLesserLast;
//
bool isADXOverThreshold;
bool isADXUnderThreshold;
//
bool isDXPBiggerThanDXN;
bool isDXNBiggerThanDXP;
//
bool isADXBullish;
bool isADXBearish;
//
bool isADXSwitchedToBullish;
bool isADXSwitchedToBearish;
//
// ATR ...
bool isATROverLast;
bool isATRUnderLast;
//
// CCI ...
//
bool isCCIBullish;
bool isCCIBearish;
//
bool isCCISwitchedToBullish;
bool isCCISwitchedToBearish;
//
bool isCCIOB;
bool isCCIOS;
//
bool isCCICrossedOverOB;
bool isCCICrossedOverOS;
//
bool isCCICrossedUnderOB;
bool isCCICrossedUnderOS;
//
// RSI ...
//
bool isRSIBullish;
bool isRSIBearish;
//
bool isRSISwitchedToBullish;
bool isRSISwitchedToBearish;
//
bool isRSIOB;
bool isRSIOS;
//
bool isRSICrossedOverOB;
bool isRSICrossedOverOS;
//
bool isRSICrossedUnderOB;
bool isRSICrossedUnderOS;
//
// MFI ...
//
bool isMFIBullish;
bool isMFIBearish;
//
bool isMFISwitchedToBullish;
bool isMFISwitchedToBearish;
//
bool isMFIOB;
bool isMFIOS;
//
bool isMFICrossedOverOB;
bool isMFICrossedOverOS;
//
bool isMFICrossedUnderOB;
bool isMFICrossedUnderOS;
//
// RVI ...
//
bool isRVIBullish;
bool isRVIBearish;
//
bool isRVISwitchedToBullish;
bool isRVISwitchedToBearish;
//
bool isRVIOverSignal;
bool isRVIUnderSignal;
//
bool isRVICrossedOverSignal;
bool isRVICrossedUnderSignal;
//
// MACD ...
//
bool isMACDBullish;
bool isMACDBearish;
//
bool isMACDSwitchedToBullish;
bool isMACDSwitchedToBearish;
//
bool isMACDOverSignal;
bool isMACDUnderSignal;
//
bool isMACDCrossedOverSignal;
bool isMACDCrossedUnderSignal;
//
// MOMENTUM ...
//
bool isMomentumBullish;
bool isMomentumBearish;
//
bool isMomentumSwitchedToBullish;
bool isMomentumSwitchedToBearish;
//
// STOCHASTIC ...
//
bool isStochasticBullish;
bool isStochasticBearish;
//
bool isStochasticSwitchedToBullish;
bool isStochasticSwitchedToBearish;
//
bool isStochasticOverSignal;
bool isStochasticUnderSignal;
//
bool isStochasticCrossedOverSignal;
bool isStochasticCrossedUnderSignal;
//
bool isStochasticOB;
bool isStochasticOS;
//
bool isStochasticCrossedOverOB;
bool isStochasticCrossedOverOS;
//
bool isStochasticCrossedUnderOB;
bool isStochasticCrossedUnderOS;
//
// Constructor ...
X121XOCSConditions()
{
Clean();
}
//
// Tools ...
/**
* Cleaning Up ...
*/
void Clean()
{
//
// Commons ...
symbol = NULL;
period = NULL;
time = NULL;
//
// Buffers ...
//
Clean(acBuffer);
Clean(adBuffer);
Clean(atrBuffer);
Clean(cciBuffer);
Clean(rsiBuffer);
Clean(mfiBuffer);
Clean(rviBuffer);
Clean(adxBuffer);
Clean(adxpBuffer);
Clean(adxnBuffer);
Clean(macdBuffer);
Clean(momentumBuffer);
Clean(rviSignalBuffer);
Clean(macdSignalBuffer);
Clean(stochasticBuffer);
Clean(stochasticSignalBuffer);
//
ArraySetAsSeries(acBuffer, true);
ArraySetAsSeries(adBuffer, true);
ArraySetAsSeries(atrBuffer, true);
ArraySetAsSeries(cciBuffer, true);
ArraySetAsSeries(rsiBuffer, true);
ArraySetAsSeries(mfiBuffer, true);
ArraySetAsSeries(rviBuffer, true);
ArraySetAsSeries(adxBuffer, true);
ArraySetAsSeries(adxpBuffer, true);
ArraySetAsSeries(adxnBuffer, true);
ArraySetAsSeries(macdBuffer, true);
ArraySetAsSeries(momentumBuffer, true);
ArraySetAsSeries(rviSignalBuffer, true);
ArraySetAsSeries(macdSignalBuffer, true);
ArraySetAsSeries(stochasticBuffer, true);
ArraySetAsSeries(stochasticSignalBuffer, true);
//
// Values ...
//
adxThreshold = 0.0;
cciOBLevel = 0.0;
cciOSLevel = 0.0;
cciReversalLevel = 0.0;
rsiOBLevel = 0.0;
rsiOSLevel = 0.0;
rsiReversalLevel = 0.0;
mfiOBLevel = 0.0;
mfiOSLevel = 0.0;
mfiReversalLevel = 0.0;
rviBullishLevel = 0.0;
rviBearishLevel = 0.0;
macdBullishLevel = 0.0;
macdBearishLevel = 0.0;
momentumBullishLevel = 0.0;
momentumBearishLevel = 0.0;
stochasticOBLevel = 0.0;
stochasticOSLevel = 0.0;
stochasticReversalLevel = 0.0;
//
// Conditions ...
//
// AC ...
//
isACBullish = false;
isACBearish = false;
isACSwitchedToBullish = false;
isACSwitchedToBearish = false;
isACOverMax = false;
isACUnderMin = false;
//
// AD ...
//
isADBiggerLast = false;
isADLesserLast = false;
isADOverMax = false;
isADUnderMin = false;
//
// ADX ...
//
isADXBiggerLast = false;
isADXLesserLast = false;
isADXOverThreshold = false;
isADXUnderThreshold = false;
isDXPBiggerThanDXN = false;
isDXNBiggerThanDXP = false;
isADXBullish = false;
isADXBearish = false;
isADXSwitchedToBullish = false;
isADXSwitchedToBearish = false;
//
// ATR ...
//
isATROverLast = false;
isATRUnderLast = false;
//
// CCI ...
//
isCCIBullish = false;
isCCIBearish = false;
isCCISwitchedToBullish = false;
isCCISwitchedToBearish = false;
isCCIOB = false;
isCCIOS = false;
isCCICrossedOverOB = false;
isCCICrossedOverOS = false;
isCCICrossedUnderOB = false;
isCCICrossedUnderOS = false;
//
// RSI ...
//
isRSIBullish = false;
isRSIBearish = false;
isRSISwitchedToBullish = false;
isRSISwitchedToBearish = false;
isRSIOB = false;
isRSIOS = false;
isRSICrossedOverOB = false;
isRSICrossedOverOS = false;
isRSICrossedUnderOB = false;
isRSICrossedUnderOS = false;
//
// MFI ...
//
isMFIBullish = false;
isMFIBearish = false;
isMFISwitchedToBullish = false;
isMFISwitchedToBearish = false;
isMFIOB = false;
isMFIOS = false;
isMFICrossedOverOB = false;
isMFICrossedOverOS = false;
isMFICrossedUnderOB = false;
isMFICrossedUnderOS = false;
//
// RVI ...
//
isRVIBullish = false;
isRVIBearish = false;
isRVISwitchedToBullish = false;
isRVISwitchedToBearish = false;
isRVIOverSignal = false;
isRVIUnderSignal = false;
isRVICrossedOverSignal = false;
isRVICrossedUnderSignal = false;
//
// MACD ...
//
isMACDBullish = false;
isMACDBearish = false;
isMACDSwitchedToBullish = false;
isMACDSwitchedToBearish = false;
isMACDOverSignal = false;
isMACDUnderSignal = false;
isMACDCrossedOverSignal = false;
isMACDCrossedUnderSignal = false;
//
// MOMENTUM ...
//
isMomentumBullish = false;
isMomentumBearish = false;
isMomentumSwitchedToBullish = false;
isMomentumSwitchedToBearish = false;
//
// STOCHASTIC ...
//
isStochasticBullish = false;
isStochasticBearish = false;
isStochasticSwitchedToBullish = false;
isStochasticSwitchedToBearish = false;
isStochasticOverSignal = false;
isStochasticUnderSignal = false;
isStochasticCrossedOverSignal = false;
isStochasticCrossedUnderSignal = false;
isStochasticOB = false;
isStochasticOS = false;
isStochasticCrossedOverOB = false;
isStochasticCrossedOverOS = false;
isStochasticCrossedUnderOB = false;
isStochasticCrossedUnderOS = false;
//
ZeroMemory(this);
}
/**
* Generate Conditions Scores ...
*
* @param bullishScore: Double, Directional Scores Reference ...
* @param bearishScore: Double, Directional Scores Reference ...
*/
void GenerateScore(
double &bullishScore,
double &bearishScore //
)
{
//
bullishScore = 0;
bearishScore = 0;
//
double score = 1;
double minScore = 0.5;
double highScore = 1.5;
//
//
// AC ...
//
if (isACBullish)
{
bullishScore += minScore;
}
if (isACOverMax)
{
bullishScore += minScore;
}
if (isACSwitchedToBullish)
{
bullishScore += minScore;
}
//
if (isACBearish)
{
bearishScore += minScore;
}
if (isACUnderMin)
{
bearishScore += minScore;
}
if (isACSwitchedToBearish)
{
bearishScore += minScore;
}
//
// AD ...
//
if (isADOverMax)
{
bullishScore += minScore;
}
if (isADBiggerLast)
{
bullishScore += minScore;
}
//
if (isADUnderMin)
{
bearishScore += minScore;
}
if (isADLesserLast)
{
bearishScore += minScore;
}
//
// ADX ...
//
if (isADXBullish)
{
bullishScore += minScore;
}
if (isADXBiggerLast)
{
bullishScore += minScore;
}
if (isADXOverThreshold)
{
bullishScore += minScore;
}
if (isDXPBiggerThanDXN)
{
bullishScore += minScore;
}
if (isADXSwitchedToBullish)
{
bullishScore += minScore;
}
//
if (isADXBearish)
{
bearishScore += minScore;
}
if (isADXLesserLast)
{
bearishScore += minScore;
}
if (isDXNBiggerThanDXP)
{
bearishScore += minScore;
}
if (isADXUnderThreshold)
{
bearishScore += minScore;
}
if (isADXSwitchedToBearish)
{
bearishScore += minScore;
}
//
// ATR ...
//
if (isATROverLast)
{
bullishScore += minScore;
}
//
if (isATRUnderLast)
{
bearishScore += minScore;
}
//
// CCI ...
//
if (isCCIOS)
{
bullishScore += minScore;
}
if (isCCIBullish)
{
bullishScore += minScore;
}
if (isCCICrossedOverOS)
{
bullishScore += minScore;
}
if (isCCICrossedOverOB)
{
bullishScore += minScore;
}
if (isCCISwitchedToBullish)
{
bullishScore += minScore;
}
//
if (isCCIOB)
{
bearishScore += minScore;
}
if (isCCIBearish)
{
bearishScore += minScore;
}
if (isCCICrossedUnderOS)
{
bearishScore += minScore;
}
if (isCCICrossedUnderOB)
{
bearishScore += minScore;
}
if (isCCISwitchedToBearish)
{
bearishScore += minScore;
}
//
// RSI ...
//
if (isRSIOS)
{
bullishScore += minScore;
}
if (isRSIBullish)
{
bullishScore += minScore;
}
if (isRSICrossedOverOB)
{
bullishScore += minScore;
}
if (isRSICrossedOverOS)
{
bullishScore += minScore;
}
if (isRSISwitchedToBullish)
{
bullishScore += minScore;
}
//
if (isRSIOB)
{
bearishScore += minScore;
}
if (isRSIBearish)
{
bearishScore += minScore;
}
if (isRSICrossedUnderOB)
{
bearishScore += minScore;
}
if (isRSICrossedUnderOS)
{
bearishScore += minScore;
}
if (isRSISwitchedToBearish)
{
bearishScore += minScore;
}
//
// MFI ...
//
if (isMFIOS)
{
bullishScore += minScore;
}
if (isMFIBullish)
{
bullishScore += minScore;
}
if (isMFICrossedOverOB)
{
bullishScore += minScore;
}
if (isMFICrossedOverOS)
{
bullishScore += minScore;
}
if (isMFISwitchedToBullish)
{
bullishScore += minScore;
}
//
if (isMFIOB)
{
bearishScore += minScore;
}
if (isMFIBearish)
{
bearishScore += minScore;
}
if (isMFICrossedUnderOB)
{
bearishScore += minScore;
}
if (isMFICrossedUnderOS)
{
bearishScore += minScore;
}
if (isMFISwitchedToBearish)
{
bearishScore += minScore;
}
//
// RVI ...
//
if (isRVIBullish)
{
bullishScore += minScore;
}
if (isRVIOverSignal)
{
bullishScore += minScore;
}
if (isRVISwitchedToBullish)
{
bullishScore += minScore;
}
if (isRVICrossedOverSignal)
{
bullishScore += minScore;
}
//
if (isRVIBearish)
{
bearishScore += minScore;
}
if (isRVIUnderSignal)
{
bearishScore += minScore;
}
if (isRVISwitchedToBearish)
{
bearishScore += minScore;
}
if (isRVICrossedUnderSignal)
{
bearishScore += minScore;
}
//
// MACD ...
//
if (isMACDBullish)
{
bullishScore += minScore;
}
if (isMACDOverSignal)
{
bullishScore += minScore;
}
if (isMACDSwitchedToBullish)
{
bullishScore += minScore;
}
if (isMACDCrossedOverSignal)
{
bullishScore += minScore;
}
//
if (isMACDBearish)
{
bearishScore += minScore;
}
if (isMACDUnderSignal)
{
bearishScore += minScore;
}
if (isMACDSwitchedToBearish)
{
bearishScore += minScore;
}
if (isMACDCrossedUnderSignal)
{
bearishScore += minScore;
}
//
// MOMENTUM ...
//
if (isMomentumBullish)
{
bullishScore += minScore;
}
if (isMomentumSwitchedToBullish)
{
bullishScore += minScore;
}
//
if (isMomentumBearish)
{
bearishScore += minScore;
}
if (isMomentumSwitchedToBearish)
{
bearishScore += minScore;
}
//
// STOCHASTIC ...
//
if (isStochasticOS)
{
bullishScore += minScore;
}
if (isStochasticOverSignal)
{
bullishScore += minScore;
}
if (isStochasticBullish)
{
bullishScore += minScore;
}
if (isStochasticCrossedOverSignal)
{
bullishScore += minScore;
}
if (isStochasticCrossedOverOB)
{
bullishScore += minScore;
}
if (isStochasticCrossedOverOS)
{
bullishScore += minScore;
}
if (isStochasticSwitchedToBullish)
{
bullishScore += minScore;
}
//
if (isStochasticOB)
{
bearishScore += minScore;
}
if (isStochasticUnderSignal)
{
bearishScore += minScore;
}
if (isStochasticBearish)
{
bearishScore += minScore;
}
if (isStochasticCrossedUnderSignal)
{
bearishScore += minScore;
}
if (isStochasticCrossedUnderOB)
{
bearishScore += minScore;
}
if (isStochasticCrossedUnderOS)
{
bearishScore += minScore;
}
if (isStochasticSwitchedToBearish)
{
bearishScore += minScore;
}
//
}
/**
* Generate Summary String for Represent Conditions State ...
*
* @param onlyCommons: Boolean, Just Generate Only Commons Conditions ...
* @param onlyConditions: Boolean, Just Generate Only Conditions ...
* @param includeScores: Boolean, Attach Scores Representations on Result ...
* @param ignoreFalseConditions: Boolean, Ignore False Conditions on Result ...
* @param separator: String, Separate Lines ...
*
* @return ( string )
*/
string GenerateSummary(
bool onlyCommons = false,
bool onlyConditions = false,
bool includeScores = true,
bool ignoreFalseConditions = true,
string separator = "\n" //
)
{
//
string result = NULL;
//
double bullishScore = 0;
double bearishScore = 0;
GenerateScore(
bullishScore,
bearishScore //
);
//
string scoresStr =
//
"Scores: " + separator +
"---------------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
string commonStr = GenerateSpecifiedCommonSummary(
this,
separator,
includeScores //
);
//
string conditionsStr =
//
"-----------------------" + separator +
"XOSCS: " + separator +
"-----------------------" + separator +
ToString("isACBullish", isACBullish, ignoreFalseConditions, separator) +
ToString("isACBearish", isACBearish, ignoreFalseConditions, separator) +
ToString("isACSwitchedToBullish", isACSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isACSwitchedToBearish", isACSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isACOverMax", isACOverMax, ignoreFalseConditions, separator) +
ToString("isACUnderMin", isACUnderMin, ignoreFalseConditions, separator) +
ToString("isADBiggerLast", isADBiggerLast, ignoreFalseConditions, separator) +
ToString("isADLesserLast", isADLesserLast, ignoreFalseConditions, separator) +
ToString("isADOverMax", isADOverMax, ignoreFalseConditions, separator) +
ToString("isADUnderMin", isADUnderMin, ignoreFalseConditions, separator) +
ToString("isADXBiggerLast", isADXBiggerLast, ignoreFalseConditions, separator) +
ToString("isADXLesserLast", isADXLesserLast, ignoreFalseConditions, separator) +
ToString("isADXOverThreshold", isADXOverThreshold, ignoreFalseConditions, separator) +
ToString("isADXUnderThreshold", isADXUnderThreshold, ignoreFalseConditions, separator) +
ToString("isDXPBiggerThanDXN", isDXPBiggerThanDXN, ignoreFalseConditions, separator) +
ToString("isDXNBiggerThanDXP", isDXNBiggerThanDXP, ignoreFalseConditions, separator) +
ToString("isADXBullish", isADXBullish, ignoreFalseConditions, separator) +
ToString("isADXBearish", isADXBearish, ignoreFalseConditions, separator) +
ToString("isADXSwitchedToBullish", isADXSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isADXSwitchedToBearish", isADXSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isATROverLast", isATROverLast, ignoreFalseConditions, separator) +
ToString("isATRUnderLast", isATRUnderLast, ignoreFalseConditions, separator) +
ToString("isCCIBullish", isCCIBullish, ignoreFalseConditions, separator) +
ToString("isCCIBearish", isCCIBearish, ignoreFalseConditions, separator) +
ToString("isCCISwitchedToBullish", isCCISwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isCCISwitchedToBearish", isCCISwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isCCIOB", isCCIOB, ignoreFalseConditions, separator) +
ToString("isCCIOS", isCCIOS, ignoreFalseConditions, separator) +
ToString("isCCICrossedOverOB", isCCICrossedOverOB, ignoreFalseConditions, separator) +
ToString("isCCICrossedOverOS", isCCICrossedOverOS, ignoreFalseConditions, separator) +
ToString("isCCICrossedUnderOB", isCCICrossedUnderOB, ignoreFalseConditions, separator) +
ToString("isCCICrossedUnderOS", isCCICrossedUnderOS, ignoreFalseConditions, separator) +
ToString("isRSIBullish", isRSIBullish, ignoreFalseConditions, separator) +
ToString("isRSIBearish", isRSIBearish, ignoreFalseConditions, separator) +
ToString("isRSISwitchedToBullish", isRSISwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isRSISwitchedToBearish", isRSISwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isRSIOB", isRSIOB, ignoreFalseConditions, separator) +
ToString("isRSIOS", isRSIOS, ignoreFalseConditions, separator) +
ToString("isRSICrossedOverOB", isRSICrossedOverOB, ignoreFalseConditions, separator) +
ToString("isRSICrossedOverOS", isRSICrossedOverOS, ignoreFalseConditions, separator) +
ToString("isRSICrossedUnderOB", isRSICrossedUnderOB, ignoreFalseConditions, separator) +
ToString("isRSICrossedUnderOS", isRSICrossedUnderOS, ignoreFalseConditions, separator) +
ToString("isMFIBullish", isMFIBullish, ignoreFalseConditions, separator) +
ToString("isMFIBearish", isMFIBearish, ignoreFalseConditions, separator) +
ToString("isMFISwitchedToBullish", isMFISwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isMFISwitchedToBearish", isMFISwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isMFIOB", isMFIOB, ignoreFalseConditions, separator) +
ToString("isMFIOS", isMFIOS, ignoreFalseConditions, separator) +
ToString("isMFICrossedOverOB", isMFICrossedOverOB, ignoreFalseConditions, separator) +
ToString("isMFICrossedOverOS", isMFICrossedOverOS, ignoreFalseConditions, separator) +
ToString("isMFICrossedUnderOB", isMFICrossedUnderOB, ignoreFalseConditions, separator) +
ToString("isMFICrossedUnderOS", isMFICrossedUnderOS, ignoreFalseConditions, separator) +
ToString("isRVIBullish", isRVIBullish, ignoreFalseConditions, separator) +
ToString("isRVIBearish", isRVIBearish, ignoreFalseConditions, separator) +
ToString("isRVISwitchedToBullish", isRVISwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isRVISwitchedToBearish", isRVISwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isRVIOverSignal", isRVIOverSignal, ignoreFalseConditions, separator) +
ToString("isRVIUnderSignal", isRVIUnderSignal, ignoreFalseConditions, separator) +
ToString("isRVICrossedOverSignal", isRVICrossedOverSignal, ignoreFalseConditions, separator) +
ToString("isRVICrossedUnderSignal", isRVICrossedUnderSignal, ignoreFalseConditions, separator) +
ToString("isMACDBullish", isMACDBullish, ignoreFalseConditions, separator) +
ToString("isMACDBearish", isMACDBearish, ignoreFalseConditions, separator) +
ToString("isMACDSwitchedToBullish", isMACDSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isMACDSwitchedToBearish", isMACDSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isMACDOverSignal", isMACDOverSignal, ignoreFalseConditions, separator) +
ToString("isMACDUnderSignal", isMACDUnderSignal, ignoreFalseConditions, separator) +
ToString("isMACDCrossedOverSignal", isMACDCrossedOverSignal, ignoreFalseConditions, separator) +
ToString("isMACDCrossedUnderSignal", isMACDCrossedUnderSignal, ignoreFalseConditions, separator) +
ToString("isMomentumBullish", isMomentumBullish, ignoreFalseConditions, separator) +
ToString("isMomentumBearish", isMomentumBearish, ignoreFalseConditions, separator) +
ToString("isMomentumSwitchedToBullish", isMomentumSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isMomentumSwitchedToBearish", isMomentumSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isStochasticBullish", isStochasticBullish, ignoreFalseConditions, separator) +
ToString("isStochasticBearish", isStochasticBearish, ignoreFalseConditions, separator) +
ToString("isStochasticSwitchedToBullish", isStochasticSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isStochasticSwitchedToBearish", isStochasticSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isStochasticOverSignal", isStochasticOverSignal, ignoreFalseConditions, separator) +
ToString("isStochasticUnderSignal", isStochasticUnderSignal, ignoreFalseConditions, separator) +
ToString("isStochasticCrossedOverSignal", isStochasticCrossedOverSignal, ignoreFalseConditions, separator) +
ToString("isStochasticCrossedUnderSignal", isStochasticCrossedUnderSignal, ignoreFalseConditions, separator) +
ToString("isStochasticOB", isStochasticOB, ignoreFalseConditions, separator) +
ToString("isStochasticOS", isStochasticOS, ignoreFalseConditions, separator) +
ToString("isStochasticCrossedOverOB", isStochasticCrossedOverOB, ignoreFalseConditions, separator) +
ToString("isStochasticCrossedOverOS", isStochasticCrossedOverOS, ignoreFalseConditions, separator) +
ToString("isStochasticCrossedUnderOB", isStochasticCrossedUnderOB, ignoreFalseConditions, separator) +
ToString("isStochasticCrossedUnderOS", isStochasticCrossedUnderOS, ignoreFalseConditions, separator) +
//
""
//
;
//
result =
//
"[" + GetTag() + "]" + separator +
(onlyConditions
? ""
: commonStr) +
(!includeScores
? ""
: scoresStr) +
" " + separator +
(onlyCommons
? ""
: conditionsStr) +
""
//
;
//
return result;
}
/**
* Retrieve nique Tag Identifier ...
*
* @return ( string )
*/
string GetTag()
{
return GetTypeName(this);
}
};
//
// Helper Class Implementation ...
class XCX121XOCSHelper : XCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XCX121XOCSHelper()
: XCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XCX121XOCSHelper()
{
//
mInputs.Clean();
//
Clean(acBuffer);
Clean(adBuffer);
Clean(atrBuffer);
Clean(cciBuffer);
Clean(rsiBuffer);
Clean(mfiBuffer);
Clean(rviBuffer);
Clean(adxBuffer);
Clean(adxpBuffer);
Clean(adxnBuffer);
Clean(macdBuffer);
Clean(momentumBuffer);
Clean(rviSignalBuffer);
Clean(macdSignalBuffer);
Clean(stochasticBuffer);
Clean(stochasticSignalBuffer);
}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
X121XOCSInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
ArraySetAsSeries(acBuffer, true);
ArraySetAsSeries(adBuffer, true);
ArraySetAsSeries(atrBuffer, true);
ArraySetAsSeries(cciBuffer, true);
ArraySetAsSeries(rsiBuffer, true);
ArraySetAsSeries(mfiBuffer, true);
ArraySetAsSeries(rviBuffer, true);
ArraySetAsSeries(adxBuffer, true);
ArraySetAsSeries(adxpBuffer, true);
ArraySetAsSeries(adxnBuffer, true);
ArraySetAsSeries(macdBuffer, true);
ArraySetAsSeries(momentumBuffer, true);
ArraySetAsSeries(rviSignalBuffer, true);
ArraySetAsSeries(macdSignalBuffer, true);
ArraySetAsSeries(stochasticBuffer, true);
ArraySetAsSeries(stochasticSignalBuffer, true);
//
mInputs = inputs;
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.x121.xoscs",
//
// Inputs ...
//
// AD ...
"",
mInputs.adAppliedTo,
//
// ADX ...
"",
mInputs.adxLength,
//
// ATR ...
"",
mInputs.atrLength,
//
// CCI ...
"",
mInputs.cciLength,
mInputs.cciAppliedTo,
//
// RSI ...
"",
mInputs.rsiLength,
mInputs.rsiAppliedTo,
//
// MFI ...
"",
mInputs.mfiLength,
mInputs.mfiAppliedTo,
//
// RVI ...
"",
mInputs.rviLength,
//
// MACD ...
"",
mInputs.macdFastLength,
mInputs.macdSlowLength,
mInputs.macdSignalLength,
mInputs.macdAppliedTo,
//
// MOMENTUM ...
"",
mInputs.momentumLength,
mInputs.momentumAppliedTo,
//
// STOCHASTIC ...
"",
mInputs.stochasticKLength,
mInputs.stochasticDLength,
mInputs.stochasticSmoothingLength,
mInputs.stochasticSmoothingMethod,
mInputs.stochasticAppliedTo,
//
// Presentation ...
"",
//
mInputs.startCalculationForLastBars
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
X121XOCSInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
X121XOCSInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Readers ...
//
// AC ...
//
double GetAC(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(acBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return acBuffer[barIndex];
}
//
int CopyAC(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
acBuffer,
buffer,
forceClean
//
);
}
//
// AD ...
//
double GetAD(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(adBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return adBuffer[barIndex];
}
//
int CopyAD(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
adBuffer,
buffer,
forceClean
//
);
}
//
// ADX ...
//
double GetADX(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(adxBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return adxBuffer[barIndex];
}
//
int CopyADX(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
adxBuffer,
buffer,
forceClean
//
);
}
//
// ADXP ...
//
double GetADXP(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(adxpBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return adxpBuffer[barIndex];
}
//
int CopyADXP(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
adxpBuffer,
buffer,
forceClean
//
);
}
//
// ADXN ...
//
double GetADXN(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(adxnBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return adxnBuffer[barIndex];
}
//
int CopyADXN(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
adxnBuffer,
buffer,
forceClean
//
);
}
//
// ATR ...
//
double GetATR(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(atrBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return atrBuffer[barIndex];
}
//
int CopyATR(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
atrBuffer,
buffer,
forceClean
//
);
}
//
// CCI ...
//
double GetCCI(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(cciBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return cciBuffer[barIndex];
}
//
int CopyCCI(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
cciBuffer,
buffer,
forceClean
//
);
}
//
// RSI ...
//
double GetRSI(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(rsiBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return rsiBuffer[barIndex];
}
//
int CopyRSI(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
rsiBuffer,
buffer,
forceClean
//
);
}
//
// MFI ...
//
double GetMFI(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(mfiBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mfiBuffer[barIndex];
}
//
int CopyMFI(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
mfiBuffer,
buffer,
forceClean
//
);
}
//
// Momentum ...
//
double GetMomentum(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(momentumBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return momentumBuffer[barIndex];
}
//
int CopyMomentum(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
momentumBuffer,
buffer,
forceClean
//
);
}
//
// RVI ...
//
double GetRVI(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(rviBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return rviBuffer[barIndex];
}
//
int CopyRVI(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
rviBuffer,
buffer,
forceClean
//
);
}
//
// RVI Signal ...
//
double GetRVISignal(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(rviSignalBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return rviSignalBuffer[barIndex];
}
//
int CopyRVISignal(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
rviSignalBuffer,
buffer,
forceClean
//
);
}
//
// MACD ...
//
double GetMACD(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(macdBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return macdBuffer[barIndex];
}
//
int CopyMACD(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
macdBuffer,
buffer,
forceClean
//
);
}
//
// MACD Signal ...
//
double GetMACDSignal(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(macdSignalBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return macdSignalBuffer[barIndex];
}
//
int CopyMACDSignal(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
macdSignalBuffer,
buffer,
forceClean
//
);
}
//
// Stochastic ...
//
double GetStochastic(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(stochasticBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return stochasticBuffer[barIndex];
}
//
int CopyStochastic(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
stochasticBuffer,
buffer,
forceClean
//
);
}
//
// Stochastic Signal ...
//
double GetStochasticSignal(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(stochasticSignalBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return stochasticSignalBuffer[barIndex];
}
//
int CopyStochasticSignal(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
stochasticSignalBuffer,
buffer,
forceClean
//
);
}
//
void Free() override
{
Cleanup(10);
}
//
bool GetConditions(
X121XOCSConditions &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;
result = zBar.Init(
mSymbol,
mPeriod,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
mSymbol,
mPeriod,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
mSymbol,
mPeriod,
pIndex //
);
if (!result)
{
return result;
}
//
// Buffers ...
//
CopyAC(
zIndex,
loopback,
conditions.acBuffer //
);
//
CopyAD(
zIndex,
loopback,
conditions.adBuffer //
);
//
CopyADX(
zIndex,
loopback,
conditions.adxBuffer //
);
//
CopyADXP(
zIndex,
loopback,
conditions.adxpBuffer //
);
//
CopyADXN(
zIndex,
loopback,
conditions.adxnBuffer //
);
//
CopyATR(
zIndex,
loopback,
conditions.atrBuffer //
);
//
CopyCCI(
zIndex,
loopback,
conditions.cciBuffer //
);
//
CopyRSI(
zIndex,
loopback,
conditions.rsiBuffer //
);
//
CopyMFI(
zIndex,
loopback,
conditions.mfiBuffer //
);
//
CopyMomentum(
zIndex,
loopback,
conditions.momentumBuffer //
);
//
CopyRVI(
zIndex,
loopback,
conditions.rviBuffer //
);
//
CopyRVISignal(
zIndex,
loopback,
conditions.rviSignalBuffer //
);
//
CopyMACD(
zIndex,
loopback,
conditions.macdBuffer //
);
//
CopyMACDSignal(
zIndex,
loopback,
conditions.macdSignalBuffer //
);
//
CopyStochastic(
zIndex,
loopback,
conditions.stochasticBuffer //
);
//
CopyStochasticSignal(
zIndex,
loopback,
conditions.stochasticSignalBuffer //
);
//
// Values ...
//
conditions.adxThreshold = mInputs.adxThreshold;
conditions.cciOBLevel = mInputs.cciOBLevel;
conditions.cciOSLevel = mInputs.cciOSLevel;
conditions.cciReversalLevel = mInputs.cciReversalLevel;
conditions.rsiOBLevel = mInputs.rsiOBLevel;
conditions.rsiOSLevel = mInputs.rsiOSLevel;
conditions.rsiReversalLevel = mInputs.rsiReversalLevel;
conditions.mfiOBLevel = mInputs.mfiOBLevel;
conditions.mfiOSLevel = mInputs.mfiOSLevel;
conditions.mfiReversalLevel = mInputs.mfiReversalLevel;
conditions.rviBullishLevel = mInputs.rviBullishLevel;
conditions.rviBearishLevel = mInputs.rviBearishLevel;
conditions.macdBullishLevel = mInputs.macdBullishLevel;
conditions.macdBearishLevel = mInputs.macdBearishLevel;
conditions.momentumBullishLevel = mInputs.momentumBullishLevel;
conditions.momentumBearishLevel = mInputs.momentumBearishLevel;
conditions.stochasticOBLevel = mInputs.stochasticOBLevel;
conditions.stochasticOSLevel = mInputs.stochasticOSLevel;
conditions.stochasticReversalLevel = mInputs.stochasticReversalLevel;
//
// Conditions ...
//
int cIDX = 1;
int pIDX = cIDX + 1;
int ppIDX = pIDX + 1;
//
// AC ...
//
bool isACBullish = conditions.acBuffer[cIDX] > mInputs.acBullishLevel;
bool isACBullishPrev = conditions.acBuffer[pIDX] > mInputs.acBullishLevel;
bool isACSwitchedToBullish = isACBullish &&
!isACBullishPrev;
//
bool isACBearish = conditions.acBuffer[cIDX] < mInputs.acBearishLevel;
bool isACBearishPrev = conditions.acBuffer[pIDX] < mInputs.acBearishLevel;
bool isACSwitchedToBearish = isACBearish &&
!isACBearishPrev;
//
bool isACOverMax = conditions.acBuffer[cIDX] >= GetMax(conditions.acBuffer);
bool isACUnderMin = conditions.acBuffer[cIDX] <= GetMin(conditions.acBuffer);
//
// AD ...
//
bool isADBiggerLast = conditions.adBuffer[cIDX] > conditions.adBuffer[pIDX];
bool isADLesserLast = conditions.adBuffer[cIDX] < conditions.adBuffer[pIDX];
//
bool isADOverMax = conditions.adBuffer[cIDX] >= GetMax(conditions.adBuffer);
bool isADUnderMin = conditions.adBuffer[cIDX] <= GetMin(conditions.adBuffer);
//
// ADX ...
//
bool isADXBiggerLast = conditions.adxBuffer[cIDX] > conditions.adxBuffer[pIDX];
bool isADXBiggerLastPrev = conditions.adxBuffer[pIDX] > conditions.adxBuffer[ppIDX];
//
bool isADXLesserLast = conditions.adxBuffer[cIDX] < conditions.adxBuffer[pIDX];
bool isADXLesserLastPrev = conditions.adxBuffer[pIDX] < conditions.adxBuffer[ppIDX];
//
bool isADXOverThreshold = conditions.adxBuffer[cIDX] > mInputs.adxThreshold;
bool isADXOverThresholdPrev = conditions.adxBuffer[pIDX] > mInputs.adxThreshold;
//
bool isADXUnderThreshold = conditions.adxBuffer[cIDX] < mInputs.adxThreshold;
bool isADXUnderThresholdPrev = conditions.adxBuffer[pIDX] < mInputs.adxThreshold;
//
bool isDXPBiggerThanDXN = conditions.adxpBuffer[cIDX] > conditions.adxnBuffer[cIDX];
bool isDXPBiggerThanDXNPrev = conditions.adxpBuffer[pIDX] > conditions.adxnBuffer[pIDX];
//
bool isDXNBiggerThanDXP = conditions.adxnBuffer[cIDX] > conditions.adxpBuffer[cIDX];
bool isDXNBiggerThanDXPPrev = conditions.adxnBuffer[pIDX] > conditions.adxpBuffer[pIDX];
//
bool isADXBullish = isADXBiggerLast &&
isDXPBiggerThanDXN &&
isADXOverThreshold;
bool isADXBullishPrev = isADXBiggerLastPrev &&
isDXPBiggerThanDXNPrev &&
isADXOverThresholdPrev;
bool isADXSwitchedToBullish = isADXBullish &&
!isADXBullishPrev;
//
bool isADXBearish = isADXLesserLast &&
isDXNBiggerThanDXP &&
isADXUnderThreshold;
bool isADXBearishPrev = isADXLesserLastPrev &&
isDXNBiggerThanDXP &&
isADXUnderThresholdPrev;
bool isADXSwitchedToBearish = isADXBearish &&
!isADXBearishPrev;
//
// ATR ...
//
bool isATROverLast = conditions.atrBuffer[cIDX] > conditions.atrBuffer[pIDX];
bool isATRUnderLast = conditions.atrBuffer[cIDX] < conditions.atrBuffer[pIDX];
//
// CCI ...
//
bool isCCIBullish = conditions.cciBuffer[cIDX] > mInputs.cciReversalLevel;
bool isCCIBullishPrev = conditions.cciBuffer[pIDX] > mInputs.cciReversalLevel;
bool isCCISwitchedToBullish = isCCIBullish &&
!isCCIBullishPrev;
//
bool isCCIBearish = conditions.cciBuffer[cIDX] < mInputs.cciReversalLevel;
bool isCCIBearishPrev = conditions.cciBuffer[pIDX] < mInputs.cciReversalLevel;
bool isCCISwitchedToBearish = isCCIBearish &&
!isCCIBearishPrev;
//
bool isCCIOB = conditions.cciBuffer[cIDX] > mInputs.cciOBLevel;
bool isCCIOBPrev = conditions.cciBuffer[pIDX] > mInputs.cciOBLevel;
bool isCCICrossedOverOB = isCCIOB &&
!isCCIOBPrev;
//
bool isCCIUnderOB = conditions.cciBuffer[cIDX] < mInputs.cciOBLevel;
bool isCCIUnderOBPrev = conditions.cciBuffer[pIDX] < mInputs.cciOBLevel;
bool isCCICrossedUnderOB = isCCIUnderOB &&
!isCCIUnderOBPrev;
//
bool isCCIOS = conditions.cciBuffer[cIDX] < mInputs.cciOSLevel;
bool isCCIOSPrev = conditions.cciBuffer[pIDX] < mInputs.cciOSLevel;
bool isCCICrossedUnderOS = isCCIOS &&
!isCCIOSPrev;
//
bool isCCIOverOS = conditions.cciBuffer[cIDX] > mInputs.cciOSLevel;
bool isCCIOverOSPrev = conditions.cciBuffer[pIDX] > mInputs.cciOSLevel;
bool isCCICrossedOverOS = isCCIOverOS &&
!isCCIOverOSPrev;
//
// RSI ...
//
bool isRSIBullish = conditions.rsiBuffer[cIDX] > mInputs.rsiReversalLevel;
bool isRSIBullishPrev = conditions.rsiBuffer[pIDX] > mInputs.rsiReversalLevel;
bool isRSISwitchedToBullish = isRSIBullish &&
!isRSIBullishPrev;
//
bool isRSIBearish = conditions.rsiBuffer[cIDX] < mInputs.rsiReversalLevel;
bool isRSIBearishPrev = conditions.rsiBuffer[pIDX] < mInputs.rsiReversalLevel;
bool isRSISwitchedToBearish = isRSIBearish &&
!isRSIBearishPrev;
//
bool isRSIOB = conditions.rsiBuffer[cIDX] > mInputs.rsiOBLevel;
bool isRSIOBPrev = conditions.rsiBuffer[pIDX] > mInputs.rsiOBLevel;
bool isRSICrossedOverOB = isRSIOB &&
!isRSIOBPrev;
//
bool isRSIUnderOB = conditions.rsiBuffer[cIDX] < mInputs.rsiOBLevel;
bool isRSIUnderOBPrev = conditions.rsiBuffer[pIDX] < mInputs.rsiOBLevel;
bool isRSICrossedUnderOB = isRSIUnderOB &&
!isRSIUnderOBPrev;
//
bool isRSIOS = conditions.rsiBuffer[cIDX] < mInputs.rsiOSLevel;
bool isRSIOSPrev = conditions.rsiBuffer[pIDX] < mInputs.rsiOSLevel;
bool isRSICrossedUnderOS = isRSIOS &&
!isRSIOSPrev;
//
bool isRSIOverOS = conditions.rsiBuffer[cIDX] > mInputs.rsiOSLevel;
bool isRSIOverOSPrev = conditions.rsiBuffer[pIDX] > mInputs.rsiOSLevel;
bool isRSICrossedOverOS = isRSIOverOS &&
!isRSIOverOSPrev;
//
// MFI ...
//
bool isMFIBullish = conditions.mfiBuffer[cIDX] > mInputs.mfiReversalLevel;
bool isMFIBullishPrev = conditions.mfiBuffer[pIDX] > mInputs.mfiReversalLevel;
bool isMFISwitchedToBullish = isMFIBullish &&
!isMFIBullishPrev;
//
bool isMFIBearish = conditions.mfiBuffer[cIDX] < mInputs.mfiReversalLevel;
bool isMFIBearishPrev = conditions.mfiBuffer[pIDX] < mInputs.mfiReversalLevel;
bool isMFISwitchedToBearish = isMFIBearish &&
!isMFIBearishPrev;
//
bool isMFIOB = conditions.mfiBuffer[cIDX] > mInputs.mfiOBLevel;
bool isMFIOBPrev = conditions.mfiBuffer[pIDX] > mInputs.mfiOBLevel;
bool isMFICrossedOverOB = isMFIOB &&
!isMFIOBPrev;
//
bool isMFIUnderOB = conditions.mfiBuffer[cIDX] < mInputs.mfiOBLevel;
bool isMFIUnderOBPrev = conditions.mfiBuffer[pIDX] < mInputs.mfiOBLevel;
bool isMFICrossedUnderOB = isMFIUnderOB &&
!isMFIUnderOBPrev;
//
bool isMFIOS = conditions.mfiBuffer[cIDX] < mInputs.mfiOSLevel;
bool isMFIOSPrev = conditions.mfiBuffer[pIDX] < mInputs.mfiOSLevel;
bool isMFICrossedUnderOS = isMFIOS &&
!isMFIOSPrev;
//
bool isMFIOverOS = conditions.mfiBuffer[cIDX] > mInputs.mfiOSLevel;
bool isMFIOverOSPrev = conditions.mfiBuffer[pIDX] > mInputs.mfiOSLevel;
bool isMFICrossedOverOS = isMFIOverOS &&
!isMFIOverOSPrev;
//
// RVI ...
//
bool isRVIBullish = conditions.rviBuffer[cIDX] > mInputs.rviBullishLevel;
bool isRVIBullishPrev = conditions.rviBuffer[pIDX] > mInputs.rviBullishLevel;
bool isRVISwitchedToBullish = isRVIBullish &&
!isRVIBullishPrev;
//
bool isRVIBearish = conditions.rviBuffer[cIDX] < mInputs.rviBearishLevel;
bool isRVIBearishPrev = conditions.rviBuffer[pIDX] < mInputs.rviBearishLevel;
bool isRVISwitchedToBearish = isRVIBearish &&
!isRVIBearishPrev;
//
bool isRVIOverSignal = conditions.rviBuffer[cIDX] > conditions.rviSignalBuffer[cIDX];
bool isRVIOverSignalPrev = conditions.rviBuffer[pIDX] > conditions.rviSignalBuffer[pIDX];
bool isRVICrossedOverSignal = isRVIOverSignal &&
!isRVIOverSignalPrev;
//
bool isRVIUnderSignal = conditions.rviBuffer[cIDX] < conditions.rviSignalBuffer[cIDX];
bool isRVIUnderSignalPrev = conditions.rviBuffer[pIDX] < conditions.rviSignalBuffer[pIDX];
bool isRVICrossedUnderSignal = isRVIUnderSignal &&
!isRVIUnderSignalPrev;
//
// MACD ...
//
bool isMACDBullish = conditions.macdBuffer[cIDX] > mInputs.macdBullishLevel;
bool isMACDBullishPrev = conditions.macdBuffer[pIDX] > mInputs.macdBullishLevel;
bool isMACDSwitchedToBullish = isMACDBullish &&
!isMACDBullishPrev;
//
bool isMACDBearish = conditions.macdBuffer[cIDX] < mInputs.macdBearishLevel;
bool isMACDBearishPrev = conditions.macdBuffer[pIDX] < mInputs.macdBearishLevel;
bool isMACDSwitchedToBearish = isMACDBearish &&
!isMACDBearishPrev;
//
bool isMACDOverSignal = conditions.macdBuffer[cIDX] > conditions.macdSignalBuffer[cIDX];
bool isMACDOverSignalPrev = conditions.macdBuffer[pIDX] > conditions.macdSignalBuffer[pIDX];
bool isMACDCrossedOverSignal = isMACDOverSignal &&
!isMACDOverSignalPrev;
//
bool isMACDUnderSignal = conditions.macdBuffer[cIDX] < conditions.macdSignalBuffer[cIDX];
bool isMACDUnderSignalPrev = conditions.macdBuffer[pIDX] < conditions.macdSignalBuffer[pIDX];
bool isMACDCrossedUnderSignal = isMACDUnderSignal &&
!isMACDUnderSignalPrev;
//
// MOMENTUM ...
//
bool isMomentumBullish = conditions.momentumBuffer[cIDX] > mInputs.momentumBullishLevel;
bool isMomentumBullishPrev = conditions.momentumBuffer[pIDX] > mInputs.momentumBullishLevel;
bool isMomentumSwitchedToBullish = isMomentumBullish &&
!isMomentumBullishPrev;
//
bool isMomentumBearish = conditions.momentumBuffer[cIDX] < mInputs.momentumBearishLevel;
bool isMomentumBearishPrev = conditions.momentumBuffer[pIDX] < mInputs.momentumBearishLevel;
bool isMomentumSwitchedToBearish = isMomentumBearish &&
!isMomentumBearishPrev;
//
// STOCHASTIC ...
//
bool isStochasticBullish = conditions.stochasticBuffer[cIDX] > mInputs.stochasticReversalLevel;
bool isStochasticBullishPrev = conditions.stochasticBuffer[pIDX] > mInputs.stochasticReversalLevel;
bool isStochasticSwitchedToBullish = isStochasticBullish &&
!isStochasticBullishPrev;
//
bool isStochasticBearish = conditions.stochasticBuffer[cIDX] < mInputs.stochasticReversalLevel;
bool isStochasticBearishPrev = conditions.stochasticBuffer[pIDX] < mInputs.stochasticReversalLevel;
bool isStochasticSwitchedToBearish = isStochasticBearish &&
!isStochasticBearishPrev;
//
bool isStochasticOverSignal = conditions.stochasticBuffer[cIDX] > conditions.stochasticSignalBuffer[cIDX];
bool isStochasticOverSignalPrev = conditions.stochasticBuffer[pIDX] > conditions.stochasticSignalBuffer[pIDX];
bool isStochasticCrossedOverSignal = isStochasticOverSignal &&
!isStochasticOverSignalPrev;
//
bool isStochasticUnderSignal = conditions.stochasticBuffer[cIDX] < conditions.stochasticSignalBuffer[cIDX];
bool isStochasticUnderSignalPrev = conditions.stochasticBuffer[pIDX] < conditions.stochasticSignalBuffer[pIDX];
bool isStochasticCrossedUnderSignal = isStochasticUnderSignal &&
!isStochasticUnderSignalPrev;
//
bool isStochasticOB = conditions.stochasticBuffer[cIDX] > mInputs.stochasticOBLevel;
bool isStochasticOBPrev = conditions.stochasticBuffer[pIDX] > mInputs.stochasticOBLevel;
bool isStochasticCrossedOverOB = isStochasticOB &&
!isStochasticOBPrev;
//
bool isStochasticUnderOB = conditions.stochasticBuffer[cIDX] < mInputs.stochasticOBLevel;
bool isStochasticUnderOBPrev = conditions.stochasticBuffer[pIDX] < mInputs.stochasticOBLevel;
bool isStochasticCrossedUnderOB = isStochasticUnderOB &&
!isStochasticUnderOBPrev;
//
bool isStochasticOS = conditions.stochasticBuffer[cIDX] < mInputs.stochasticOSLevel;
bool isStochasticOSPrev = conditions.stochasticBuffer[pIDX] < mInputs.stochasticOSLevel;
bool isStochasticCrossedUnderOS = isStochasticOS &&
!isStochasticOSPrev;
//
bool isStochasticOverOS = conditions.stochasticBuffer[cIDX] > mInputs.stochasticOSLevel;
bool isStochasticOverOSPrev = conditions.stochasticBuffer[pIDX] > mInputs.stochasticOSLevel;
bool isStochasticCrossedOverOS = isStochasticOverOS &&
!isStochasticOverOSPrev;
//
//
//
//
conditions.isCCIOB = isCCIOB;
conditions.isCCIOS = isCCIOS;
conditions.isRSIOB = isRSIOB;
conditions.isRSIOS = isRSIOS;
conditions.isMFIOB = isMFIOB;
conditions.isMFIOS = isMFIOS;
conditions.isACBullish = isACBullish;
conditions.isACBearish = isACBearish;
conditions.isACOverMax = isACOverMax;
conditions.isADOverMax = isADOverMax;
conditions.isACUnderMin = isACUnderMin;
conditions.isADUnderMin = isADUnderMin;
conditions.isADXBullish = isADXBullish;
conditions.isADXBearish = isADXBearish;
conditions.isCCIBullish = isCCIBullish;
conditions.isCCIBearish = isCCIBearish;
conditions.isRSIBullish = isRSIBullish;
conditions.isRSIBearish = isRSIBearish;
conditions.isMFIBullish = isMFIBullish;
conditions.isMFIBearish = isMFIBearish;
conditions.isRVIBullish = isRVIBullish;
conditions.isRVIBearish = isRVIBearish;
conditions.isATROverLast = isATROverLast;
conditions.isMACDBullish = isMACDBullish;
conditions.isMACDBearish = isMACDBearish;
conditions.isATRUnderLast = isATRUnderLast;
conditions.isADBiggerLast = isADBiggerLast;
conditions.isADLesserLast = isADLesserLast;
conditions.isStochasticOB = isStochasticOB;
conditions.isStochasticOS = isStochasticOS;
conditions.isADXBiggerLast = isADXBiggerLast;
conditions.isADXLesserLast = isADXLesserLast;
conditions.isRVIOverSignal = isRVIOverSignal;
conditions.isRVIUnderSignal = isRVIUnderSignal;
conditions.isMACDOverSignal = isMACDOverSignal;
conditions.isMACDUnderSignal = isMACDUnderSignal;
conditions.isMomentumBullish = isMomentumBullish;
conditions.isMomentumBearish = isMomentumBearish;
conditions.isADXOverThreshold = isADXOverThreshold;
conditions.isDXPBiggerThanDXN = isDXPBiggerThanDXN;
conditions.isDXNBiggerThanDXP = isDXNBiggerThanDXP;
conditions.isCCICrossedOverOB = isCCICrossedOverOB;
conditions.isCCICrossedOverOS = isCCICrossedOverOS;
conditions.isRSICrossedOverOB = isRSICrossedOverOB;
conditions.isRSICrossedOverOS = isRSICrossedOverOS;
conditions.isMFICrossedOverOB = isMFICrossedOverOB;
conditions.isMFICrossedOverOS = isMFICrossedOverOS;
conditions.isADXUnderThreshold = isADXUnderThreshold;
conditions.isCCICrossedUnderOB = isCCICrossedUnderOB;
conditions.isCCICrossedUnderOS = isCCICrossedUnderOS;
conditions.isRSICrossedUnderOB = isRSICrossedUnderOB;
conditions.isRSICrossedUnderOS = isRSICrossedUnderOS;
conditions.isMFICrossedUnderOB = isMFICrossedUnderOB;
conditions.isMFICrossedUnderOS = isMFICrossedUnderOS;
conditions.isStochasticBullish = isStochasticBullish;
conditions.isStochasticBearish = isStochasticBearish;
conditions.isACSwitchedToBullish = isACSwitchedToBullish;
conditions.isACSwitchedToBearish = isACSwitchedToBearish;
conditions.isADXSwitchedToBullish = isADXSwitchedToBullish;
conditions.isADXSwitchedToBearish = isADXSwitchedToBearish;
conditions.isCCISwitchedToBullish = isCCISwitchedToBullish;
conditions.isCCISwitchedToBearish = isCCISwitchedToBearish;
conditions.isRSISwitchedToBullish = isRSISwitchedToBullish;
conditions.isRSISwitchedToBearish = isRSISwitchedToBearish;
conditions.isMFISwitchedToBullish = isMFISwitchedToBullish;
conditions.isMFISwitchedToBearish = isMFISwitchedToBearish;
conditions.isRVISwitchedToBullish = isRVISwitchedToBullish;
conditions.isRVISwitchedToBearish = isRVISwitchedToBearish;
conditions.isRVICrossedOverSignal = isRVICrossedOverSignal;
conditions.isStochasticOverSignal = isStochasticOverSignal;
conditions.isStochasticUnderSignal = isStochasticUnderSignal;
conditions.isRVICrossedUnderSignal = isRVICrossedUnderSignal;
conditions.isMACDSwitchedToBullish = isMACDSwitchedToBullish;
conditions.isMACDSwitchedToBearish = isMACDSwitchedToBearish;
conditions.isMACDCrossedOverSignal = isMACDCrossedOverSignal;
conditions.isMACDCrossedUnderSignal = isMACDCrossedUnderSignal;
conditions.isStochasticCrossedOverOB = isStochasticCrossedOverOB;
conditions.isStochasticCrossedOverOS = isStochasticCrossedOverOS;
conditions.isStochasticCrossedUnderOB = isStochasticCrossedUnderOB;
conditions.isStochasticCrossedUnderOS = isStochasticCrossedUnderOS;
conditions.isMomentumSwitchedToBullish = isMomentumSwitchedToBullish;
conditions.isMomentumSwitchedToBearish = isMomentumSwitchedToBearish;
conditions.isStochasticSwitchedToBullish = isStochasticSwitchedToBullish;
conditions.isStochasticSwitchedToBearish = isStochasticSwitchedToBearish;
conditions.isStochasticCrossedOverSignal = isStochasticCrossedOverSignal;
conditions.isStochasticCrossedUnderSignal = isStochasticCrossedUnderSignal;
//
Cleanup();
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
X121XOCSInputs mInputs; // Inputs ...
//
// Buffers ...
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[];
//
void Calculate(
int barIndex = 0,
int maxRequiredBars = 100 //
)
{
//
// Buffers ...
if (barIndex < 0)
{
barIndex = 0;
}
//
// AC ...
CopyBuffer(
mHandler,
X121_XOSCS_XAC_LINE,
barIndex,
maxRequiredBars,
acBuffer //
);
//
// AD ...
CopyBuffer(
mHandler,
X121_XOSCS_XAD_LINE,
barIndex,
maxRequiredBars,
adBuffer //
);
//
// ADX ...
CopyBuffer(
mHandler,
X121_XOSCS_XADX_LINE,
barIndex,
maxRequiredBars,
adxBuffer //
);
//
// ADX P ...
CopyBuffer(
mHandler,
X121_XOSCS_XADX_P_LINE,
barIndex,
maxRequiredBars,
adxpBuffer //
);
//
// ADX N ...
CopyBuffer(
mHandler,
X121_XOSCS_XADX_N_LINE,
barIndex,
maxRequiredBars,
adxnBuffer //
);
//
// ATR ...
CopyBuffer(
mHandler,
X121_XOSCS_XATR_LINE,
barIndex,
maxRequiredBars,
atrBuffer //
);
//
// CCI ...
CopyBuffer(
mHandler,
X121_XOSCS_XCCI_LINE,
barIndex,
maxRequiredBars,
cciBuffer //
);
//
// RSI ...
CopyBuffer(
mHandler,
X121_XOSCS_XRSI_LINE,
barIndex,
maxRequiredBars,
rsiBuffer //
);
//
// MFI ...
CopyBuffer(
mHandler,
X121_XOSCS_XMFI_LINE,
barIndex,
maxRequiredBars,
mfiBuffer //
);
//
// MOMENTUM ...
CopyBuffer(
mHandler,
X121_XOSCS_XMOMENTUM_LINE,
barIndex,
maxRequiredBars,
momentumBuffer //
);
//
// RVI ...
CopyBuffer(
mHandler,
X121_XOSCS_XRVI_LINE,
barIndex,
maxRequiredBars,
rviBuffer //
);
//
// RVI Signal ...
CopyBuffer(
mHandler,
X121_XOSCS_XRVI_S_LINE,
barIndex,
maxRequiredBars,
rviSignalBuffer //
);
//
// MACD ...
CopyBuffer(
mHandler,
X121_XOSCS_XMACD_LINE,
barIndex,
maxRequiredBars,
macdBuffer //
);
//
// MACD Signal ...
CopyBuffer(
mHandler,
X121_XOSCS_XMACD_S_LINE,
barIndex,
maxRequiredBars,
macdSignalBuffer //
);
//
// STOCHASTIC ...
CopyBuffer(
mHandler,
X121_XOSCS_XSTOCHASTIC_LINE,
barIndex,
maxRequiredBars,
stochasticBuffer //
);
//
// STOCHASTIC Signal ...
CopyBuffer(
mHandler,
X121_XOSCS_XSTOCHASTIC_S_LINE,
barIndex,
maxRequiredBars,
stochasticSignalBuffer //
);
}
//
void Cleanup(
int maxAllowed = 100 //
)
{
//
CleanupArray(
acBuffer,
maxAllowed //
);
//
CleanupArray(
adBuffer,
maxAllowed //
);
//
CleanupArray(
atrBuffer,
maxAllowed //
);
//
CleanupArray(
cciBuffer,
maxAllowed //
);
//
CleanupArray(
rsiBuffer,
maxAllowed //
);
//
CleanupArray(
mfiBuffer,
maxAllowed //
);
//
CleanupArray(
rviBuffer,
maxAllowed //
);
//
CleanupArray(
adxBuffer,
maxAllowed //
);
//
CleanupArray(
adxpBuffer,
maxAllowed //
);
//
CleanupArray(
adxnBuffer,
maxAllowed //
);
//
CleanupArray(
macdBuffer,
maxAllowed //
);
//
CleanupArray(
momentumBuffer,
maxAllowed //
);
//
CleanupArray(
rviSignalBuffer,
maxAllowed //
);
//
CleanupArray(
macdSignalBuffer,
maxAllowed //
);
//
CleanupArray(
stochasticBuffer,
maxAllowed //
);
//
CleanupArray(
stochasticSignalBuffer,
maxAllowed //
);
}
//
};