Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Experts

Missing Stop Loss and Take Profit Setter - expert for MetaTrader 5

Kenichiro Sakamoto
Kenichiro Sakamoto
5 (2)
I'm Kenichiro Sakamoto, the developer behind FXEA365 — a studio building transparent, rule-based Expert Advisors for MetaTrader 5.
Views:
15
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

This Expert Advisor checks the open positions on every tick and every 5 seconds. When a position has no stop loss, a stop loss is placed at the set number of pips from the open price, and when it has no take profit, a take profit is placed in the same way. Stop levels that already exist are never changed.

The check can be limited to the chart symbol or applied to all symbols, and a magic number filter can limit it to manual trades or to the trades of one Expert Advisor. The chart comment shows the settings, the number of positions in scope, the positions still without stops and the number of positions changed since the start.

Fig. 1. The utility on a EURUSD H1 chart

Input parameters

  • InpSLPips - stop loss distance from the open price in pips; 0 means that no stop loss is added.
  • InpTPPips - take profit distance from the open price in pips; 0 means that no take profit is added.
  • InpAllSymbols - check the positions of all symbols; when false only the chart symbol is checked.
  • InpMagic - magic number filter: -1 checks all positions, 0 only manual trades, another value only the trades with that magic number.

Notes

If the price has already moved past the calculated level, or the level is closer to the price than the stop level of the broker, that level is skipped and the position is checked again later. One pip is 10 points on 3 and 5 digit quotes and 1 point on other symbols. Failed requests are written to the Experts log with the description of the trade server return code.

Spread Spike Histogram with Moving Average Spread Spike Histogram with Moving Average

Separate window indicator that draws the spread of every bar as a histogram with its moving average and colors the bars where the spread is far above normal or above a fixed ceiling.

Economic News Window Flag for Pausing Expert Advisors Economic News Window Flag for Pausing Expert Advisors

Utility Expert Advisor that reads the built-in economic calendar and sets a terminal global variable to 1 around important events, so other Expert Advisors can skip new entries during the news.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.