This commit is contained in:
2025-09-16 10:55:50 +03:30
parent 5dd58eec74
commit 83ef415ca2
5 changed files with 1530 additions and 4 deletions
+112 -2
View File
@@ -862,9 +862,9 @@ double GetXSpread(
/**
* Get SPecified Symbols Volume Step ...
*
*
* @param mSymbol: string ...
*
*
* @return ( double )
*/
double GetVolumeStep(
@@ -1110,6 +1110,116 @@ bool GetTick(
return SymbolInfoTick(mSymbol, tick);
}
//
// Peak and Vales ...
int FindXSwing(
ENUM_X_SWING_TYPE mType,
string mSymbol = NULL,
ENUM_TIMEFRAMES mPeriod = NULL,
int mFromIndex = 0,
int mShoulders = 5 //
)
{
//
int result = -1;
//
// Validate ...
if (!IsXValid(mType))
{
return result;
}
//
result = mFromIndex;
int foundedIDX = FindXNextSwing(
mType,
mSymbol,
mPeriod,
result - mShoulders,
mShoulders * 2 + 1 //
);
while (foundedIDX != result)
{
//
result = FindXNextSwing(
mType,
mSymbol,
mPeriod,
result + 1,
mShoulders //
);
//
foundedIDX = FindXNextSwing(
mType,
mSymbol,
mPeriod,
result - mShoulders,
mShoulders * 2 + 1 //
);
}
//
return result;
}
int FindXNextSwing(
ENUM_X_SWING_TYPE mType,
string mSymbol = NULL,
ENUM_TIMEFRAMES mPeriod = NULL,
int mFromIndex = 0,
int mShoulders = 5 //
)
{
//
int result = -1;
//
if (mFromIndex < 0)
{
mShoulders += mFromIndex;
}
//
// Normalize ...
mSymbol = NormalizeSymbol(mSymbol);
mPeriod = NormalizePeriod(mPeriod);
mFromIndex = NormalizeInt(mFromIndex, 0);
mShoulders = NormalizeInt(mShoulders, 3);
//
// Validate ....
if (!IsXValid(mType))
{
return result;
}
//
// Converts Swing Type to Series Mode ...
ENUM_SERIESMODE mode = ToSeriesMode(mType);
result =
mode == MODE_HIGH
? iHighest(
mSymbol,
mPeriod,
mode,
mShoulders,
mFromIndex //
)
: iLowest(
mSymbol,
mPeriod,
mode,
mShoulders,
mFromIndex //
);
//
return result;
}
//
// END Position ...
//
+4
View File
@@ -747,6 +747,10 @@ bool IsValid(ENUM_X_SWING_TYPE value)
//
return result;
}
bool IsXValid(ENUM_X_SWING_TYPE value)
{
return IsValid(value);
}
/**
* Converts To String ...
+165
View File
@@ -1339,6 +1339,171 @@ struct XOHCL
return result;
}
//
// Swing Detection ...
//
int FindSwing(
ENUM_X_SWING_TYPE type,
int shoulders = 3 //
)
{
//
int result = -1;
//
// Validate ...
bool isValid = IsValid() &&
IsXValid(type);
if (!isValid)
{
return result;
}
//
// Find Next Swing ...
result = FindXSwing(
type,
symbol,
period,
Index(),
shoulders //
);
//
return result;
}
//
int FindNextSwing(
ENUM_X_SWING_TYPE type,
int shoulders = 3 //
)
{
//
int result = -1;
//
// Validate ...
bool isValid = IsValid() &&
IsXValid(type);
if (!isValid)
{
return result;
}
//
// Find Next Swing ...
result = FindXSwing(
type,
symbol,
period,
Index() + 1,
shoulders //
);
//
return result;
}
//
bool FindSwingBar(
ENUM_X_SWING_TYPE type,
XOHCL &swingBar,
int shoulders = 3 //
)
{
//
bool result = false;
//
// Prepare ...
swingBar.Clean();
//
// Validate ...
result = IsValid() &&
IsXValid(type);
if (!result)
{
return result;
}
//
// Find Next Swing ...
int idx = FindXSwing(
type,
symbol,
period,
Index(),
shoulders //
);
result = IsValidIndex(idx);
if (!result)
{
return result;
}
//
result = swingBar.Init(
symbol,
period,
idx //
);
//
return result;
}
//
bool FindNextSwingBar(
ENUM_X_SWING_TYPE type,
XOHCL &swingBar,
int shoulders = 3 //
)
{
//
bool result = false;
//
// Prepare ...
swingBar.Clean();
//
// Validate ...
result = IsValid() &&
IsXValid(type);
if (!result)
{
return result;
}
//
// Find Next Swing ...
int idx = FindXSwing(
type,
symbol,
period,
Index() + 1,
shoulders //
);
result = IsValidIndex(idx);
if (!result)
{
return result;
}
//
result = swingBar.Init(
symbol,
period,
idx //
);
//
return result;
}
//
// Other ...
string GetTag(string prefix = "")