complete all indicator/oscillator(s) helper classes ...

This commit is contained in:
2024-05-18 06:12:14 +03:30
parent fb0b6fe38f
commit 8c81f649dc
9 changed files with 2367 additions and 630 deletions
+755 -76
View File
@@ -30,7 +30,20 @@
//
enum ENUM_XCHMA_BUFFERS
{
XCHMA_MAIN_LINE = 0
//
// LC ...
XCHMA_LC_FAST_LINE = 0,
XCHMA_LC_SLOW_LINE = 1,
//
// MC ...
XCHMA_MC_FAST_LINE = 2,
XCHMA_MC_SLOW_LINE = 3,
//
// SC ...
XCHMA_SC_FAST_LINE = 4,
XCHMA_SC_SLOW_LINE = 5,
//
XCHMA_HOT_STATE_LINE = 6,
};
//
@@ -39,7 +52,67 @@ struct XXCHMAInputs
{
//
// Props ...
string tmp;
//
// Hot Areas ...
bool drawHotAreas; // Draw Hot Areas Symbol
uchar hotBullishArrowCode; // Hot Bullish Arrow Code
color hotBullishArrowColor; // Hot Bullish Arrow Color
uchar hotBearishArrowCode; // Hot Bearish Arrow Code
color hotBearishArrowColor; // Hot Bearish Arrow Color
//
// Long Cycle ...
// LC Market ...
int lcFastLength; // Fast Length
int lcSlowLength; // Slow Length
ENUM_MA_METHOD lcMethod; // Calculation Method
ENUM_APPLIED_PRICE lcAppliedTo; // Applied To
// LC Style ...
int lcDrawWidth; // Draw Width
ENUM_DRAW_TYPE lcDrawType; // Draw Type
ENUM_LINE_STYLE lcDrawStyle; // Draw Style
color lcFastColor; // Fast Color
color lcSlowColor; // Slow Color
// LC Drawings ...
bool lcDrawFast; // Draw Fast
bool lcDrawSlow; // Draw Slow
bool lcDrawCrosses; // Draw Cross Lines
//
// Medium Cycle ...
// MC Market ...
int mcFastLength; // Fast Length
int mcSlowLength; // Slow Length
ENUM_MA_METHOD mcMethod; // Calculation Method
ENUM_APPLIED_PRICE mcAppliedTo; // Applied To
// MC Style ...
int mcDrawWidth; // Draw Width
ENUM_DRAW_TYPE mcDrawType; // Draw Type
ENUM_LINE_STYLE mcDrawStyle; // Draw Style
color mcFastColor; // Fast Color
color mcSlowColor; // Slow Color
// MC Drawings ...
bool mcDrawFast; // Draw Fast
bool mcDrawSlow; // Draw Slow
bool mcDrawCrosses; // Draw Cross Lines
//
// Short Cycle ...
// SC Market ...
int scFastLength; // Fast Length
int scSlowLength; // Slow Length
ENUM_MA_METHOD scMethod; // Calculation Method
ENUM_APPLIED_PRICE scAppliedTo; // Applied To
// SC Style ...
int scDrawWidth; // Draw Width
ENUM_DRAW_TYPE scDrawType; // Draw Type
ENUM_LINE_STYLE scDrawStyle; // Draw Style
color scFastColor; // Fast Color
color scSlowColor; // Slow Color
// SC Drawings ...
bool scDrawFast; // Draw Fast
bool scDrawSlow; // Draw Slow
bool scDrawCrosses; // Draw Cross Lines
//
// Constructor(s) ...
@@ -57,6 +130,66 @@ struct XXCHMAInputs
void Clean()
{
//
// Hot Areas ...
drawHotAreas = false;
hotBullishArrowCode = 228;
hotBullishArrowColor = CLR_NONE;
hotBearishArrowCode = 230;
hotBearishArrowColor = CLR_NONE;
//
// Long Cycle ...
// LC Market ...
lcFastLength = 20;
lcSlowLength = 50;
lcMethod = MODE_EMA;
lcAppliedTo = PRICE_CLOSE;
// LC Style ...
lcDrawWidth = 1;
lcDrawType = DRAW_NONE;
lcDrawStyle = STYLE_DOT;
lcFastColor = CLR_NONE;
lcSlowColor = CLR_NONE;
// LC Drawings ...
lcDrawFast = false;
lcDrawSlow = false;
lcDrawCrosses = false;
//
// Medium Cycle ...
// MC Market ...
mcFastLength = 10;
mcSlowLength = 30;
mcMethod = MODE_EMA;
mcAppliedTo = PRICE_CLOSE;
// MC Style ...
mcDrawWidth = 1;
mcDrawType = DRAW_NONE;
mcDrawStyle = STYLE_DOT;
mcFastColor = CLR_NONE;
mcSlowColor = CLR_NONE;
// MC Drawings ...
mcDrawFast = false;
mcDrawSlow = false;
mcDrawCrosses = false;
//
// Short Cycle ...
// SC Market ...
scFastLength = 7;
scSlowLength = 14;
scMethod = MODE_EMA;
scAppliedTo = PRICE_CLOSE;
// SC Style ...
scDrawWidth = 1;
scDrawType = DRAW_NONE;
scDrawStyle = STYLE_SOLID;
scFastColor = CLR_NONE;
scSlowColor = CLR_NONE;
// SC Drawings ...
scDrawFast = false;
scDrawSlow = false;
scDrawCrosses = false;
}
//
@@ -64,6 +197,66 @@ struct XXCHMAInputs
void Default()
{
//
// Hot Areas ...
drawHotAreas = false;
hotBullishArrowCode = 228;
hotBullishArrowColor = CLR_NONE;
hotBearishArrowCode = 230;
hotBearishArrowColor = CLR_NONE;
//
// Long Cycle ...
// LC Market ...
lcFastLength = 20;
lcSlowLength = 50;
lcMethod = MODE_EMA;
lcAppliedTo = PRICE_CLOSE;
// LC Style ...
lcDrawWidth = 1;
lcDrawType = DRAW_LINE;
lcDrawStyle = STYLE_DOT;
lcFastColor = clrAqua;
lcSlowColor = clrFuchsia;
// LC Drawings ...
lcDrawFast = true;
lcDrawSlow = true;
lcDrawCrosses = false;
//
// Medium Cycle ...
// MC Market ...
mcFastLength = 10;
mcSlowLength = 30;
mcMethod = MODE_EMA;
mcAppliedTo = PRICE_CLOSE;
// MC Style ...
mcDrawWidth = 1;
mcDrawType = DRAW_LINE;
mcDrawStyle = STYLE_DOT;
mcFastColor = clrLime;
mcSlowColor = clrRed;
// MC Drawings ...
mcDrawFast = true;
mcDrawSlow = true;
mcDrawCrosses = false;
//
// Short Cycle ...
// SC Market ...
scFastLength = 7;
scSlowLength = 14;
scMethod = MODE_EMA;
scAppliedTo = PRICE_CLOSE;
// SC Style ...
scDrawWidth = 1;
scDrawType = DRAW_LINE;
scDrawStyle = STYLE_SOLID;
scFastColor = clrLightBlue;
scSlowColor = clrLightSalmon;
// SC Drawings ...
scDrawFast = true;
scDrawSlow = true;
scDrawCrosses = false;
}
//
@@ -76,7 +269,11 @@ struct XXCHMAInputs
//
result =
//
false
(lcFastLength >= 4 && lcSlowLength > lcFastLength) &&
(mcFastLength >= 4 && mcSlowLength > mcFastLength) &&
(scFastLength >= 4 && scSlowLength > scFastLength) &&
(lcFastLength > mcFastLength &&
mcFastLength > scFastLength)
//
;
@@ -92,7 +289,11 @@ struct XXCHMAInputs
int result = 0;
//
result = MathMax(0, 0);
result = MathMax(scFastLength, scSlowLength);
result = MathMax(result, lcFastLength);
result = MathMax(result, lcSlowLength);
result = MathMax(result, mcFastLength);
result = MathMax(result, mcSlowLength);
//
return result;
@@ -124,7 +325,7 @@ public:
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XXCHMAInputs &inputs // Inputs
XXCHMAInputs &inputs // Inputs
)
{
//
@@ -144,21 +345,109 @@ public:
//
mInputs = inputs;
// //
// // ArraySetAsSeries(shortExit2Buffer, true);
// mHandler = iCustom(
// mSymbol,
// mPeriod,
// "x-saherelm.x",
// //
// // Inputs ...
// //
// );
// result = mHandler != INVALID_HANDLE;
// if (!result)
// {
// return result;
// }
//
ArraySetAsSeries(scFastBuffer, true);
ArraySetAsSeries(scSlowBuffer, true);
ArraySetAsSeries(mcFastBuffer, true);
ArraySetAsSeries(mcSlowBuffer, true);
ArraySetAsSeries(lcFastBuffer, true);
ArraySetAsSeries(lcSlowBuffer, true);
ArraySetAsSeries(hotStateBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xchma",
//
// Inputs ...
//
// Hot Areas ...
"",
mInputs.drawHotAreas, // Draw Hot Areas Symbol
mInputs.hotBullishArrowCode, // Hot Bullish Arrow Code
mInputs.hotBullishArrowColor, // Hot Bullish Arrow Color
mInputs.hotBearishArrowCode, // Hot Bearish Arrow Code
mInputs.hotBearishArrowColor, // Hot Bearish Arrow Color
//
// Long Cycle ...
"",
//
// LC Market ...
"",
mInputs.lcFastLength, // Fast Length
mInputs.lcSlowLength, // Slow Length
mInputs.lcMethod, // Calculation Method
mInputs.lcAppliedTo, // Applied To
//
// LC Style ...
"",
mInputs.lcDrawWidth, // Draw Width
mInputs.lcDrawType, // Draw Type
mInputs.lcDrawStyle, // Draw Style
mInputs.lcFastColor, // Fast Color
mInputs.lcSlowColor, // Slow Color
//
// LC Drawings ...
"",
mInputs.lcDrawFast, // Draw Fast
mInputs.lcDrawSlow, // Draw Slow
mInputs.lcDrawCrosses, // Draw Cross Lines
//
// Medium Cycle ...
"",
//
// MC Market ...
"",
mInputs.mcFastLength, // Fast Length
mInputs.mcSlowLength, // Slow Length
mInputs.mcMethod, // Calculation Method
mInputs.mcAppliedTo, // Applied To
//
// MC Style ...
"",
mInputs.mcDrawWidth, // Draw Width
mInputs.mcDrawType, // Draw Type
mInputs.mcDrawStyle, // Draw Style
mInputs.mcFastColor, // Fast Color
mInputs.mcSlowColor, // Slow Color
//
// MC Drawings ...
"",
mInputs.mcDrawFast, // Draw Fast
mInputs.mcDrawSlow, // Draw Slow
mInputs.mcDrawCrosses, // Draw Cross Lines
//
// Short Cycle ...
"",
//
// SC Market ...
"",
mInputs.scFastLength, // Fast Length
mInputs.scSlowLength, // Slow Length
mInputs.scMethod, // Calculation Method
mInputs.scAppliedTo, // Applied To
//
// SC Style ...
"",
mInputs.scDrawWidth, // Draw Width
mInputs.scDrawType, // Draw Type
mInputs.scDrawStyle, // Draw Style
mInputs.scFastColor, // Fast Color
mInputs.scSlowColor, // Slow Color
//
// SC Drawings ...
"",
mInputs.scDrawFast, // Draw Fast
mInputs.scDrawSlow, // Draw Slow
mInputs.scDrawCrosses // Draw Cross Lines
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
@@ -189,56 +478,365 @@ public:
//
// Buffers ...
// //
// double GetMain(
// int barIndex // Bar Index
// )
// {
// //
// if (barIndex < 0)
// {
// barIndex = 0;
// }
// //
// Calculate();
//
// Short ...
// //
// int count = ArraySize(mainBuffer);
// if (barIndex >= count)
// {
// barIndex = count - 1;
// }
//
double GetSCFast(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
// //
// return mainBuffer[barIndex];
// }
//
Calculate();
// //
// // Copy Required Long Exits 2 ...
// int CopyLongExit2(
// int start, // Start
// int count, // Number of Items for read
// double &buffer[], // Dest Buffer
// bool forceClean = true // Force To Clean buffer
// )
// {
// //
// // Update Calculations ...
// Calculate();
//
int count = ArraySize(scFastBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
// //
// // Copy Items ...
// return Copy(
// start,
// count,
// longExit2Buffer,
// buffer,
// forceClean
// //
// );
// }
//
return scFastBuffer[barIndex];
}
//
// Copy Required Items ...
int CopySCFast(
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,
scFastBuffer,
buffer,
forceClean
//
);
}
//
double GetSCSlow(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(scSlowBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return scSlowBuffer[barIndex];
}
//
// Copy Required Items ...
int CopySCSlow(
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,
scSlowBuffer,
buffer,
forceClean
//
);
}
//
// Medium ...
//
double GetMCFast(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mcFastBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mcFastBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMCFast(
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,
mcFastBuffer,
buffer,
forceClean
//
);
}
//
double GetMCSlow(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mcSlowBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mcSlowBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMCSlow(
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,
mcSlowBuffer,
buffer,
forceClean
//
);
}
//
// Long ...
//
double GetLCFast(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(lcFastBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return lcFastBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyLCFast(
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,
lcFastBuffer,
buffer,
forceClean
//
);
}
//
double GetLCSlow(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(lcSlowBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return lcSlowBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyLCSlow(
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,
lcSlowBuffer,
buffer,
forceClean
//
);
}
//
double GetHotState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(hotStateBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return hotStateBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyHotState(
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,
hotStateBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
@@ -252,7 +850,13 @@ private:
//
// Buffers ...
// double longExit1Buffer[];
double scFastBuffer[];
double scSlowBuffer[];
double mcFastBuffer[];
double mcSlowBuffer[];
double lcFastBuffer[];
double lcSlowBuffer[];
double hotStateBuffer[];
//
// Tools ...
@@ -264,16 +868,91 @@ private:
//
int totalBars = CountBars();
// //
// // Short Exit 2 ...
// CopyBuffer(
// mHandler,
// X_CHE_SHORT_EXIT_2_LINE,
// 0,
// totalBars,
// shortExit2Buffer
// //
// );
//
// Short Cycle ...
//
// Fast ...
CopyBuffer(
mHandler,
XCHMA_SC_FAST_LINE,
0,
totalBars,
scFastBuffer
//
);
//
// Slow ...
CopyBuffer(
mHandler,
XCHMA_SC_SLOW_LINE,
0,
totalBars,
scSlowBuffer
//
);
//
// Medium Cycle ...
//
// Fast ...
CopyBuffer(
mHandler,
XCHMA_MC_FAST_LINE,
0,
totalBars,
mcFastBuffer
//
);
//
// Slow ...
CopyBuffer(
mHandler,
XCHMA_MC_SLOW_LINE,
0,
totalBars,
mcSlowBuffer
//
);
//
// Long Cycle ...
//
// Fast ...
CopyBuffer(
mHandler,
XCHMA_LC_FAST_LINE,
0,
totalBars,
lcFastBuffer
//
);
//
// Slow ...
CopyBuffer(
mHandler,
XCHMA_LC_SLOW_LINE,
0,
totalBars,
lcSlowBuffer
//
);
//
// Hot State ...
CopyBuffer(
mHandler,
XCHMA_HOT_STATE_LINE,
0,
totalBars,
hotStateBuffer
//
);
}
}