Progressive Hedging EA: Hedge Lot Sizing Formula Revision

Development Log · 2025-07


1. Title

Progressive Hedging EA: Hedge Lot Sizing Formula Revision


2. Date / Phase

  • Date: July 2025 (initial conversation)
  • Phase: Phase 1 — Core Logic Refinement

Note: This development log predates the introduction of KOOeda6, AMARA, RAIDER, and HROOM as named entities. It documents an early technical evolution in the Progressive Hedging EA project.


3. Background

The Progressive Hedging EA was originally converted from ZZ2_EA, implementing a hedging system based on dual ZigZag indicators. The EA used a specific formula for calculating hedge lot sizes when price crossed predefined "Buy Line" or "Sell Line" levels.

The original formulas were:

  • Buy Order (LB(n)):
    LB(n) = (((B/A) + 1) / (B/A)) × (TotalSellLots − TotalBuyLots) × SpreadMultiplier

  • Sell Order (LS(n)):
    LS(n) = (((B/A) + 1) / (B/A)) × (TotalBuyLots − TotalSellLots) × SpreadMultiplier

The user requested a revision to these formulas, proposing a new structure where the ratio multiplication is applied to only one side of the position before subtracting the opposing side, rather than applying the ratio to the net difference.


4. Key Insights

4.1 Original Formula Structure

The original formula applied the ratio ((B/A) + 1) / (B/A) to the net position difference (TotalSellLots − TotalBuyLots or vice versa). This meant:

  • The ratio amplified or reduced the net imbalance.
  • The resulting hedge lot was proportional to the net exposure.

4.2 Proposed New Formula Structure

The revised formula applies the ratio to one side's total lots first, then subtracts the opposing side:

  • New Buy Order (LB(n)):
    LB(n) = ((((B/A) + 1) / (B/A)) × TotalSellLots − TotalBuyLots) × SpreadMultiplier

  • New Sell Order (LS(n)):
    LS(n) = ((((B/A) + 1) / (B/A)) × TotalBuyLots − TotalSellLots) × SpreadMultiplier

4.3 Mathematical Comparison

A numerical example revealed the behavioral difference:

Assumptions: B/A = 2, SellLots = 1.0, BuyLots = 0.5, SpreadMultiplier = 1.3

Formula Calculation Result
Original (1.5 × (1.0 − 0.5)) × 1.3 0.975
New ((1.5 × 1.0) − 0.5) × 1.3 1.300

Conclusion: The new formula produces larger hedge positions when the position being hedged against is larger than the opposing position. This results in more aggressive hedging and faster position balancing.

4.4 Scope of Change

The revision affects only the CalculateHedgeLotSize() function. All other components remain unchanged:

  • Risk management logic
  • SL/TP calculations
  • Order execution flow
  • Visual line management
  • ZigZag signal detection

4.5 First Hedge Exception

The first hedge order (when isFirstHedge = true) continues to use the original formula, as it establishes the initial hedge position without an existing opposing position to subtract.


5. Decisions

  1. Adopt the new formula for all subsequent hedge orders (non-first hedges):

    • Buy hedges: LB(n) = ((((B/A) + 1) / (B/A)) × TotalSellLots − TotalBuyLots) × SpreadMultiplier
    • Sell hedges: LS(n) = ((((B/A) + 1) / (B/A)) × TotalBuyLots − TotalSellLots) × SpreadMultiplier
  2. Retain the original formula for the first hedge order.

  3. Preserve all other EA logic — only the CalculateHedgeLotSize() function is modified.

  4. Maintain detailed logging to trace the new calculation steps for debugging and verification.

  5. Acknowledge the behavioral shift — the new formula produces larger hedge positions in imbalance scenarios, leading to more aggressive rebalancing.


6. Philosophy

This revision reflects a subtle but important shift in hedging philosophy:

  • Original approach: Hedge size proportional to net exposure. This is a conservative stance — the EA hedges only what is necessary to neutralize the net position, scaled by the risk-reward geometry.

  • New approach: Hedge size proportional to the dominant side, minus the opposing side. This is an assertive stance — the EA assumes the dominant position is the "truth" of the market and sizes the hedge to aggressively restore balance, even if it means temporarily over-hedging.

The new formula implicitly trusts the most recent signal more strongly. It does not merely neutralize — it actively pushes the position back toward equilibrium. This is a philosophical choice: balance is not just a state to be achieved, but a condition to be enforced.

The first hedge remains conservative because it is the anchor of the cycle. Subsequent hedges, however, are corrective in nature — they exist to fix an imbalance, and the new formula makes that correction more forceful.


7. Future Work

  1. Backtest comparison — Run historical simulations with both formulas to quantify the difference in drawdown, recovery speed, and net profitability.

  2. Parameter tuning — The SpreadMultiplier may need adjustment if the new formula produces excessively large positions in volatile markets.

  3. Edge case handling — Test scenarios where TotalBuyLots or TotalSellLots is zero (e.g., after partial closures) to ensure the formula behaves correctly.

  4. Logging enhancements — Add a flag to log the difference between old and new formula results side-by-side during live trading for real-time comparison.

  5. Documentation update — Update the EA's inline comments and external documentation to reflect the new formula.


8. Closing Note

In the evolution of any trading system, there comes a moment when the logic must shift from reacting to asserting. The original Progressive Hedging EA reacted to price movement by neutralizing exposure proportionally. The revised formula asserts a stronger corrective intent — it does not merely balance the books, it actively pushes toward equilibrium with conviction.

This change, though confined to a single function, represents a philosophical maturation: the system now trusts its own signals enough to act decisively when imbalance occurs. The first hedge remains the cautious anchor; all subsequent hedges become the hands that steady the ship.

The lesson is not that one formula is correct and the other wrong. The lesson is that formula structure encodes intent. The original formula asked, "How much do I need to hedge?" The new formula asks, "How much do I need to dominate?" These are different questions, and they lead to different systems.

What remains is to test whether this assertive posture performs better in the crucible of live markets. That is the work of the next phase.


End of Development Log — Progressive Hedging EA, Phase 1 Revision