last ...
This commit is contained in:
@@ -69,7 +69,7 @@ input double sarMax = 0.2; // Maximum
|
||||
|
||||
//
|
||||
input group "Swing Detection";
|
||||
input int swingLength = 5;
|
||||
input int swingLength = 5; // Length
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
@@ -81,8 +81,8 @@ input int sarArrowCode = 159; // Parabolic Sar Arrow Code
|
||||
input int peaksArrowCode = 159; // Peaks Arrow Code
|
||||
input int valesArrowCode = 159; // Vales Arrow Code
|
||||
input int trendArrowCode = 117; // Trend Arrow Code
|
||||
input int swingLowsArrowCode = 159; // Swing Lows Arrow Code
|
||||
input int swingHighsArrowCode = 159; // Swing Highs Arrow Code
|
||||
input int swingLowsArrowCode = 225; // Swing Lows Arrow Code
|
||||
input int swingHighsArrowCode = 226; // Swing Highs Arrow Code
|
||||
input int supportsArrowCode = 159; // Supports Arrow Code
|
||||
input int resistancesArrowCode = 159; // Resistances Arrow Code
|
||||
|
||||
@@ -351,6 +351,14 @@ ENUM_TIMEFRAMES mLCPeriod = NULL;
|
||||
int mHCLength = 0;
|
||||
ENUM_TIMEFRAMES mHCPeriod = NULL;
|
||||
|
||||
//
|
||||
// Swings ...
|
||||
double lSwingLow = emptyValue;
|
||||
double lSwingHigh = emptyValue;
|
||||
double lTrend = emptyValue;
|
||||
double lTrendState = emptyValue;
|
||||
double lTrendColor = hideColorIDX;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
@@ -943,10 +951,17 @@ void CalculateBuffers(
|
||||
tickVolume //
|
||||
);
|
||||
|
||||
//
|
||||
int swingBarIndex = bar_index;
|
||||
if (bar_index < swingLength)
|
||||
{
|
||||
swingBarIndex = bar_index + swingLength;
|
||||
}
|
||||
|
||||
//
|
||||
// Calcultae Swing High and Low and Trends ...
|
||||
CalculateSwingsAndTrend(
|
||||
bar_index,
|
||||
swingBarIndex,
|
||||
prevCalculated,
|
||||
ratesTotal,
|
||||
open,
|
||||
@@ -955,6 +970,21 @@ void CalculateBuffers(
|
||||
low,
|
||||
tickVolume //
|
||||
);
|
||||
|
||||
//
|
||||
if (bar_index < swingLength)
|
||||
{
|
||||
//
|
||||
// for (int i = bar_index; i < bar_index + swingLength; i++)
|
||||
// {
|
||||
// //
|
||||
// trendBuffer[i] = lTrend;
|
||||
// swingLowsBuffer[i] = lSwingLow;
|
||||
// swingHighsBuffer[i] = lSwingHigh;
|
||||
// trendStateBuffer[i] = lTrendState;
|
||||
// trendColorBuffer[i] = lTrendColor;
|
||||
// }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1447,6 +1477,10 @@ void CalculateSwingsAndTrend(
|
||||
? lastSwingLow
|
||||
: iLow;
|
||||
swingLowsBuffer[bar_index] = iSwingLow;
|
||||
if (isSwingLow)
|
||||
{
|
||||
lSwingLow = iSwingLow;
|
||||
}
|
||||
|
||||
//
|
||||
// Swing High ...
|
||||
@@ -1459,6 +1493,10 @@ void CalculateSwingsAndTrend(
|
||||
? lastSwingHigh
|
||||
: iHigh;
|
||||
swingHighsBuffer[bar_index] = iSwingHigh;
|
||||
if (isSwingHigh)
|
||||
{
|
||||
lSwingHigh = iSwingHigh;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Trend ...
|
||||
@@ -1476,6 +1514,14 @@ void CalculateSwingsAndTrend(
|
||||
? iSwingHigh
|
||||
: lastTrend;
|
||||
trendBuffer[bar_index] = iTrend;
|
||||
bool isBullTrnd =
|
||||
isSwingLow &&
|
||||
iSwingLow > lastSwingLow;
|
||||
bool isBearTrnd =
|
||||
isSwingHigh &&
|
||||
iSwingHigh < lastSwingHigh;
|
||||
bool isTrnd = isBullTrnd ||
|
||||
isBearTrnd;
|
||||
|
||||
//
|
||||
double lastTrendState = isFirstBar
|
||||
@@ -1530,6 +1576,15 @@ void CalculateSwingsAndTrend(
|
||||
? bearishColorIDX
|
||||
: hideColorIDX;
|
||||
trendColorBuffer[bar_index] = iTrendColor;
|
||||
|
||||
//
|
||||
if (isTrnd)
|
||||
{
|
||||
//
|
||||
lTrend = iTrend;
|
||||
lTrendColor = iTrendColor;
|
||||
lTrendState = iTrendState;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1547,7 +1602,7 @@ bool IsSwingLow(
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = index - length > 0;
|
||||
result = index - length >= 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
@@ -1581,7 +1636,7 @@ bool IsSwingHigh(
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = index - length > 0;
|
||||
result = index - length >= 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user