MT4 Expert Advisor That Sets Take Profit and Stop Loss Automatically
Many trading systems and strategies use a fixed take profit and stop loss, so it’s convenient — and safer — to set them right away.
On Market Execution accounts (NDD, STP, ECN) you can’t set a stop loss or take profit when opening a position — only after the trade is open.
An Expert Advisor from the MQL4 Code Base can do it for you:

The EA is called SetUpProfitAndLoss.
Download the EA
SetUpProfitAndLoss.zip — an MT4 Expert Advisor that sets stop loss and take profit automatically. The archive contains the .mq4 source.
What it does
As soon as an order without SL/TP appears on the chart, the EA sets them. It also has two kinds of trailing: a regular trailing stop and a move-to-breakeven.
Parameters:
- TakeProfit — take profit in points (0 = don’t set, e.g. if you close by trailing).
- StopLoss — stop loss in points (0 = don’t set).
- TrailingStop — 0 = no trailing; a positive value = regular trailing stop; a negative value = move to breakeven after the price moves that many points. If the value is too small for your broker, the EA shows the minimum allowed value in the chart comment.
- SetOnlyZeroValues — true: only fill in SL/TP that are not set yet (zero); false: overwrite both with the EA’s settings.
- BuyOrderColor / SellOrderColor — line colors for buy and sell orders.
How to install it in MT4
- In the terminal: File → Open Data Folder →
MQL4\Experts. UnzipSetUpProfitAndLoss.mq4there. - Restart the terminal or click Refresh in the Navigator window. The EA compiles automatically (or open it in MetaEditor and click Compile).
- Drag the EA onto the chart of the symbol you trade and enable AutoTrading.
Note: this is an Expert Advisor, not an indicator. If you put it in the Indicators folder it won’t work — a common mistake in the comments.
The EA only handles orders for the symbol of the chart it’s attached to. If you don’t need trailing, you can switch it off once SL and TP are set.