LibHoughTransform
This is an MQL5 library implementing the Linear Hough Transform, a computer vision algorithm used to detect straight lines in 2D images. It provides a factory function to create Hough transform objects and extracts line parameters (slope and intercept) from binary image data. The code is a general-purpose signal processing utility, not a trading EA.
Open the interactive view (equity curve, symbol switch)Key facts
Backtest results (H1, about 1 year)
Not backtested yet — this EA could not be converted automatically.
Strategy analysis
This code is not a trading strategy but rather a mathematical library implementation of the Hough Transform. It maps pixels from image space into parameter space (rho-theta space) to detect straight lines, where each non-zero pixel votes for all possible theta angles, accumulating into a 2D accumulator array. The extraction phase identifies the most prominent lines by finding local maxima in the accumulator, using non-maximum suppression (clearing a 3x3 neighborhood around each peak) to prevent duplicate detections. Each detected line is ultimately converted to slope-intercept form y=a*x+b as output parameters. The library supports both int and double data types through template class genericity. However, the code contains absolutely no trading logic, entry/exit conditions, position sizing, or money management strategy whatsoever.
Strengths
- Template-based design supports multiple data types with good code reusability
- Implements non-maximum suppression to avoid duplicate detection of the same line
- Converts line parameters to intuitive slope-intercept form (y=ax+b) for downstream use
- Factory pattern for object creation, supporting future extension of more transform types
- Pre-computed trigonometric table avoids repeated calculations and improves performance
Weaknesses
- Non-maximum suppression in findMax only clears a 3x3 neighborhood, which may be insufficient for high-resolution accumulators
- Lacks input image validity checks (e.g., handling of empty or zero-sized images)
- Angular resolution is fixed at M_PI/size with no adaptive adjustment based on image characteristics
- No inverse transform or verification functionality to confirm detection reliability
- Parameter conversion may produce numerical instability when sin(t) approaches zero
Possible improvements
- Add adaptive non-maximum suppression window size that dynamically adjusts based on accumulator resolution
- Add input data validation and boundary checks to improve library robustness
- Add numerical stability handling when sin(t) approaches zero to prevent division by zero or extreme values
Risk assessment
Overall risk: Safe
- This is a pure mathematical library with no trading operations and no trading risk
- Numerical stability issues may only appear under specific input conditions
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
quants | N/A (constructor arg) | Quantization parameter for Hough transform angle and distance resolution |
lines | 8 | Number of detected lines; 2 parameters per line |
type | TYPE_INT | Data type selection (TYPE_INT or TYPE_DOUBLE) |
Similar Machine Learning EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.