MetaTrader 4 MT4 Expert Advisors Orders Guardian – EA MetaTrader 4

Orders Guardian – EA MetaTrader 4

I. Introduction

MetaTrader provieds the functions to set a fixed TP, SL or trailing stop to an order. More often, we hope to use some other closing strategy, such as resistance, support lines, channels, etc. But this need users to keep staring at the chart and modifying the TP and SL times to time, which will be a hard working. OrdersGuardian is such an EA that will partly free you from the computer screen after opening orders. It has some simple closing strategy, including MA, envelopes, trendline, channels, parabolic SAR. It will close the order as the price reach to this curve or line you set.

II. Parameters

Varables Type Default Values Comments
Orders string “*” Orders’ tickets to be monitored. “*” means all opened orders of current symbol, it can be tickets list separated by spaces, commas and other chars, for the EA will check each order whecher its ticket is this string’s substr. All the orders in this list must be in the same direction, otherwise the EA can not work.
2 TP strategy: 1 – Envelopes or MA (set TP_Env_Dev to 0 means MA), 2 – line objects, others – no TP.
EA will search line objects in the chart, which can be Trendline, Trendline by Angel or Equidistant Channel.
2 SL strategy : 1 – Envelopes or MA, 2 – line objects, 3 – Parabolic SAR, others – no SL.
true Whether to show TP and SL price line in the chart.
LimeGreen Color of TP price line.
0 Timeframe of the indicator for calculating TP price, the unit is minute, 0 means the current chart timeframe.
34 Period for TP MA calculation.
MODE_EMA TP MA method.
PRICE_CLOSE Applied price for TP MA.
0.2 Percent deviation of TP envelopes line from MA, positive – the upper, negative – the lower, zero – MA curve line.
0 TP MA shift, MA line offset relate to the chart by timeframe.
Red Color of SL price line.
0 Timeframe of the indicator for calculating SL price.
34 Period for SL MA calculation.
MODE_EMA SL MA method.
PRICE_CLOSE Applied price for SL MA.
0.2 Percent deviation of SL envelopes line from MA
SL_SARStep double 0.02
Increment of SAR.
double 0.5 Maximum value of SAR.
0 SL MA shift
Alternative:   earlyBird1 - EA MetaTrader 4

III. About line objects

  1. If there were more than one line object in the chart, taking a long order as example, the EA would search the nearest one above the current price as the TP trendline, and the nearest one below as the SL trendline.
  2. When EA running, user can adjust the position of trendline, and EA will calculate the new coordinates automatically.
  3. The EA searches the TL and SL trendline right after its starting, after which two line objects will not change, even if user move them above or below other lines, excpet restarting the EA.
  4. Changing the period of attached chart will cause EA restarting and then re-searching TP and SL objects.
  5. If users delect the working TP or SL objects, the EA would search a new one.
  6. When equidistant channel used, the upper line would be TP line and lower be SL in long orders, vice versa in short orders.
  7. Trendline in angel is not recommanded, for its position in the chart’s price coordinate is not fixed and changes with the price or time axis.

IV. Notice

  • When SAR used as SL, the variable SL_Shift can not be zero, must >=1.
  • The TP and SL price is the price showed in chart, ie. bid price, no spread calculated.

V. Operation steps

  1. Open your orders.
  2. Place indicators or trendline to the chart as your TP or SL objects.
  3. Attach OrdersGuardian to the chart,set the parameters same as your indicators (setting ShowLines’s value true is recommended), and leave “Allow live trading” unchecked on the common tab. Click OK button, there should be a cross in the top-right corner of the chart.
  4. Press down the “Expert Advisors” button, the cross will became an unhappy face, which means the EA is working properly, but will not close any orders.
  5. If the TP and SL price line displayed in the chart are same as your planned, press F7, select the checkbox of “Allow live trading”, and the unhappy face icon will change into a smiling one, so the EA is now starting monitoring your orders.
Alternative:   PChannel3_HTF - indicator MetaTrader 5

Equidistant Channels as TP and SL

Envelopes as TP

Moving Average as SL

Parabolic SAR as SL

Trendline as TP and SL

📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks