custom trail-stop by ma - update 4

custom trail-stop by ma - update 4
Download ALL MT5 experts (1593)
YouTube Video Thumbnail



Similar MetaTrader Tools

custom trail-stop by ma - update 4

Info

The custom trail-stop by ma - update 4 is a Expert Advisor for MetaTrader 5 that this is my first try at creating an ea from ground upthe ea only trails, so no automatic buy/sell***** please note: the default values are adjusted for m1 time-frame, as is the easiest way i got for testing it's workings, but it works in all time-frames and currency pairs *****besides the ma parameters, it also got a few options for the trailingpossibility of enforcing a maximum stop loss - for older orders that might exceed it number of bars behind to use in ma trail minimum distance from ma to trail minimum distance of current price to trail on positive and on negative profit possibility of not showing indicator line trail step the code probably can be optimized furtherfeel free to post suggestions, changes to the code that can improve it, or any doubts about it's workingsi have been trying to control the indicator`s appearance - line, color and style. any help will be welcomeupdate 1 (v1.

Usage

This tool is typically used for automated trading on major forex pairs and gold.

Platform

This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use custom trail-stop by ma - update 4

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

What this tool does

this is my first try at creating an ea from ground upthe ea only trails, so no automatic buy/sell***** please note: the default values are adjusted for m1 time-frame, as is the easiest way i got for testing it's workings, but it works in all time-frames and currency pairs *****besides the ma parameters, it also got a few options for the trailingpossibility of enforcing a maximum stop loss - for older orders that might exceed it number of bars behind to use in ma trail minimum distance from ma to trail minimum distance of current price to trail on positive and on negative profit possibility of not showing indicator line trail step the code probably can be optimized furtherfeel free to post suggestions, changes to the code that can improve it, or any doubts about it's workingsi have been trying to control the indicator`s appearance - line, color and style.

Typical Use Case

This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.

Description & Settings

Related: create custom buttons with ob j bit m a p la b e l ea - another powerful expert for MetaTrader 5 traders.


this is my first try at creating an ea from ground up

Also recommended: Expert Advisor with Custom Chart Application - similar expert with strong performance on MetaTrader 5.

the ea only trails, so no automatic buy/sell
***** please note: the default values are adjusted for m1 time-frame, as is the easiest way i got for testing it's workings, but it works in all time-frames and currency pairs *****
besides the ma parameters, it also got a few options for the trailing

possibility of enforcing a maximum stop loss - for older orders that might exceed it

number of bars behind to use in ma trail

minimum distance from ma to trail

minimum distance of current price to trail on positive and on negative profit

possibility of not showing indicator line

trail step
the code probably can be optimized further
feel free to post suggestions, changes to the code that can improve it, or any doubts about it's workings
i have been trying to control the indicator`s appearance - line, color and style. any help will be welcome
update 1 (v1.1)

file updated after consideration on how to treat preexisting orders that exceed max sl and the ea don`t have permission to close them
update 2 (v1.2)

logic errors in the trail system

added possibility of hiding/showing graphic line on chart
update 3 (v1.3)

added trail step
update 3.1

fixed some logic errors (yes i still keep finding them ^^)
update 4

a lot of mistakes where identified and corrected, affecting some minor changes in the trail method
coming soon: class library

You may also like: i ma i stochastic custom - excellent alternative for expert users on MetaTrader 5.

Source Code

#property copyright "robotfx"
#property version   "1.50"
#include <indicators\trend.mqh>
#include <trade\trade.mqh>
input group                "ma parameters"
input int                  ts_ma_period=50;                 // period of ma
input int                  ts_ma_shift=0;                   // ma shift
input enum_ma_method       ts_ma_method=mode_lwma;          // ma type of smoothing
input enum_applied_price   ts_applied_price=price_weighted; // ma type of price
string                     ts_sl_symbol=_symbol;            // working symbol

.......

Leave your opinion, ask a question, share some knowledge

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.