Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Twitter !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Vues:
7961
Note:
(34)
Publié:
2017.03.02 09:54
Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

This is a simple Expert Advisor with an implemented trailing stop.

It has only two parameters:

TrailingStop Inputs 

TrailingStop — the distance between the price and the Stop Loss level.

TrailingStep — protection against to frequent modification of position. 

How TrailingStop works — the example of the Buy position: 

Originally the StopLoss of a position is equal to zero, we wait for the following condition to be met

                  if(m_symbol.Bid()-ExtTrailingStop>m_position.PriceOpen())

— i.e. when the Bid minus TrailingStop is greater than the position open price PriceOpen:

TrailingStop sl to priceopen

StopLoss is moved to the PriceOpen level (position open price):

TrailingStop sl to priceopen result.png

now, when the position has StopLoss (i.e. when StopLoss is not equal to zero), wait for the following condition to be met:

                  if(m_symbol.Bid()-ExtTrailingStop-ExtTrailingStep>m_position.StopLoss())

— i.e. when the Bid minus TrailingStop minus TrailingStep is greater than the StopLoss price: So here we need to additionally check TrailingStep — this prevent position modification on every tick:

TrailingStop trailing

StopLoss is then moved to Bid minus TrailingStop:

TrailingStop trailing result.png 

Here is why we need a protection in the form of TrailingStep:

TrailingStop non trailing 

Traduit du russe par MetaQuotes Ltd.
Code original : https://www.mql5.com/ru/code/17263

Reconstruction of positions Reconstruction of positions

An example of working with the trading history on Hedge accounts — reconstruction of positions.

BIG DOG BIG DOG

The EA places pending stop orders BUY_STOP and SELL_STOP.

AIS1 AIS1

The EA works based on the analysis of Open, High and Low.

NRTR GATOR NRTR GATOR

Derived from the NRTR indicator, provided with a new visual display.