last works ...
This commit is contained in:
+121
-102
@@ -45,6 +45,127 @@ enum ENUM_X_SWING_TYPE
|
||||
X_SWING_LOW = -1,
|
||||
};
|
||||
|
||||
//
|
||||
ENUM_SERIESMODE ToSeriesMode(ENUM_X_SWING_TYPE value)
|
||||
{
|
||||
//
|
||||
ENUM_SERIESMODE result = MODE_HIGH;
|
||||
|
||||
//
|
||||
switch (value)
|
||||
{
|
||||
//
|
||||
case X_SWING_HIGH:
|
||||
result = MODE_HIGH;
|
||||
break;
|
||||
|
||||
//
|
||||
case X_SWING_LOW:
|
||||
result = MODE_LOW;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Swing Points ...
|
||||
int FindSwing(
|
||||
string mSymbol, // Trading Symbol ...
|
||||
ENUM_TIMEFRAMES mPeriod, // Trading Period ...
|
||||
ENUM_X_SWING_TYPE mode, // Swing Based On Price mode ...
|
||||
int mLength, // Loopback ...
|
||||
int bar_index // BarIndex ...
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (StringLen(mSymbol) == 0 || (mode != X_SWING_HIGH && mode != X_SWING_LOW))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int current = bar_index;
|
||||
int founded = FindNextSwing(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
mode,
|
||||
(mLength * 2) + 1,
|
||||
current - mLength);
|
||||
|
||||
//
|
||||
while (founded != current)
|
||||
{
|
||||
//
|
||||
current = FindNextSwing(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
mode,
|
||||
mLength,
|
||||
current + 1);
|
||||
|
||||
//
|
||||
founded = FindNextSwing(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
mode,
|
||||
(mLength * 2) + 1,
|
||||
current - mLength);
|
||||
}
|
||||
|
||||
//
|
||||
result = current;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Next Swing ...
|
||||
int FindNextSwing(
|
||||
string mSymbol, // Trading Symbol ...
|
||||
ENUM_TIMEFRAMES mPeriod, // Trading Period ...
|
||||
ENUM_X_SWING_TYPE mode, // Swing Based On Price mode ...
|
||||
int mLength, // Loopback ...
|
||||
int bar_index // BarIndex ...
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (bar_index < 0)
|
||||
{
|
||||
mLength += bar_index;
|
||||
bar_index = 0;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_SERIESMODE mSeriesMode = ToSeriesMode(mode);
|
||||
|
||||
//
|
||||
result = mode == X_SWING_HIGH
|
||||
? iHighest(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
mSeriesMode,
|
||||
mLength,
|
||||
bar_index)
|
||||
: iLowest(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
mSeriesMode,
|
||||
mLength,
|
||||
bar_index);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XPERIOD Calculation Method ...
|
||||
enum ENUM_X_PERIOD_METHOD
|
||||
@@ -1399,108 +1520,6 @@ struct XOHCL
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Swings (Highs nd Lows) ...
|
||||
int FindSwing(
|
||||
ENUM_X_SWING_TYPE swing, // Swing Based On Price mode ...
|
||||
int mLength // Loopback ...
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!IsValid() ||
|
||||
!IsValid(swing))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int current = Index();
|
||||
int founded = FindNextSwing(
|
||||
swing,
|
||||
(mLength * 2) + 1,
|
||||
current - mLength
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
while (founded != current)
|
||||
{
|
||||
//
|
||||
current = FindNextSwing(
|
||||
swing,
|
||||
mLength,
|
||||
current + 1
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
founded = FindNextSwing(
|
||||
swing,
|
||||
(mLength * 2) + 1,
|
||||
current - mLength
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
result = current;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Next Swing ...
|
||||
int FindNextSwing(
|
||||
ENUM_X_SWING_TYPE swing, // Swing Based On Price mode ...
|
||||
int from, // from Bar Index
|
||||
int mLength // Loopback ...
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!IsValid() ||
|
||||
!IsValid(swing))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (from < 0)
|
||||
{
|
||||
mLength += from;
|
||||
from = 0;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_SERIESMODE mMode = swing == X_SWING_HIGH
|
||||
? MODE_HIGH
|
||||
: MODE_LOW;
|
||||
|
||||
//
|
||||
result = swing == X_SWING_HIGH
|
||||
? iHighest(
|
||||
symbol,
|
||||
period,
|
||||
mMode,
|
||||
mLength,
|
||||
from)
|
||||
: iLowest(
|
||||
symbol,
|
||||
period,
|
||||
mMode,
|
||||
mLength,
|
||||
from);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Lowest Bar Index ...
|
||||
int FindHighestIndex(
|
||||
|
||||
Reference in New Issue
Block a user