Finalize EA architecture before strategy development

This commit is contained in:
peter
2026-06-07 16:32:51 -04:00
parent fff49ea9da
commit c88216db03
11 changed files with 1512 additions and 375 deletions
+28 -11
View File
@@ -27,18 +27,35 @@ public:
// Guard against invalid broker volume data
if(min_lot <= 0.0 || max_lot <= 0.0 || lot_step <= 0.0 || max_lot < min_lot)
return 0.0;
// Apply limits
if(lot < min_lot) lot = min_lot;
if(lot > max_lot) lot = max_lot;
// Round to step
lot = MathFloor(lot / lot_step) * lot_step;
if(lot < min_lot)
lot = min_lot;
return NormalizeDouble(lot, 2);
// Compute precision from volume step
int precision = 0;
double s = lot_step;
const double eps = 1e-9;
while(MathAbs(MathRound(s) - s) > eps && precision < 8)
{
s *= 10.0;
precision++;
}
// Round down to nearest step
double normalized = MathFloor(lot / lot_step) * lot_step;
normalized = NormalizeDouble(normalized, precision);
// If normalized is below minimum, indicate invalid by returning 0.0
if(normalized < min_lot)
return 0.0;
// Clamp to maximum allowed (rounded down to step)
if(normalized > max_lot)
{
normalized = MathFloor(max_lot / lot_step) * lot_step;
normalized = NormalizeDouble(normalized, precision);
if(normalized < min_lot)
return 0.0;
}
return normalized;
}
// Convert points to price distance