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
+344 -75
View File
@@ -30,7 +30,10 @@
//
enum ENUM_XTS_BUFFERS
{
XTS_MAIN_LINE = 0
XTS_CURRENT_LINE = 0,
XTS_NEAREST_LINE = 1,
XTS_MEDIEST_LINE = 2,
XTS_FAREST_LINE = 3,
};
//
@@ -39,7 +42,24 @@ struct XXTSInputs
{
//
// Props ...
string tmp;
//
// Current Period ...
ENUM_APPLIED_PRICE currentAppliedTo; // Current Applied To
//
// Nearest Period ...
ENUM_X_PERIOD_METHOD nearestMethod; // How to Find Nearest Period
ENUM_TIMEFRAMES nearestPeriod; // Nearest Time Frame
ENUM_APPLIED_PRICE nearestAppliedTo; // Nearest Applied To
//
// Mediest Period ...
ENUM_X_PERIOD_METHOD mediestMethod; // How to Find Mediest Period
ENUM_TIMEFRAMES mediestPeriod; // Mediest Time Frame
ENUM_APPLIED_PRICE mediestAppliedTo; // Mediest Applied To
//
// Farest Period ...
ENUM_X_PERIOD_METHOD farestMethod; // How to Find Farest Period
ENUM_TIMEFRAMES farestPeriod; // Farest Time Frame
ENUM_APPLIED_PRICE farestAppliedTo; // Farest Applied To
//
// Constructor(s) ...
@@ -57,6 +77,23 @@ struct XXTSInputs
void Clean()
{
//
// Current Period ...
currentAppliedTo = PRICE_CLOSE;
//
// Nearest Period ...
nearestMethod = X_PERIOD_NOTHING;
nearestPeriod = NULL;
nearestAppliedTo = PRICE_CLOSE;
//
// Mediest Period ...
mediestMethod = X_PERIOD_NOTHING;
mediestPeriod = NULL;
mediestAppliedTo = PRICE_CLOSE;
//
// Farest Period ...
farestMethod = X_PERIOD_NOTHING;
farestPeriod = NULL;
farestAppliedTo = PRICE_CLOSE;
}
//
@@ -64,6 +101,23 @@ struct XXTSInputs
void Default()
{
//
// Current Period ...
currentAppliedTo = PRICE_CLOSE;
//
// Nearest Period ...
nearestMethod = X_PERIOD_AUTO;
nearestPeriod = NULL;
nearestAppliedTo = PRICE_CLOSE;
//
// Mediest Period ...
mediestMethod = X_PERIOD_AUTO;
mediestPeriod = NULL;
mediestAppliedTo = PRICE_CLOSE;
//
// Farest Period ...
farestMethod = X_PERIOD_AUTO;
farestPeriod = NULL;
farestAppliedTo = PRICE_CLOSE;
}
//
@@ -76,7 +130,9 @@ struct XXTSInputs
//
result =
//
false
IsValid(nearestMethod, nearestPeriod) &&
IsValid(mediestMethod, mediestPeriod) &&
IsValid(farestMethod, farestPeriod)
//
;
@@ -92,7 +148,7 @@ struct XXTSInputs
int result = 0;
//
result = MathMax(0, 0);
result = MathMax(result, 0);
//
return result;
@@ -124,7 +180,7 @@ public:
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XXTSInputs &inputs // Inputs
XXTSInputs &inputs // Inputs
)
{
//
@@ -144,21 +200,48 @@ public:
//
mInputs = inputs;
// //
// // ArraySetAsSeries(shortExit2Buffer, true);
// mHandler = iCustom(
// mSymbol,
// mPeriod,
// "x-saherelm.x",
// //
// // Inputs ...
// //
// );
// result = mHandler != INVALID_HANDLE;
// if (!result)
// {
// return result;
// }
//
ArraySetAsSeries(currentBuffer, true);
ArraySetAsSeries(nearestBuffer, true);
ArraySetAsSeries(mediestBuffer, true);
ArraySetAsSeries(farestBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xts",
//
// Inputs ...
//
// Current Period ...
"",
mInputs.currentAppliedTo, // Current Applied To
//
// Nearest Period ...
"",
mInputs.nearestMethod, // How to Find Nearest Period
mInputs.nearestPeriod, // Nearest Time Frame
mInputs.nearestAppliedTo, // Nearest Applied To
//
// Mediest Period ...
"",
mInputs.mediestMethod, // How to Find Mediest Period
mInputs.mediestPeriod, // Mediest Time Frame
mInputs.mediestAppliedTo, // Mediest Applied To
//
// Farest Period ...
"",
mInputs.farestMethod, // How to Find Farest Period
mInputs.farestPeriod, // Farest Time Frame
mInputs.farestAppliedTo // Farest Applied To
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
@@ -190,55 +273,205 @@ public:
//
// Buffers ...
// //
// double GetMain(
// int barIndex // Bar Index
// )
// {
// //
// if (barIndex < 0)
// {
// barIndex = 0;
// }
//
double GetCurrent(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
// //
// Calculate();
//
Calculate();
// //
// int count = ArraySize(mainBuffer);
// if (barIndex >= count)
// {
// barIndex = count - 1;
// }
//
int count = ArraySize(currentBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
// //
// return mainBuffer[barIndex];
// }
//
return currentBuffer[barIndex];
}
// //
// // 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();
//
// Copy Required Items ...
int CopyCurrent(
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,
// longExit2Buffer,
// buffer,
// forceClean
// //
// );
// }
//
// Copy Items ...
return Copy(
start,
count,
currentBuffer,
buffer,
forceClean
//
);
}
//
double GetNearest(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(nearestBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return nearestBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyNearest(
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,
nearestBuffer,
buffer,
forceClean
//
);
}
//
double GetMediest(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mediestBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mediestBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMediest(
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,
mediestBuffer,
buffer,
forceClean
//
);
}
//
double GetFarest(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(farestBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return farestBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyFarest(
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,
farestBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
@@ -252,7 +485,10 @@ private:
//
// Buffers ...
// double longExit1Buffer[];
double currentBuffer[];
double nearestBuffer[];
double mediestBuffer[];
double farestBuffer[];
//
// Tools ...
@@ -264,16 +500,49 @@ private:
//
int totalBars = CountBars();
// //
// // Short Exit 2 ...
// CopyBuffer(
// mHandler,
// X_CHE_SHORT_EXIT_2_LINE,
// 0,
// totalBars,
// shortExit2Buffer
// //
// );
//
// Current ...
CopyBuffer(
mHandler,
XTS_CURRENT_LINE,
0,
totalBars,
currentBuffer
//
);
//
// Nearest ...
CopyBuffer(
mHandler,
XTS_NEAREST_LINE,
0,
totalBars,
nearestBuffer
//
);
//
// Mediest ...
CopyBuffer(
mHandler,
XTS_MEDIEST_LINE,
0,
totalBars,
mediestBuffer
//
);
//
// Farest ...
CopyBuffer(
mHandler,
XTS_FAREST_LINE,
0,
totalBars,
farestBuffer
//
);
}
}