last works ...

adding some tools to ch helper classes ...
This commit is contained in:
2024-07-26 03:36:40 +03:30
parent 35d814fc9c
commit fc9bca9c37
6 changed files with 1878 additions and 77 deletions
+788
View File
@@ -1585,6 +1585,794 @@ public:
);
}
//
// Tools ...
//
double GetCyclesMaxFast(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
int cyclesCount = ArraySize(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
double values[];
for (int i = 0; i < cyclesCount; i++)
{
//
double iValue = 0;
//
switch (cycles[i])
{
//
// CURRENT ...
case X_MARKET_CYCLE_UNKNOWN:
//
iValue = GetCFast(barIndex);
break;
//
// SHORT ...
case X_MARKET_CYCLE_SHORT:
//
iValue = GetSFast(barIndex);
break;
//
// MEDIUM ...
case X_MARKET_CYCLE_MEDIUM:
//
iValue = GetMFast(barIndex);
break;
//
// LONG ...
case X_MARKET_CYCLE_LONG:
//
iValue = GetLFast(barIndex);
break;
//
// HIND ...
case X_MARKET_CYCLE_HIND:
//
iValue = GetHFast(barIndex);
break;
}
//
if (iValue > 0)
{
//
Add(
iValue,
values //
);
}
}
//
result = GetMax(values);
//
return result;
}
//
double GetCyclesMinFast(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
int cyclesCount = ArraySize(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
double values[];
for (int i = 0; i < cyclesCount; i++)
{
//
double iValue = 0;
//
switch (cycles[i])
{
//
// CURRENT ...
case X_MARKET_CYCLE_UNKNOWN:
//
iValue = GetCFast(barIndex);
break;
//
// SHORT ...
case X_MARKET_CYCLE_SHORT:
//
iValue = GetSFast(barIndex);
break;
//
// MEDIUM ...
case X_MARKET_CYCLE_MEDIUM:
//
iValue = GetMFast(barIndex);
break;
//
// LONG ...
case X_MARKET_CYCLE_LONG:
//
iValue = GetLFast(barIndex);
break;
//
// HIND ...
case X_MARKET_CYCLE_HIND:
//
iValue = GetHFast(barIndex);
break;
}
//
if (iValue > 0)
{
//
Add(
iValue,
values //
);
}
}
//
result = GetMin(values);
//
return result;
}
//
double GetCyclesMaxSlow(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
int cyclesCount = ArraySize(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
double values[];
for (int i = 0; i < cyclesCount; i++)
{
//
double iValue = 0;
//
switch (cycles[i])
{
//
// CURRENT ...
case X_MARKET_CYCLE_UNKNOWN:
//
iValue = GetCSlow(barIndex);
break;
//
// SHORT ...
case X_MARKET_CYCLE_SHORT:
//
iValue = GetSSlow(barIndex);
break;
//
// MEDIUM ...
case X_MARKET_CYCLE_MEDIUM:
//
iValue = GetMSlow(barIndex);
break;
//
// LONG ...
case X_MARKET_CYCLE_LONG:
//
iValue = GetLSlow(barIndex);
break;
//
// HIND ...
case X_MARKET_CYCLE_HIND:
//
iValue = GetHSlow(barIndex);
break;
}
//
if (iValue > 0)
{
//
Add(
iValue,
values //
);
}
}
//
result = GetMax(values);
//
return result;
}
//
double GetCyclesMinSlow(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
int cyclesCount = ArraySize(cycles);
if (!IsValidSize(cyclesCount))
{
return result;
}
//
double values[];
for (int i = 0; i < cyclesCount; i++)
{
//
double iValue = 0;
//
switch (cycles[i])
{
//
// CURRENT ...
case X_MARKET_CYCLE_UNKNOWN:
//
iValue = GetCSlow(barIndex);
break;
//
// SHORT ...
case X_MARKET_CYCLE_SHORT:
//
iValue = GetSSlow(barIndex);
break;
//
// MEDIUM ...
case X_MARKET_CYCLE_MEDIUM:
//
iValue = GetMSlow(barIndex);
break;
//
// LONG ...
case X_MARKET_CYCLE_LONG:
//
iValue = GetLSlow(barIndex);
break;
//
// HIND ...
case X_MARKET_CYCLE_HIND:
//
iValue = GetHSlow(barIndex);
break;
}
//
if (iValue > 0)
{
//
Add(
iValue,
values //
);
}
}
//
result = GetMin(values);
//
return result;
}
//
double GetCyclesMax(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
double maxFast = GetCyclesMaxFast(
barIndex,
cycles //
);
double maxSlow = GetCyclesMaxSlow(
barIndex,
cycles //
);
//
result = MathMax(maxFast, maxSlow);
//
return result;
}
//
double GetCyclesMin(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
double minFast = GetCyclesMinFast(
barIndex,
cycles //
);
double minSlow = GetCyclesMinSlow(
barIndex,
cycles //
);
//
result = MathMin(minFast, minSlow);
//
return result;
}
//
// Calculate Bullish Power ...
double GetBullishPower(
int barIndex // Bar Index
)
{
//
double result = 0;
//
double fast = 0;
double slow = 0;
double delta = 0;
//
// CURRENT ...
fast = GetCFast(barIndex);
slow = GetCSlow(barIndex);
delta = MathAbs(fast - slow);
if (fast > slow)
{
result += delta;
}
//
// SHORT ...
fast = GetSFast(barIndex);
slow = GetSSlow(barIndex);
delta = MathAbs(fast - slow);
if (fast > slow)
{
result += delta;
}
//
// MEDIUM ...
fast = GetMFast(barIndex);
slow = GetMSlow(barIndex);
delta = MathAbs(fast - slow);
if (fast > slow)
{
result += delta;
}
//
// LONG ...
fast = GetLFast(barIndex);
slow = GetLSlow(barIndex);
delta = MathAbs(fast - slow);
if (fast > slow)
{
result += delta;
}
//
// HIND ...
fast = GetHFast(barIndex);
slow = GetHSlow(barIndex);
delta = MathAbs(fast - slow);
if (fast > slow)
{
result += delta;
}
//
return result;
}
//
// Calculate Bearish Power ...
double GetBearishPower(
int barIndex // Bar Index
)
{
//
double result = 0;
//
double fast = 0;
double slow = 0;
double delta = 0;
//
// CURRENT ...
fast = GetCFast(barIndex);
slow = GetCSlow(barIndex);
delta = MathAbs(slow - fast);
if (fast < slow)
{
result += delta;
}
//
// SHORT ...
fast = GetSFast(barIndex);
slow = GetSSlow(barIndex);
delta = MathAbs(slow - fast);
if (fast < slow)
{
result += delta;
}
//
// MEDIUM ...
fast = GetMFast(barIndex);
slow = GetMSlow(barIndex);
delta = MathAbs(slow - fast);
if (fast < slow)
{
result += delta;
}
//
// LONG ...
fast = GetLFast(barIndex);
slow = GetLSlow(barIndex);
delta = MathAbs(slow - fast);
if (fast < slow)
{
result += delta;
}
//
// HIND ...
fast = GetHFast(barIndex);
slow = GetHSlow(barIndex);
delta = MathAbs(slow - fast);
if (fast < slow)
{
result += delta;
}
//
return result;
}
//
// Check Bullish Power is Up ...
bool HasBullishPower(
int barIndex // Bar Index
)
{
//
bool result = false;
//
double bullishPower = GetBullishPower(barIndex);
double bearishPower = GetBearishPower(barIndex);
//
result =
//
bearishPower >= 0 &&
bullishPower > bearishPower
//
;
//
return result;
}
//
// Check Bearish Power is Up ...
bool HasBearishPower(
int barIndex // Bar Index
)
{
//
bool result = false;
//
double bullishPower = GetBullishPower(barIndex);
double bearishPower = GetBearishPower(barIndex);
//
result =
//
bullishPower >= 0 &&
bearishPower > bullishPower
//
;
//
return result;
}
//
// Check Bullish Power Increasing ...
bool IsBullishPowerIncreasing(
int barIndex, // Bar Index
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetBullishPower(barIndex);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetBullishPower(i);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower > iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower > lastPower
//
;
}
//
return result;
}
//
// Check Bullish Power Decreasing ...
bool IsBullishPowerDecreasing(
int barIndex, // Bar Index
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetBullishPower(barIndex);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetBullishPower(i);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower < iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower < lastPower
//
;
}
//
return result;
}
//
// Check Bearish Power Increasing ...
bool IsBearishPowerIncreasing(
int barIndex, // Bar Index
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetBearishPower(barIndex);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetBearishPower(i);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower > iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower > lastPower
//
;
}
//
return result;
}
//
// Check Bearish Power Decreasing ...
bool IsBearishPowerDecreasing(
int barIndex, // Bar Index
int loopback = 5 // Loopback
)
{
//
bool result = false;
//
if (loopback <= 0)
{
loopback = 5;
}
//
double firstPower = GetBearishPower(barIndex);
double lastPower = firstPower;
for (int i = barIndex + 1; i < barIndex + loopback; i++)
{
//
double iPower = GetBearishPower(i);
//
result =
//
iPower > 0 &&
firstPower > 0 &&
lastPower < iPower
//
;
if (!result)
{
break;
}
//
lastPower = iPower;
}
//
if (result)
{
//
result =
//
firstPower < lastPower
//
;
}
//
return result;
}
//
// Conditions ...
//
bool GetConditions(
XCHMConditions &conditions, //