Lavoro terminato
Specifiche
Cycle start
-
When there are no open orders (by magic+symbol), the EA immediately opens a new cycle using the bullishness, bearishness, or neutralness of the current candle direction: if the current candle is bullish → open M1 BUY, otherwise M1 SELL. If the current candle is neutral, choose randomly.
-
Immediately after opening M1, place P1 in the opposite direction as M1 at the broker’s minimum pending distance. P1 lot = 3 × M1 lot (user input). M1 TP = 0.7 pips and P1 TP is at entry ± 0.7 pips (depending on direction) — but the P1 entry is at the minimum allowed distance.
-
Immediately after opening M1, place P2 in the same direction as M1 at the broker's minimum pending distance plus 1 point (P2 lot is calculated in Scenario (iii) below). P2 TP is at entry ± 0.7 pips as well.
Scenario (i) — M1 wins before P1 triggers
-
When M1 is closed by TP, the EA deletes P1 and P2 and resets the cycle (immediate restart).
Scenario (ii) — P1 triggers → M2 and M2 wins
-
If P1 triggers (fills) it becomes M2 (market). If M2 hits its own TP, the EA closes M1 and any pendings (P2) and restarts the.
Scenario (iii) — P1 triggers (M2), M2 didn't win but price returns to M1 TP
-
If M2 is running and later M1 TP is reached, the EA:
-
Closes M1 (M1 awarded profit by broker),
-
P2 lot is computed so that the cash profit when M3 (P2 when triggered) hits its TP will approximately offset or cancel the floating loss of M2, to within 3 points (Note that this makes sure that the P/L of M1 is always protected).
-
When P2 triggers → M3
-
P2 becomes M3 (market); The EA checks combined floating P/L of M2 + M3 each tick; if combined P/L is within the 3 point threshold, the EA closes both M2 & M3 and resets.
Safety & housekeeping
-
All lot sizes are clamped/rounded to broker rules (MODE_MINLOT, MODE_LOTSTEP, MODE_MAXLOT).
-
Pending distances respect MODE_STOPLEVEL .
-
Many debug logs & a periodic summary print are included.
-
The EA uses history-scanning to reliably react to broker-side TP closures (so it can detect TP closures that removed tickets).
-
Make sure the EA survives a connection interruption.