MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal

Source code library - Expert Advisors, Indicators and Scripts

Buy Expert Advisors in MetaTrader Market and Let Them Trade For You
To post a new code, please log in or register

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2010.03.09 09:33
Universal trailing stop

Universal trailing stop - expert for MetaTrader 4

| English Spanish Portuguese Russian

Views:
15135
Rating:
votes: 5

Description:

Can run as a single Expert Advisor or a script, together with any Expert Advisor.

Depending on the variable TrailingStop, trailing may be performed using the fractals, the extremal values of bar in the past or using the specified points.

  • If TrailingStop is greater than 0, then trailing will be carried out with the specified points, which are defined in the variable TrailingStop. If TrailingStop is less than the minimal limit stops, trailing stops will be minimal.
  • If TrailingStop = 0 and Tip.Fr.or.Candl = 0, then trailing will performed using the fractals. The first corresponding fractal is used for the trailing.
  • If TrailingStop = 0 and Tip.Fr.or.Candl = 1, then trailing will performed using the minimal/ maximal price values of the previous candle.
  • If Magic = 0, then the trailing will performde on all orders with of this character, without the magic number. If the variable specified Magic magic number, respectively, will only trailing orders with the number of Magic.
  • If OnlyProfit = true, then trailed profit orders only.
  • If OnlyWithoutLoss = true, then orders trailed to the price level without loss only.

Visualization:

The screen displays information about the ongoing work of the script:

- Script settings;
- Number of orders, that processed;
- Current time
- Minimum levels of Stop (-)
- Current possible stop levels (price tags)

Tips:

The script terminates when all orders are closed. If the program is running as an ExpertAdvisor, it can be terminated manually.


Translated from Russian by MetaQuotes Software Corp.
Original code: http://www.mql5.com/ru/code/9530

Last comments | Go to discussion (9)
MQL4 Comments
mql4_comments | 6 Jun 2011 at 07:54

Could you update to detect and support 5-digit brokers? Thanks!

Vladimir Khlystov
cmillion | 25 Sep 2012 at 09:16
roy7:

Could you update to detect and support 5-digit brokers? Thanks!


Adviser and the script works on any broker, it is not important number of characters.
Newer versions.
MQL4 Comments
mql4_comments | 15 Feb 2013 at 01:16
cmillion:
razoff:

is there a way to trail several Magic (separated by comma or space) and dont trail the others if we have multiple EAs with their own magic ?

Thanks for sharing.


Simply start trail in miscellaneous window with one currency. In each window - its Magic

MQL4 Comments
mql4_comments | 15 Feb 2013 at 01:20
cmillion:
razoff:

is there a way to trail several Magic (separated by comma or space) and dont trail the others if we have multiple EAs with their own magic ?

Thanks for sharing.


Simply start trail in miscellaneous window with one currency. In each window - its Magic

jiva34:  very nice. works like a charm. many thanks. just what I needed.
cmillion:
razoff:

is there a way to trail several Magic (separated by comma or space) and dont trail the others if we have multiple EAs with their own magic ?

Thanks for sharing.


Simply start trail in miscellaneous window with one currency. In each window - its Magic




luchik
luchik | 15 Aug 2013 at 19:38
Perfect! Spasibo!