Fan sayfamıza katılın
Öyleyse bir link gönderin -
başkalarının da faydalanmasını sağlayın
![Kütüphaneler](https://c.mql5.com/i/code/library.png)
Function library for maintaining positions with a simple trailing stop - MetaTrader 4 için kütüphane
- Görüntülemeler:
- 7195
- Derecelendirme:
- Yayınlandı:
- 2016.03.25 13:31
-
Bu koda dayalı bir robota veya göstergeye mi ihtiyacınız var? Freelance üzerinden sipariş edin Freelance'e git
With the help of this library it is possible to implement the ability to maintain positions with a simple trailing stop in any Expert Advisor. This library is universal and is designed to be able to connect to virtually any EA using the #include compiler directive and granting the EA the ability to maintain positions with a simple trailing stop.
In order to connect the library to an EA it is necessary to make the following changes:
1. Insert the compiler directive before the declaration of functions:
#include <a-SimpleTrailing.mqh>
2. Declare the global variables:
color clModifyBuy = Aqua; // Color of Buy modification icon color clModifySell = Tomato; // Color of Sell modification icon
3. Declare the external parameters:
// Use sound signals during the execution of trades extern bool UseSound = True; extern string NameFileSound = "expert.wav"; // Name of the sound file extern int NumberOfTry = 3; // Number of trade attempts on errors extern int PauseAfterError = 75; // Pause between trade attempts in seconds
4. Insert the line at the end of the start() function:
if(UseTrailing)
TrailingPositions();
5. Place the library file a-SimpleTrailing.mqh into the terminal folder ...\experts\include\
Once the library is connected, the EA will have the following external parameters:
// Use trailing stop. If 'False', the trailing stop is disabled. UseTrailing = True; // Trail only profit. If 'False', then the trailing stop will start // working in the unprofitable zone. ProfitTrailing = True; TrailingStopBuy = 50; // Trailing stop size for Buy orders. TrailingStopSell = 50; // Trailing stop size for Sell orders. TrailingStep = 5; // Trailing step.The TrailingPositions() function can take on the following parameters:
- symbol name ("" - current symbol);
- operation (-1 - any position, 0 - Buy, 1 - Sell);
- MagicNumber (-1 - any magic number).
This allows to narrow the scope of the trailing stop operation. For example, trail only Euro:
if(UseTrailing) TrailingPositions("EURUSD");
Or trail only Pound Sells:
if(UseTrailing) TrailingPositions("GBPUSD", OP_SELL);
And if the EA uses a magic number, then it must be passed to the maintenance function:
if(UseTrailing) TrailingPositions("", -1, MAGIC);
MetaQuotes Ltd tarafından Rusçadan çevrilmiştir.
Orijinal kod: https://www.mql5.com/ru/code/7069
![Library of functions for working with INI-files.](https://c.mql5.com/i/code/library.png)
The library contains five functions for reading the values from an INI-file and five functions for writing the values to an INI-file. Thus, there are five pairs of functions to read/write the values of 'integer array', 'boolean', 'double', 'integer' and 'string' types.
![MA-4H](https://c.mql5.com/i/code/indicator.png)
The MA-4H indicator displays the moving average of the selected timeframe on the chart of the current timeframe. The intersection of the two moving averages is implemented as optional. The external parameters allow to activate the second moving average in order to see their intersection.
![New_Fractal_Lines](https://c.mql5.com/i/code/indicator.png)
The New Fractal Lines indicator implements not the "squat" bar, but the "squat" fractal and draws the fractal lines.
![WATR trend indicator, simple but clear](https://c.mql5.com/i/code/indicator.png)
A simple trend indicator that clearly shows the direction of the current trend. It can be used in the breakout trading systems.