İş Gereklilikleri
Cycle start
-
When there are no open orders for the EA (by magic+symbol) the EA immediately opens a new cycle using the last closed candle direction: if the current candle is bullish → open M1 BUY, otherwise M1 SELL. If the current candle is neutral, choose randomly. (Note that the attached file uses the last closed candle. Modify the EA so that it uses the bullishness, bearishness, or neutrality of the current candle)
-
Immediately after opening M1, place P1 in the opposite direction 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.
Scenario (i) — M1 wins before P1 triggers
-
When M1 is closed by TP, the EA deletes P1 (if still pending) 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 and resets.
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),
-
Immediately places P2 as a pending order in the same direction as M1 at the broker minimum pending distance (P2 entry = Ask+minDist for buy, Bid-minDist for sell).
-
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, within CloseWithinPoints (3 points by default). The calculation uses MODE_TICKVALUE & MODE_TICKSIZE to turn points into cash and compute required lots. Lot is clamped/rounded to broker min/step.
-
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 CloseWithinPoints 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 (OrdersHistoryTotal) to reliably react to broker-side TP closures (so it can detect TP closures that removed tickets).