Adding Prices Instead of Subtracting: Dissecting a Logic Breakdown in an Unfiltered Straddle EA
Introduction
Adding Prices Instead of Subtracting: Dissecting a Logic Breakdown in an Unfiltered Straddle EA
Introduction
The quality of an Expert Advisor (EA) cannot be measured by its line count.
This is a dissection record of a skeletal EA derived from an outdated Interbank FX template. It is exceptionally short. While our previous case study (Specimen 002) consisted of 589 lines of code, this current subject (Specimen 003) is an ultra-minimalistic script. At first glance, it appears lightweight, transparent, and constructed around a seemingly straightforward breakout strategy.
However, a look under the hood reveals a catastrophic collapse that occurs even before any trading strategy can take place.
To be precise, the core mathematical equation intended to capture price movements and deploy a straddle grid is fundamentally broken, rendered completely meaningless by a fatal coding bug. The EA does not analyze the market; it merely executes unconditional buy-and-sell stop orders at extremely tight intervals using a logically collapsed formula. Whether the market rises or falls, this EA exercises zero judgment.
The common frustration among retail traders — “Why does my EA fail in live trading despite beautiful backtests?” — often stems from this exact type of structural void. The input parameters mimic a sophisticated multi-functional system, yet the execution code reveals that the core logic is entirely dead. This article exposes this reality using nothing but objective code analysis and the cold mathematics of expectancy. We offer no speculation; anything that cannot be definitively proven will be labeled as “Gray.”
:::message
This article is a technical diagnosis of a widely circulated retail trading “pattern” analyzed from a purely structural standpoint. It does not intend to criticize any specific individual or commercial product. All descriptions are based strictly on objective code facts and quantitative mathematics.
:::
Specimen Overview — Reversing the Design Intent from the Code
This specimen came with no accompanying documentation or product manuals. Therefore, its original design intent must be reverse-engineered entirely from the structural artifacts left within the source code.
The code reveals the unmistakable blueprint of a classic “Breakout Straddle Strategy.” The apparent intent was to place a Buy Stop above and a Sell Stop below the current market price simultaneously during a period of low volatility, aiming to capture sudden momentum shifts (breakouts) and scalp a minuscule profit of roughly 2.0 pips.
Furthermore, variables declaring technical indicator periods (Periods=14) and toggles for utilizing completed bars are defined at the top of the script, indicating a superficial attempt to implement some form of market environment filtering.
However, none of these filtering mechanisms are connected to the actual execution logic. As demonstrated in the following chapters, the EA operates on a purely unconditional basis, continuously throwing out orders while the foundational equation meant to track price action is completely broken. A definitive disconnection lies between the original design intent and the reality of the code.
Chapter 1: Specification Verification — Display vs. Implementation
We cross-reference the visible input parameters in the user interface with their actual handling inside the source code. Multiple severe discrepancies between the presentation and implementation were discovered.
Technical Indicator Variables (Periods=14, etc.)
These are declared at the top of the file but are never referenced anywhere within the actual execution logic. They are entirely dead code. While the user interface implies that the EA performs sophisticated technical analysis, the live implementation executes unconditional order placement without any market context.
Slippage Control (Slippage=3)
An input variable exists for slippage limitation, yet the actual order sending function (OrderSend) passes a hardcoded value of 0 for the slippage argument. While the user believes they are protected against adverse fills, the live system leaves slippage completely unmanaged and exposed.
Take Profit and Stop Loss Distances
These metrics are hardcoded in raw points rather than adjusted pips. In a standard 5-digit broker environment, this forces the strategy into an extremely compressed window: a Take Profit (TP) of 2.0 pips and a Stop Loss (SL) of 1.8 pips. This extreme tight constraint amplifies the impact of market friction exponentially.
Chapter 2: Fatal Structures — The Three Pillars of Failure
A. Mathematical Breakdown of the Trailing Logic (Price Addition)
We begin with the most critical technical defect.
The logic responsible for adjusting the pending stop orders relative to the current market price relies on the following conditional statement:
コード スニペット
if ((OrderOpenPrice() + Bid) > 0.007)
In the laws of mathematics and physics, measuring the “distance” between two price points strictly requires subtraction (the absolute value of OrderOpenPrice() - Bid). Instead, this specimen "adds" the prices together, rendering the conditional statement entirely meaningless for tracking distance. Furthermore, the hardcoded threshold of 0.007 is completely dependent on the digit structure of the currency pair; running this on any mismatched asset will trigger immediate and continuous execution failure.
This is not a case of an inefficient strategy; it is a total mathematical collapse. The logic has lost all relationship with physical price space.
B. Complete Absence of Entry Filters
There are zero mechanisms to evaluate market hours, spread expansion, or volatility regimes.
The moment a tick arrives, if no active positions are detected, the EA immediately initiates its straddle routine. It continues to deploy orders blindly during toxic market environments, such as the early morning rollover period or high-impact news events when spreads widen drastically. Under these conditions, the widened spread alone instantly breaches the tight 1.8-pip Stop Loss threshold the exact moment the order triggers. The script does not extract an edge; it merely exposes capital to random market noise.
C. Structural Loss via Unconditional Straddling
Predicting no market direction and trapping the price from both sides via a straddle framework becomes predatory to the user under micro-range conditions (TP 2.0 / SL 1.8).
Even if one side triggers and successfully secures a 2.0-pip profit, the opposing pending order is either left abandoned in the market or dragged into an adverse position by the broken trailing logic, ultimately resulting in a high-probability stop-out. Because holistic position management is entirely absent, the dual burden of transactional friction and structural contradiction guarantees a compounding drain on capital.
Chapter 3: CAP Audit — Verification of Data Distortion
Semura Lab. evaluates the presence of “CAP” (Data Manipulation / Cheat Behavior) based on five rigid engineering dimensions. The verdicts are marked as Black (Present), Gray (Suspected/Inconclusive), or White (Absent).
Survivorship Bias / Future Leak (Referencing unconfirmed bars): White
The specimen lacks any logical framework to analyze historical market structures to form a trade decision. Because there are no indicator calculations to leak data from the future, a future leak is structurally impossible. This is a “White” verdict born out of a total absence of logic, rather than a robust design.
Close-Cap (Artificial capping of losses or profits in backtests): White
No hidden code manipulation was found that artificially limits or truncates historical equity drawdowns to distort backtest reporting.
Placebo Variables (Superficial inputs that connect to nothing): Black
This is the most pronounced infraction in this specimen. The parameters dedicated to technical indicator periods (Periods=14) are completely unmapped to the core execution loops. The user interface projects a multi-faceted algorithmic setup, but the real backend code performs nothing but unmapped, raw order placement. The core architecture is a pure illusion.
Mismatched Presentation and Implementation: Black
The declaration of slippage parameters that are silenced in the actual OrderSend functions, combined with the presentation of technical variables masking an unconditional execution model, represents a severe divergence between description and execution. This is a documented technical fact.
Curve-Fitting (Over-Optimization): Gray
Because the optimization targets (the indicator variables) are disconnected from live execution, there are no structural footprints of historical curve-fitting. Due to the lack of evaluable backtest metrics, this dimension remains inconclusive.
Chapter 4: Mathematics of Friction — Expected Value Outcomes
We prove the structural impossibility of this EA generating a positive return using pure mathematics.
Let us isolate the impact of an average market spread of 0.6 pips against the specimen’s ultra-tight nominal targets (TP = 2.0 pips, SL = 1.8 pips). When friction is factored in, the true execution parameters shift drastically:
- Effective Profit = 2.0 pips — 0.6 pips = 1.4 pips
- Effective Loss = 1.8 pips + 0.6 pips = 2.4 pips
The required break-even win rate ($p$) for a single trade under these conditions is defined by the standard expectancy formula:
$$p = \frac{\text{Effective Loss}}{\text{Effective Profit} + \text{Effective Loss}}$$
$$p = \frac{2.4}{1.4 + 2.4} \approx 63.1\%$$
This exposes the harsh mathematical reality of the specimen.
Nominally, the risk-to-reward ratio appears close to an acceptable 1:1 structure. Yet, the moment a realistic 0.6-pip spread is introduced, the break-even win rate requirement spikes to 63.1%. This occurs because the transactional friction consumes a massive 30% of the target profit.
There is zero mathematical basis for profitability.
Because the strategy deploys an unconditional straddle with no direction filtering (Chapter 2, B), the probability of the market hitting either side in a random walk scenario cannot exceed 50%. Expecting a blind, broken system to maintain a continuous win rate of over 63.1% simply to cover the cost of friction violates basic probability theory.
As trade frequency scales, the account equity will inevitably decay toward a net negative balance, perfectly aligning with the mathematical expectation. An appealing risk-reward ratio means nothing when faced with a broken formula and overwhelming friction.
Chapter 5: Compliance Assessment — Semura Lab. Standards
We evaluate this logic against the core operational thresholds demanded by Semura Lab. for robust trading systems.
- Risk-to-Reward Consistency: Failed. The nominal targets of TP 2.0 / SL 1.8 are compressed so tightly that the entire strategy is drowned out by spread noise.
- Absolute Friction Management: Failed. There are no spread protection protocols or slippage controls implemented within the execution flow.
- Position Control Consistency: Failed. The logic violates our core principle of maintaining a single isolated position, defaulting instead to an unstable, continuous dual-grid state.
- Target Expectancy (Win Rate 55% / PF 1.2–1.5): Unattainable. The foundational trailing logic is broken at the syntax level, disqualifying it from quantitative evaluation.
Overall Suitability: Dead on Arrival (DOA).
This specimen fails to meet the minimum logical and mathematical criteria required to function as an automated trading system. Paralyzed by an structural code defect and a fundamental disregard for transactional friction, the logic is broken at the architectural level long before it ever encounters a backtest engine.
Supplement — On the Structure of Straddle Tracking
The tracking logic of this specimen continuously re-shuffled the open price, stop loss, and take profit levels of pending BUYSTOP and SELLSTOP orders on every single incoming tick.
However, the moment one side is filled, the opposing pending order instantly transitions into toxic residual risk. Unlike a standard trailing stop applied to an active, closed-risk position, modifying pending entry orders via a logically collapsed addition formula causes entry points to shift erratically in ways that cannot be mapped. This structural defect is the primary driver behind catastrophic deviations between historical simulations and live execution environments.
Evidence — Code Excerpt
The following code snippet isolates the critical points of failure identified during our diagnosis. The markers 【A】 through 【E】 correspond directly to the analytical chapters of this report.
[embed]
Conclusion
A bare-bones script with minimal lines. Yet contained within its short architecture lies a concentration of fatal flaws: a mathematical collapse in trailing logic, a complete vacancy of execution filters, and a structural loss trap inherent to micro-straddling.
Line count is an illusion of quality. Massive frameworks can harbor dead code, and hyper-lightweight scripts can completely lack an underlying strategy. The common thread among both failures is the stark divergence between the “sophisticated presentation” of the parameters and the “actual processing” executed by the live code.
The answers are always found within the code. Evidence and mathematics will always speak louder than promotional marketing.
Diagnosis Agency: Semura Lab.
If you are concerned that your logic may contain the same “mathematical flaws” or “physical frictions” discussed in this article, we accept requests for complimentary diagnostics.
Semura Lab. is a specialized diagnostic agency that rejects market fantasies and focuses exclusively on logic capable of surviving in the real market. We subject submitted logic to an internal diagnostic process to rigorously measure whether it is physically and mathematically viable in the current market environment.
**Click here for the Viability Diagnosis Submission Form**
— Semura Lab.
메타데이터
- post_id
- 2f33da4d5a91
- slug
- adding-prices-instead-of-subtracting-dissecting-a-logic-breakdown-in-an-unfiltered-straddle-ea-2f33da4d5a91
- url
- https://medium.com/@griffice3/adding-prices-instead-of-subtracting-dissecting-a-logic-breakdown-in-an-unfiltered-straddle-ea-2f33da4d5a91
- canonical_url
- https://medium.com/@griffice3/adding-prices-instead-of-subtracting-dissecting-a-logic-breakdown-in-an-unfiltered-straddle-ea-2f33da4d5a91
- author_url
- https://medium.com/@griffice3
- status
- ok
- fetched_at
- 2026-06-20 20:29:01