manage trailing on algotrading

 
Hi, I’ve designed a neural network featuring two agents that decide whether to enter a "buy" or "sell" position, or to "skip." The entire codebase is in Python, which outputs a CSV file; this CSV is then read by an MQ5 Expert Advisor (EA) that manages the actual trades. I’m now looking for advice on how to handle the trailing stop management. Currently, the Take Profit (TP) and Stop Loss (SL) levels are determined by the Python script and are set in points, but I would prefer to work using an ATR multiplier. Please keep in mind that the system opens three positions simultaneously, each with a lot size of 0.01. How should I manage TP1, TP2, TP3, and the Stop Loss? My initial thought was that once TP1 is reached, TP2 and TP3 should immediately be moved to break-even (with a small offset)—but what comes next? A standard trailing stop? Or a reverse trailing stop? Thanks for any advice!
Tony
 
Tonybarba:
Hi, I’ve designed a neural network featuring two agents that decide whether to enter a "buy" or "sell" position, or to "skip." The entire codebase is in Python, which outputs a CSV file; this CSV is then read by an MQ5 Expert Advisor (EA) that manages the actual trades. I’m now looking for advice on how to handle the trailing stop management. Currently, the Take Profit (TP) and Stop Loss (SL) levels are determined by the Python script and are set in points, but I would prefer to work using an ATR multiplier. Please keep in mind that the system opens three positions simultaneously, each with a lot size of 0.01. How should I manage TP1, TP2, TP3, and the Stop Loss? My initial thought was that once TP1 is reached, TP2 and TP3 should immediately be moved to break-even (with a small offset)—but what comes next? A standard trailing stop? Or a reverse trailing stop? Thanks for any advice!
Tony
Without knowing the details of your strategy (I'm not asking for those), it sounds like an indicator-based dynamic exit (along with your initial fixed stop in place) might be the way to go. Personally, I'm not a big fan of the usual ATR x 2.5 stop. Have a look at the RSI(14) with an SMA(20) applied to it (as a crossover tool). I'm more of a one-and-done position trader (algorithmically), so I have to leave the stacked trades' exits to you.
 
Ryan L Johnson #:
Without knowing the details of your strategy (I'm not asking for those), it sounds like an indicator-based dynamic exit (along with your initial fixed stop in place) might be the way to go. Personally, I'm not a big fan of the usual ATR x 2.5 stop. Have a look at the RSI(14) with an SMA(20) applied to it (as a crossover tool). I'm more of a one-and-done position trader (algorithmically), so I have to leave the stacked trades' exits to you.

How I would adapt it to the 3 positions
Philosophically consistent with what we already have:

TP1 (scalp)
Don't touch it. It closes at its fixed TP – too fast for an RSI signal.

TP2 (manager)
Hybrid: keep the current fixed ladder (200/800-400) BUT add this – if the RSI crosses down after TP1 is closed → force close TP2 immediately (even if the ladder says "hold").

Logic: the ladder protects against small pullbacks, the RSI cross protects against structural reversals.

TP3 (runner)
This is where the RSI cross really shines. Replace the P3 lock + P4 trail with:

  • P1: SL = entry - 0.3 ATR (wide, as it is now)

  • P2 trigger +1200pt → BE

  • From BE onwards: NO trailing, wait for the RSI/SMA cross → close immediately

Advantage: the runner has TIME to let the trend develop, and exits on a "trend exhaustion signal" instead of closing on a mechanical pullback.


Pros:

  • Exits at real tops, not on fake pullbacks

  • Keeps the runner's wide SL → no premature closing

Cons:

  • RSI is laggy on H1 (2-3 bars delay = 2-3 hours)

  • False signals in sideways markets (RSI oscillates, continuous crossovers

What do you think? Anyway, thank you for your valuable advice.


Best,  Tony

 
Tonybarba #:

How I would adapt it to the 3 positions
Philosophically consistent with what we already have:

TP1 (scalp)
Don't touch it. It closes at its fixed TP – too fast for an RSI signal.

TP2 (manager)
Hybrid: keep the current fixed ladder (200/800-400) BUT add this – if the RSI crosses down after TP1 is closed → force close TP2 immediately (even if the ladder says "hold").

Logic: the ladder protects against small pullbacks, the RSI cross protects against structural reversals.

TP3 (runner)
This is where the RSI cross really shines. Replace the P3 lock + P4 trail with:

  • P1: SL = entry - 0.3 ATR (wide, as it is now)

  • P2 trigger +1200pt → BE

  • From BE onwards: NO trailing, wait for the RSI/SMA cross → close immediately

Advantage: the runner has TIME to let the trend develop, and exits on a "trend exhaustion signal" instead of closing on a mechanical pullback.


Pros:

  • Exits at real tops, not on fake pullbacks

  • Keeps the runner's wide SL → no premature closing

Cons:

  • RSI is laggy on H1 (2-3 bars delay = 2-3 hours)

  • False signals in sideways markets (RSI oscillates, continuous crossovers

What do you think? Anyway, thank you for your valuable advice.


Best,  Tony

Nice! You've really implemented the main benefit of the RSI/SMA─to capture runners. At the same, you're realistic about tempering it's potential detriments.