MA Head and Grid R5 Sonet
- Experts
- Versão: 5.0
- Ativações: 5
English
Upon reaching TargetProfit, the EA must be restarted because it executes a hard stop.
1. News_Filter for FXDreema Contains an algorithm that utilizes the built-in MQL5 Economic Calendar ( CalendarValueHistory , CalendarEventById ).
-
News Filter Mechanism: Loads MetaTrader 5 calendar events for specified currencies ( News_Currencies ) and importance levels (High / Medium). The NewsFilterActive() function checks whether the current server time falls within the window before or after a news release.
-
Rule: The news filter must block the opening of only the first trade of a new grid. Existing grids must continue averaging and closing without filter interference.
-
MT5 Strategy Tester Limitation: MQL5 Economic Calendar functions ( CalendarValueHistory ) only work online on real or demo accounts and do not return historical data in the standard strategy tester ( !MQLInfoInteger(MQL_TESTER) ).
2. Breakdown of Functions, Mathematical Formulas, and Precision
-
Function g(x) — Lot Size Calculation: Originally popularized by French mathematician Paul Pierre Lévy for gambling (roulette). In trading, volume increases after a loss (usually doubling) so that the first price reversal covers prior losses.
-
Precision and Error: Uses NormalizeDouble(..., 2) to round to 2 decimal places. Most brokers use a lot step of 0.01; if the formula outputs 0.015, the broker rejects the order ( Invalid Volume ).
-
-
Function s(x) — Spread Costs: Calculates total spread costs across all open orders in a grid series (standard transaction accounting formula).
-
Function t(x) — Take Profit Level Calculation: Calculates the distance (in points) from the very first order to the grid's TP level using a Weighted Average Price formula (Break-Even Point) combined with Dollar Cost Averaging (DCA).
-
Precision and Error: Mathematically exact, but subject to minor real-market variance due to floating spreads and execution slippage.
-
-
Function c(x) — Current Drawdown Calculation: Estimates maximum theoretical drawdown in deposit currency/points when opening the x-th grid leg. If totalTheoreticalRisk > c::Max_Theoretical_Risk , the EA forces a Close On Risk Limit to safeguard remaining balance.
-
Core Precision Summary: The mathematical core builds an ideal theoretical model in points. To handle real-market floating spreads, swaps, and slippage, the code incorporates CheckSafeCloseByProfit() , which dynamically computes total equity cash ( profit + swap + commission ) to ensure fault tolerance.
