Spécifications
A hedging EA that works on any time frame and any pair
Inputs:
One trade at a time
One trade per day: toggle yes/no
Fixed lot - standard 0.1
Max spread - standard 5
Gap (pip difference between buy and sell orders): standard 10 pips
TP: standard 20 pips
SL: standard 30 pips
Strategy:
Setup:
- Open a buy_stop_order_1 at price + “Gap/2” pips- Open a sell_stop_order_1 at price - “Gap/2” pips
- If buy_stop_order_1 is executed, cancel sell_stop-order_1, and open sell_stop_order_2 at same price with lot size x2
- If sell_stop_order_1 is executed, cancel buy_stop_order_1, and open buy_stop_order_2 at same price with lot size x2
- If any order hits TP directly, cancel other pending order.
Here, if the buy order is executed and price goes up to TP, all good. If price comes down, we have a new sell stop order with added lot size to cover the buy order. Same idea if the sell stop order activates first and price doesn’t hit TP.
Next moves, while TP is not hit in any direction and price floats inside SLs range:
- If buy_stop_order_2 is executed, cancel sell_stop-order_2, and open sell_stop_order_3 at same price with lot size x2
- If sell_stop_order_2 is executed, cancel buy_stop_order_2, and open buy_stop_order_3 at same price with lot size x2
Example:
Price is 1.0050
- Set BSO_1 at 1.0055, Lot 0.1, TP 1.075, SL 1.025
- Set SSO_1 at 1.0045, Lot 0.1, TP 1.025, SL 1.075
If Price moves up and executes BSO_1:
- Cancel SSO_1
- Set SSO_2 at 1.0045, Lot 0.2, TP 1.025, SL 1.075
Now, price can either:
(1) hit TP:
- Cancel pending SSO_2
(2) or execute SSO_2:
- Set BSO_2 at 1.0055, Lot 0.2, TP 1.075, SL 1.025
Now, again, price can either:
(1) hit TP:
- Cancel pending BSO_2
(2) or execute BSO_2:
- Set SSO_3 at 1.0055, Lot 0.2, TP 1.075, SL 1.025
Strategy repeats until price hits TP, with lot size increasing for the opposite pending order by 2 lot sizes every time. In this case, if price goes down and hit SSO_3, it would trigger a new BSO_3:
- Set BSO_3 at at 1.0055, Lot 0.2, TP 1.075, SL 1.025
The direction of the last executed order always carries 1 lot size more than the opposite direction. If the trade changes direction, the pending order keeps the same balance over and over until TP hits.