MQL4 - automated forex trading   /  

Code Base

Read Financial Magazines in MetaTrader 4 and MetaTrader 5!

Code Base  Expert Advisors  Universal trailing stop To post a new code, please log in or register

Download MetaTrader 5 and visit MQL5.community Code Base
and Trade on the Go!
and Trade on the Go!
Couldn't find the right code? Order it in the Jobs section

This Expert Advisor is for
MetaTrader 4
Download MT 4 - 455 Kb

and Trade on the Go!

and Trade on the Go!

Name:
Universal trailing stop [ ru ]
Author: cmillion (2010.03.09 10:33)
Rating: 10
Downloaded: 12046
Download:
 TrailingStopFrCn.mq4 (8.4 Kb) View

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.


9 comments  To post a new comment, please log in or register
Perfect! Spasibo!
15.08.2013 21:38 luchik
cmillion:
razoff wrote:

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 wrote:

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






15.02.2013 02:20 jiva34
cmillion:
razoff wrote:

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



15.02.2013 02:16 jiva34
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.
25.09.2012 11:16 cmillion

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

06.06.2011 09:54 roy7
How would one change the position of the trailing stop to the bar's extreme + spread +1? Great work by the way and I have been looking for this for a very long time.
04.02.2011 15:57 eclayf

How would you use this attached to another EA?

Can you import it or something as a script?...

03.11.2010 21:27 aku11a
razoff wrote:

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

09.03.2010 13:28 cmillion

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.

09.03.2010 12:00 razoff