Files
Bell-PriceActionWithEma-EA/Experts/EA_ICT_CL/Utils.mqh
T

34 lines
883 B
Plaintext
Raw Normal View History

2026-03-10 13:47:42 +07:00
#ifndef EA_ICT_CL__UTILS_MQH
2026-03-10 20:39:33 +07:00
#define EA_ICT_CL__UTILS_MQH
2026-03-10 13:47:42 +07:00
2026-03-10 20:39:33 +07:00
/** Clamps value to [lo, hi]. */
inline double ClampDouble(const double value, const double lo, const double hi)
2026-03-10 13:47:42 +07:00
{
2026-03-10 20:39:33 +07:00
if (value < lo) return lo;
if (value > hi) return hi;
return value;
2026-03-10 13:47:42 +07:00
}
2026-03-10 20:39:33 +07:00
/** Clamps integer value to [lo, hi]. */
inline int ClampInt(const int value, const int lo, const int hi)
2026-03-10 13:47:42 +07:00
{
2026-03-10 20:39:33 +07:00
if (value < lo) return lo;
if (value > hi) return hi;
return value;
2026-03-10 13:47:42 +07:00
}
2026-03-10 20:39:33 +07:00
/** Rounds value to nearest step (step must be > 0). */
2026-03-10 13:47:42 +07:00
inline double RoundToStep(const double value, const double step)
{
2026-03-10 20:39:33 +07:00
if (step <= 0.0) return value;
return MathRound(value / step) * step;
2026-03-10 13:47:42 +07:00
}
2026-03-10 20:39:33 +07:00
/** Returns true when current bar time differs from last processed bar time (new bar). */
inline bool IsNewBar(const datetime lastBarTime, const datetime currentBarTime)
2026-03-10 13:47:42 +07:00
{
2026-03-10 20:39:33 +07:00
return (currentBarTime != 0 && currentBarTime != lastBarTime);
2026-03-10 13:47:42 +07:00
}
2026-03-10 20:39:33 +07:00
#endif