last ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -4038,6 +4038,951 @@ bool Strategy1HasSignal(
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region PV ...
|
||||
bool IsPeakSameAsLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsSame(
|
||||
helper.GetPeak(barIndex),
|
||||
helper.GetPeak(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsPeakOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetPeak(barIndex),
|
||||
helper.GetPeak(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsPeakUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetPeak(barIndex),
|
||||
helper.GetPeak(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsValeSameAsLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsSame(
|
||||
helper.GetVale(barIndex),
|
||||
helper.GetVale(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsValeOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetVale(barIndex),
|
||||
helper.GetVale(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsValeUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetVale(barIndex),
|
||||
helper.GetVale(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region ATR ...
|
||||
bool IsATRBreakoutUp(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double price = bar.GetPrice(priceType);
|
||||
result = price > helper.GetATRRawUpper(barIndex);
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRBreakoutDown(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double price = bar.GetPrice(priceType);
|
||||
result = price < helper.GetATRRawLower(barIndex);
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATROverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetATR(barIndex),
|
||||
helper.GetATR(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetATR(barIndex),
|
||||
helper.GetATR(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSwitchedOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsATROverLast(barIndex, tolerance) &&
|
||||
!IsATROverLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSwitchedUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsATRUnderLast(barIndex, tolerance) &&
|
||||
!IsATRUnderLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSmoothedOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetATRSmoothed(barIndex),
|
||||
helper.GetATRSmoothed(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSmoothedUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetATRSmoothed(barIndex),
|
||||
helper.GetATRSmoothed(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSmoothedSwitchedOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsATRSmoothedOverLast(barIndex, tolerance) &&
|
||||
!IsATRSmoothedOverLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSmoothedSwitchedUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsATRSmoothedUnderLast(barIndex, tolerance) &&
|
||||
!IsATRSmoothedUnderLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsVolatilityHigh(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double atr = helper.GetATR(barIndex);
|
||||
double atrMa = helper.GetATRSmoothed(barIndex);
|
||||
result = atr > atrMa;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsVolatilityLow(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double atr = helper.GetATR(barIndex);
|
||||
double atrMa = helper.GetATRSmoothed(barIndex);
|
||||
result = atr < atrMa;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsVolatilitySwitchdToHigh(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double atr = helper.GetATR(barIndex);
|
||||
double atrPrev = helper.GetATR(barIndex + 1);
|
||||
double atrMa = helper.GetATRSmoothed(barIndex);
|
||||
double atrMaPrev = helper.GetATRSmoothed(barIndex + 1);
|
||||
|
||||
//
|
||||
result =
|
||||
atr > atrMa &&
|
||||
atrPrev <= atrMaPrev;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsVolatilitySwitchdToLow(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double atr = helper.GetATR(barIndex);
|
||||
double atrPrev = helper.GetATR(barIndex + 1);
|
||||
double atrMa = helper.GetATRSmoothed(barIndex);
|
||||
double atrMaPrev = helper.GetATRSmoothed(barIndex + 1);
|
||||
|
||||
//
|
||||
result =
|
||||
atr < atrMa &&
|
||||
atrPrev >= atrMaPrev;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region RSI ...
|
||||
bool IsRSIBullish(
|
||||
int barIndex = 0,
|
||||
double threshold = 55,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = helper.GetRSI(barIndex) > threshold + (GetPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) > threshold - (GetPoints(symbol) * tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedToBullish(
|
||||
int barIndex = 0,
|
||||
double threshold = 55,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
IsRSIBullish(barIndex, threshold, tolerance) &&
|
||||
!IsRSIBullish(barIndex + 1, threshold, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIBearish(
|
||||
int barIndex = 0,
|
||||
double threshold = 45,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = helper.GetRSI(barIndex) < threshold + (GetPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) < threshold - (GetPoints(symbol) * tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedToBearish(
|
||||
int barIndex = 0,
|
||||
double threshold = 45,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
IsRSIBearish(barIndex, threshold, tolerance) &&
|
||||
!IsRSIBearish(barIndex + 1, threshold, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIRising(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
helper.GetRSI(barIndex) > helper.GetRSISmoothed(barIndex);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedToRising(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsRSIRising(barIndex) &&
|
||||
!IsRSIRising(barIndex + 1);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIFalling(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
helper.GetRSI(barIndex) < helper.GetRSISmoothed(barIndex);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedToFalling(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsRSIFalling(barIndex) &&
|
||||
!IsRSIFalling(barIndex + 1);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetRSI(barIndex),
|
||||
helper.GetRSI(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsRSIOverLast(barIndex, tolerance) &&
|
||||
!IsRSIOverLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetRSI(barIndex),
|
||||
helper.GetRSI(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsRSIUnderLast(barIndex, tolerance) &&
|
||||
!IsRSIUnderLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIOverbought(
|
||||
int barIndex = 0,
|
||||
double threshold = 70,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = helper.GetRSI(barIndex) > threshold + (GetPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) > threshold - (GetPoints(symbol) * tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIOversold(
|
||||
int barIndex = 0,
|
||||
double threshold = 30,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = helper.GetRSI(barIndex) < threshold + (GetPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) < threshold - (GetPoints(symbol) * tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedToOversold(
|
||||
int barIndex = 0,
|
||||
double threshold = 30,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsRSIOversold(barIndex, threshold, tolerance) &&
|
||||
!IsRSIOversold(barIndex + 1, threshold, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedFromOversold(
|
||||
int barIndex = 0,
|
||||
double threshold = 30,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
!IsRSIOversold(barIndex, threshold, tolerance) &&
|
||||
IsRSIOversold(barIndex + 1, threshold, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedToOverbought(
|
||||
int barIndex = 0,
|
||||
double threshold = 70,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsRSIOverbought(barIndex, threshold, tolerance) &&
|
||||
!IsRSIOverbought(barIndex + 1, threshold, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedFromOverbought(
|
||||
int barIndex = 0,
|
||||
double threshold = 70,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
!IsRSIOverbought(barIndex, threshold, tolerance) &&
|
||||
IsRSIOverbought(barIndex + 1, threshold, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region Composite ...
|
||||
bool IsKIHasTrend(
|
||||
|
||||
@@ -114,7 +114,7 @@ class XCX121XKIHelperParser : XCBase
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
XOHCL result;
|
||||
result.Init(symbol, period);
|
||||
result.Init(symbol, period, barIndex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -171,153 +171,22 @@ class XCX121XKIHelperParser : XCBase
|
||||
DECLARE_CROSSING_COMPARATOR_FUNCTIONS("KI", "Slow", "SuperSlow", helper.GetKISlow, helper.GetKISuperSlow, NormalizeBarIndex, GetPoints);
|
||||
DECLARE_CROSSING_COMPARATOR_FUNCTIONS("MA", "Slow", "SuperSlow", helper.GetMASlow, helper.GetMASuperSlow, NormalizeBarIndex, GetPoints);
|
||||
|
||||
// #region PV ...
|
||||
bool IsPeakSameAsLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
//
|
||||
DECLARE_VALUE_COMPARATOR_FUNCTIONS("Peak", helper.GetPeak, NormalizeBarIndex, GetPoints);
|
||||
DECLARE_VALUE_COMPARATOR_FUNCTIONS("Vale", helper.GetVale, NormalizeBarIndex, GetPoints);
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
//
|
||||
DECLARE_VALUE_COMPARATOR_FUNCTIONS("ATR", helper.GetATR, NormalizeBarIndex, GetPoints);
|
||||
DECLARE_VALUE_COMPARATOR_FUNCTIONS("ATRSmoothed", helper.GetATRSmoothed, NormalizeBarIndex, GetPoints);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsSame(
|
||||
helper.GetPeak(barIndex),
|
||||
helper.GetPeak(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
//
|
||||
DECLARE_VALUE_COMPARATOR_FUNCTIONS("RSI", helper.GetRSI, NormalizeBarIndex, GetPoints);
|
||||
DECLARE_VALUE_COMPARATOR_FUNCTIONS("RSISmoothed", helper.GetRSISmoothed, NormalizeBarIndex, GetPoints);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
bool IsPeakOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetPeak(barIndex),
|
||||
helper.GetPeak(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsPeakUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetPeak(barIndex),
|
||||
helper.GetPeak(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsValeSameAsLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsSame(
|
||||
helper.GetVale(barIndex),
|
||||
helper.GetVale(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsValeOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetVale(barIndex),
|
||||
helper.GetVale(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsValeUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetVale(barIndex),
|
||||
helper.GetVale(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region ATR ...
|
||||
bool IsATRBreakoutUp(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
@@ -394,186 +263,6 @@ class XCX121XKIHelperParser : XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATROverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetATR(barIndex),
|
||||
helper.GetATR(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetATR(barIndex),
|
||||
helper.GetATR(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSwitchedOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsATROverLast(barIndex, tolerance) &&
|
||||
!IsATROverLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSwitchedUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsATRUnderLast(barIndex, tolerance) &&
|
||||
!IsATRUnderLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSmoothedOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetATRSmoothed(barIndex),
|
||||
helper.GetATRSmoothed(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSmoothedUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetATRSmoothed(barIndex),
|
||||
helper.GetATRSmoothed(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSmoothedSwitchedOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsATRSmoothedOverLast(barIndex, tolerance) &&
|
||||
!IsATRSmoothedOverLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsATRSmoothedSwitchedUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsATRSmoothedUnderLast(barIndex, tolerance) &&
|
||||
!IsATRSmoothedUnderLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsVolatilityHigh(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
@@ -689,9 +378,7 @@ class XCX121XKIHelperParser : XCBase
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region RSI ...
|
||||
bool IsRSIBullish(
|
||||
int barIndex = 0,
|
||||
double threshold = 55,
|
||||
@@ -714,8 +401,8 @@ class XCX121XKIHelperParser : XCBase
|
||||
}
|
||||
|
||||
//
|
||||
result = helper.GetRSI(barIndex) > threshold + (GetPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) > threshold - (GetPoints(symbol) * tolerance);
|
||||
result = helper.GetRSI(barIndex) > threshold + (GetXPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) > threshold - (GetXPoints(symbol) * tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -773,8 +460,8 @@ class XCX121XKIHelperParser : XCBase
|
||||
}
|
||||
|
||||
//
|
||||
result = helper.GetRSI(barIndex) < threshold + (GetPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) < threshold - (GetPoints(symbol) * tolerance);
|
||||
result = helper.GetRSI(barIndex) < threshold + (GetXPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) < threshold - (GetXPoints(symbol) * tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -880,96 +567,6 @@ class XCX121XKIHelperParser : XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsOver(
|
||||
helper.GetRSI(barIndex),
|
||||
helper.GetRSI(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedOverLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsRSIOverLast(barIndex, tolerance) &&
|
||||
!IsRSIOverLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsUnder(
|
||||
helper.GetRSI(barIndex),
|
||||
helper.GetRSI(barIndex + 1),
|
||||
GetPoints(symbol) * tolerance //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSISwitchedUnderLast(
|
||||
int barIndex = 0,
|
||||
double tolerance = 2 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
IsRSIUnderLast(barIndex, tolerance) &&
|
||||
!IsRSIUnderLast(barIndex + 1, tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsRSIOverbought(
|
||||
int barIndex = 0,
|
||||
double threshold = 70,
|
||||
@@ -992,8 +589,8 @@ class XCX121XKIHelperParser : XCBase
|
||||
}
|
||||
|
||||
//
|
||||
result = helper.GetRSI(barIndex) > threshold + (GetPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) > threshold - (GetPoints(symbol) * tolerance);
|
||||
result = helper.GetRSI(barIndex) > threshold + (GetXPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) > threshold - (GetXPoints(symbol) * tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -1021,8 +618,8 @@ class XCX121XKIHelperParser : XCBase
|
||||
}
|
||||
|
||||
//
|
||||
result = helper.GetRSI(barIndex) < threshold + (GetPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) < threshold - (GetPoints(symbol) * tolerance);
|
||||
result = helper.GetRSI(barIndex) < threshold + (GetXPoints(symbol) * tolerance) ||
|
||||
helper.GetRSI(barIndex) < threshold - (GetXPoints(symbol) * tolerance);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -1115,7 +712,6 @@ class XCX121XKIHelperParser : XCBase
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
|
||||
@@ -2233,7 +2233,7 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
{
|
||||
//
|
||||
// Bullish ...
|
||||
bool hasBullish = kiParser.IsMACrossoverSwitchedToBullish(i);
|
||||
bool hasBullish = kiParser.IsMAFastCrossedOverSlow(i);
|
||||
has = hasBullish && isBullish;
|
||||
if (has)
|
||||
{
|
||||
@@ -2263,7 +2263,7 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bool hasBearish = kiParser.IsMACrossoverSwitchedToBearish(i);
|
||||
bool hasBearish = kiParser.IsMAFastCrossedUnderSlow(i);
|
||||
has = hasBearish && isBearish;
|
||||
if (has)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user