1144 lines
24 KiB
Plaintext
1144 lines
24 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Helper Class Library
|
|
// ----------------------------------------------
|
|
// Name: XSCX3VWAPHelper
|
|
// 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.xhelper.class.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
enum ENUM_X3VWAP_BUFFERS
|
|
{
|
|
//
|
|
X3VWAP_FAST_LINE = 0,
|
|
X3VWAP_FAST_STATE_LINE = 8,
|
|
X3VWAP_MID_LINE = 1,
|
|
X3VWAP_MID_STATE_LINE = 9,
|
|
X3VWAP_SLOW_LINE = 2,
|
|
X3VWAP_SLOW_STATE_LINE = 10,
|
|
};
|
|
|
|
//
|
|
enum ENUM_X3VWAP_STATES
|
|
{
|
|
//
|
|
X3VWAP_STATE_BULLISH = 1,
|
|
X3VWAP_STATE_BEARISH = 2,
|
|
X3VWAP_STATE_NEUTURAL = 3,
|
|
};
|
|
|
|
//
|
|
// Input Models ...
|
|
struct X3VWAPInputs
|
|
{
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Market ...
|
|
int fastLength; // Fast Length
|
|
int midLength; // Mid Length
|
|
int slowLength; // Slow Length
|
|
ENUM_APPLIED_PRICE appliedTo; // Applied To
|
|
|
|
//
|
|
// Presentation ...
|
|
|
|
//
|
|
bool showFast; // Show Fast
|
|
bool showMid; // Show Mid
|
|
bool showSlow; // Show Slow
|
|
|
|
//
|
|
// Constructor(s) ...
|
|
X3VWAPInputs()
|
|
{
|
|
//
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Clean ...
|
|
void Clean()
|
|
{
|
|
//
|
|
fastLength = 0;
|
|
midLength = 0;
|
|
slowLength = 0;
|
|
appliedTo = PRICE_CLOSE;
|
|
|
|
//
|
|
showFast = false;
|
|
showMid = false;
|
|
showSlow = false;
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
void Default()
|
|
{
|
|
//
|
|
fastLength = 50;
|
|
midLength = 100;
|
|
slowLength = 200;
|
|
appliedTo = PRICE_CLOSE;
|
|
|
|
//
|
|
showFast = true;
|
|
showMid = true;
|
|
showSlow = true;
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
fastLength > 2 &&
|
|
midLength > fastLength &&
|
|
slowLength > midLength
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve MAx Length ...
|
|
int Max()
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
result = MathMax(fastLength, midLength);
|
|
result = MathMax(result, slowLength);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Define Conditions ...
|
|
struct X3VWAPConditions
|
|
{
|
|
//
|
|
// Common ...
|
|
string symbol;
|
|
ENUM_TIMEFRAMES period;
|
|
datetime time;
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
//
|
|
double fasts[];
|
|
double fastStates[];
|
|
double mids[];
|
|
double midStates[];
|
|
double slows[];
|
|
double slowStates[];
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
bool isFastBullish;
|
|
bool isFastBearish;
|
|
bool isFastNeutural;
|
|
|
|
//
|
|
bool isMidBullish;
|
|
bool isMidBearish;
|
|
bool isMidNeutural;
|
|
|
|
//
|
|
bool isSlowBullish;
|
|
bool isSlowBearish;
|
|
bool isSlowNeutural;
|
|
|
|
//
|
|
bool isFastOverMid;
|
|
bool isMidOverSlow;
|
|
|
|
//
|
|
bool isFastUnderMid;
|
|
bool isMidUnderSlow;
|
|
|
|
//
|
|
bool isBullishState;
|
|
bool isBearishState;
|
|
bool isNeuturalState;
|
|
|
|
//
|
|
bool isBullishOrdered;
|
|
bool isBearishOrdered;
|
|
|
|
//
|
|
bool isSwitchedToBullishOrdered;
|
|
bool isSwitchedToBearishOrdered;
|
|
|
|
//
|
|
bool isSwitchedToBullishState;
|
|
bool isSwitchedToBearishState;
|
|
bool isSwitchedToNeuturalState;
|
|
|
|
//
|
|
void Clean()
|
|
{
|
|
//
|
|
Clean(fasts);
|
|
Clean(mids);
|
|
Clean(slows);
|
|
|
|
//
|
|
Clean(fastStates);
|
|
Clean(midStates);
|
|
Clean(slowStates);
|
|
|
|
//
|
|
ArraySetAsSeries(fasts, true);
|
|
ArraySetAsSeries(mids, true);
|
|
ArraySetAsSeries(slows, true);
|
|
|
|
//
|
|
ArraySetAsSeries(fastStates, true);
|
|
ArraySetAsSeries(midStates, true);
|
|
ArraySetAsSeries(slowStates, true);
|
|
|
|
//
|
|
isFastBullish = false;
|
|
isFastBearish = false;
|
|
isFastNeutural = false;
|
|
isMidBullish = false;
|
|
isMidBearish = false;
|
|
isMidNeutural = false;
|
|
isSlowBullish = false;
|
|
isSlowBearish = false;
|
|
isSlowNeutural = false;
|
|
isFastOverMid = false;
|
|
isMidOverSlow = false;
|
|
isFastUnderMid = false;
|
|
isMidUnderSlow = false;
|
|
isBullishState = false;
|
|
isBearishState = false;
|
|
isNeuturalState = false;
|
|
isBullishOrdered = false;
|
|
isBearishOrdered = false;
|
|
isSwitchedToBullishOrdered = false;
|
|
isSwitchedToBearishOrdered = false;
|
|
isSwitchedToBullishState = false;
|
|
isSwitchedToBearishState = false;
|
|
isSwitchedToNeuturalState = false;
|
|
}
|
|
|
|
//
|
|
void GenerateScore(
|
|
double &bullishScore,
|
|
double &bearishScore //
|
|
)
|
|
{
|
|
//
|
|
bullishScore = 0;
|
|
bearishScore = 0;
|
|
|
|
//
|
|
// Since We have to Use this
|
|
// Only for Filtering Signals ...
|
|
// We Can Ignore Scoring ...
|
|
// or Complete this later ...
|
|
}
|
|
|
|
//
|
|
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 =
|
|
//
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
"[" + GetTag() + "]" + separator +
|
|
(onlyConditions
|
|
? ""
|
|
: commonStr) +
|
|
(!includeScores
|
|
? ""
|
|
: scoresStr) +
|
|
" " + separator +
|
|
(onlyCommons
|
|
? ""
|
|
: conditionsStr) +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string GetTag()
|
|
{
|
|
return "X3VWAP";
|
|
}
|
|
};
|
|
|
|
//
|
|
// Class ...
|
|
class XSCX3VWAPHelper : public XSCBaseHelper
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Constructors ...
|
|
XSCX3VWAPHelper()
|
|
: XSCBaseHelper(_Symbol, _Period)
|
|
{
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
~XSCX3VWAPHelper()
|
|
{
|
|
//
|
|
Clean(fastBuffer);
|
|
Clean(midBuffer);
|
|
Clean(slowBuffer);
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
bool Init(
|
|
string symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES period, // Trading Period
|
|
X3VWAPInputs &inputs // Inputs
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
mSymbol = symbol;
|
|
mPeriod = period;
|
|
|
|
//
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mInputs = inputs;
|
|
|
|
//
|
|
ArraySetAsSeries(fastBuffer, true);
|
|
ArraySetAsSeries(fastStateBuffer, true);
|
|
|
|
//
|
|
ArraySetAsSeries(midBuffer, true);
|
|
ArraySetAsSeries(midStateBuffer, true);
|
|
|
|
//
|
|
ArraySetAsSeries(slowBuffer, true);
|
|
ArraySetAsSeries(slowStateBuffer, true);
|
|
|
|
//
|
|
mHandler = iCustom(
|
|
mSymbol,
|
|
mPeriod,
|
|
"x-saherelm.x3vwap",
|
|
//
|
|
// Inputs ...
|
|
//
|
|
// Market ...
|
|
"",
|
|
mInputs.fastLength,
|
|
mInputs.midLength,
|
|
mInputs.slowLength,
|
|
mInputs.appliedTo,
|
|
//
|
|
// Presentation ...
|
|
"",
|
|
//
|
|
mInputs.showFast,
|
|
mInputs.showMid,
|
|
mInputs.showSlow
|
|
//
|
|
);
|
|
result = mHandler != INVALID_HANDLE;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Inputs ...
|
|
|
|
//
|
|
X3VWAPInputs GetInputs()
|
|
{
|
|
return mInputs;
|
|
}
|
|
|
|
//
|
|
bool SetInputs(
|
|
X3VWAPInputs &inputs // Configs
|
|
)
|
|
{
|
|
//
|
|
return Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
inputs
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
//
|
|
double GetFast(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(fastBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fastBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyFast(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
fastBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
double GetFastState(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(fastStateBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fastStateBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyFastState(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
fastStateBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
double GetMid(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(midBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return midBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyMid(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
midBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
double GetMidState(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(midStateBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return midStateBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyMidState(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
midStateBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
double GetSlow(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(slowBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return slowBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopySlow(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
slowBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
double GetSlowState(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(slowStateBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return slowStateBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopySlowState(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
slowStateBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Converts to State ...
|
|
ENUM_X3VWAP_STATES ToState(double value)
|
|
{
|
|
//
|
|
ENUM_X3VWAP_STATES result =
|
|
value == 1
|
|
? X3VWAP_STATE_BULLISH
|
|
: value == 2
|
|
? X3VWAP_STATE_BEARISH
|
|
: X3VWAP_STATE_NEUTURAL;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsBullish(double value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = ToState(value) == X3VWAP_STATE_BULLISH;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsBearish(double value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = ToState(value) == X3VWAP_STATE_BEARISH;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsNeutural(double value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = ToState(value) == X3VWAP_STATE_NEUTURAL;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
bool GetConditions(
|
|
X3VWAPConditions &conditions, //
|
|
int barIndex = 0, //
|
|
int loopback = 5 //
|
|
)
|
|
{
|
|
//
|
|
bool result = true;
|
|
|
|
//
|
|
if (loopback < 3)
|
|
{
|
|
loopback = 3;
|
|
}
|
|
|
|
//
|
|
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;
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
//
|
|
// Fast ...
|
|
CopyFast(
|
|
zIndex,
|
|
loopback,
|
|
conditions.fasts //
|
|
);
|
|
CopyFastState(
|
|
zIndex,
|
|
loopback,
|
|
conditions.fastStates //
|
|
);
|
|
|
|
//
|
|
// Mid ...
|
|
CopyMid(
|
|
zIndex,
|
|
loopback,
|
|
conditions.mids //
|
|
);
|
|
CopyMidState(
|
|
zIndex,
|
|
loopback,
|
|
conditions.midStates //
|
|
);
|
|
|
|
//
|
|
// Slow ...
|
|
CopySlow(
|
|
zIndex,
|
|
loopback,
|
|
conditions.slows //
|
|
);
|
|
CopySlowState(
|
|
zIndex,
|
|
loopback,
|
|
conditions.slowStates //
|
|
);
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
bool isFastBullish = IsBullish(conditions.fastStates[cIndex]);
|
|
bool isFastBullishPrev = IsBullish(conditions.fastStates[pIndex]);
|
|
|
|
//
|
|
bool isFastBearish = IsBearish(conditions.fastStates[cIndex]);
|
|
bool isFastBearishPrev = IsBearish(conditions.fastStates[pIndex]);
|
|
|
|
//
|
|
bool isFastNeutural = IsNeutural(conditions.fastStates[cIndex]);
|
|
bool isFastNeuturalPrev = IsNeutural(conditions.fastStates[pIndex]);
|
|
|
|
//
|
|
bool isMidBullish = IsBullish(conditions.midStates[cIndex]);
|
|
bool isMidBullishPrev = IsBullish(conditions.midStates[pIndex]);
|
|
|
|
//
|
|
bool isMidBearish = IsBearish(conditions.midStates[cIndex]);
|
|
bool isMidBearishPrev = IsBearish(conditions.midStates[pIndex]);
|
|
|
|
//
|
|
bool isMidNeutural = IsNeutural(conditions.midStates[cIndex]);
|
|
bool isMidNeuturalPrev = IsNeutural(conditions.midStates[pIndex]);
|
|
|
|
//
|
|
bool isSlowBullish = IsBullish(conditions.slowStates[cIndex]);
|
|
bool isSlowBullishPrev = IsBullish(conditions.slowStates[pIndex]);
|
|
|
|
//
|
|
bool isSlowBearish = IsBearish(conditions.slowStates[cIndex]);
|
|
bool isSlowBearishPrev = IsBearish(conditions.slowStates[pIndex]);
|
|
|
|
//
|
|
bool isSlowNeutural = IsNeutural(conditions.slowStates[cIndex]);
|
|
bool isSlowNeuturalPrev = IsNeutural(conditions.slowStates[pIndex]);
|
|
|
|
//
|
|
bool isFastOverMid =
|
|
conditions.fasts[cIndex] > conditions.mids[cIndex];
|
|
bool isFastOverMidPrev =
|
|
conditions.fasts[pIndex] > conditions.mids[pIndex];
|
|
|
|
//
|
|
bool isMidOverSlow =
|
|
conditions.mids[cIndex] > conditions.slows[cIndex];
|
|
bool isMidOverSlowPrev =
|
|
conditions.mids[pIndex] > conditions.slows[pIndex];
|
|
|
|
//
|
|
bool isFastUnderMid =
|
|
conditions.fasts[cIndex] < conditions.mids[cIndex];
|
|
bool isFastUnderMidPrev =
|
|
conditions.fasts[pIndex] < conditions.mids[pIndex];
|
|
|
|
//
|
|
bool isMidUnderSlow =
|
|
conditions.mids[cIndex] < conditions.slows[cIndex];
|
|
bool isMidUnderSlowPrev =
|
|
conditions.mids[pIndex] < conditions.slows[pIndex];
|
|
|
|
//
|
|
bool isBullishState = isFastBullish &&
|
|
isMidBullish &&
|
|
isSlowBullish;
|
|
bool isBullishStatePrev = isFastBullishPrev &&
|
|
isMidBullishPrev &&
|
|
isSlowBullishPrev;
|
|
|
|
//
|
|
bool isBearishState = isFastBearish &&
|
|
isMidBearish &&
|
|
isSlowBearish;
|
|
bool isBearishStatePrev = isFastBearishPrev &&
|
|
isMidBearishPrev &&
|
|
isSlowBearishPrev;
|
|
|
|
//
|
|
bool isNeuturalState = isFastNeutural &&
|
|
isMidNeutural &&
|
|
isSlowNeutural;
|
|
bool isNeuturalStatePrev = isFastNeuturalPrev &&
|
|
isMidNeuturalPrev &&
|
|
isSlowNeuturalPrev;
|
|
|
|
//
|
|
bool isBullishOrdered = isFastOverMid &&
|
|
isMidOverSlow;
|
|
bool isBullishOrderedPrev = isFastOverMidPrev &&
|
|
isMidOverSlowPrev;
|
|
|
|
//
|
|
bool isBearishOrdered = isFastUnderMid &&
|
|
isMidUnderSlow;
|
|
bool isBearishOrderedPrev = isFastUnderMidPrev &&
|
|
isMidUnderSlowPrev;
|
|
|
|
//
|
|
bool isSwitchedToBullishOrdered = isBullishOrdered &&
|
|
!isBullishOrderedPrev;
|
|
bool isSwitchedToBearishOrdered = isBearishOrdered &&
|
|
!isBearishOrderedPrev;
|
|
|
|
//
|
|
bool isSwitchedToBullishState = isBullishState &&
|
|
!isBullishStatePrev;
|
|
bool isSwitchedToBearishState = isBearishState &&
|
|
!isBearishStatePrev;
|
|
bool isSwitchedToNeuturalState = isNeuturalState &&
|
|
!isNeuturalStatePrev;
|
|
|
|
//
|
|
conditions.isFastBullish = isFastBullish;
|
|
conditions.isFastBearish = isFastBearish;
|
|
conditions.isFastNeutural = isFastNeutural;
|
|
conditions.isMidBullish = isMidBullish;
|
|
conditions.isMidBearish = isMidBearish;
|
|
conditions.isMidNeutural = isMidNeutural;
|
|
conditions.isSlowBullish = isSlowBullish;
|
|
conditions.isSlowBearish = isSlowBearish;
|
|
conditions.isSlowNeutural = isSlowNeutural;
|
|
conditions.isFastOverMid = isFastOverMid;
|
|
conditions.isMidOverSlow = isMidOverSlow;
|
|
conditions.isFastUnderMid = isFastUnderMid;
|
|
conditions.isMidUnderSlow = isMidUnderSlow;
|
|
conditions.isBullishState = isBullishState;
|
|
conditions.isBearishState = isBearishState;
|
|
conditions.isNeuturalState = isNeuturalState;
|
|
conditions.isBullishOrdered = isBullishOrdered;
|
|
conditions.isBearishOrdered = isBearishOrdered;
|
|
conditions.isSwitchedToBullishOrdered = isSwitchedToBullishOrdered;
|
|
conditions.isSwitchedToBearishOrdered = isSwitchedToBearishOrdered;
|
|
conditions.isSwitchedToBullishState = isSwitchedToBullishState;
|
|
conditions.isSwitchedToBearishState = isSwitchedToBearishState;
|
|
conditions.isSwitchedToNeuturalState = isSwitchedToNeuturalState;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
X3VWAPInputs mInputs; // Inputs ...
|
|
|
|
//
|
|
// Buffers ...
|
|
double fastBuffer[];
|
|
double fastStateBuffer[];
|
|
double midBuffer[];
|
|
double midStateBuffer[];
|
|
double slowBuffer[];
|
|
double slowStateBuffer[];
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Calculate Values Until Now ...
|
|
void Calculate()
|
|
{
|
|
//
|
|
int totalBars = CountBars();
|
|
if (totalBars > 1000)
|
|
{
|
|
totalBars = 1000;
|
|
}
|
|
|
|
//
|
|
// Fast ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
X3VWAP_FAST_LINE,
|
|
0,
|
|
totalBars,
|
|
fastBuffer
|
|
//
|
|
);
|
|
CopyBuffer(
|
|
mHandler,
|
|
X3VWAP_FAST_STATE_LINE,
|
|
0,
|
|
totalBars,
|
|
fastStateBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Mid ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
X3VWAP_MID_LINE,
|
|
0,
|
|
totalBars,
|
|
midBuffer
|
|
//
|
|
);
|
|
CopyBuffer(
|
|
mHandler,
|
|
X3VWAP_MID_STATE_LINE,
|
|
0,
|
|
totalBars,
|
|
midStateBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Slow ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
X3VWAP_SLOW_LINE,
|
|
0,
|
|
totalBars,
|
|
slowBuffer
|
|
//
|
|
);
|
|
CopyBuffer(
|
|
mHandler,
|
|
X3VWAP_SLOW_STATE_LINE,
|
|
0,
|
|
totalBars,
|
|
slowStateBuffer
|
|
//
|
|
);
|
|
}
|
|
};
|
|
|
|
// |