Expert Advisor for MT5 for a demo account and after testing for a real account - General description:
I need an Expert Advisor for the MetaTrader 5 in the mq5-code . The EA is only to use for the currency pair EURGBP.
The market entry signal is based on different indicators, provided that one or more indicator confirms the respective signals as a filter.
The positions are closed by stop loss, take profit or an indicator signal to close .
When an order is placed (position opening), it must be assigned a number (Magic), after which it can be distinguished from all other orders.
In a chart, there are either long positions or short positions.
If there is one position open a new position may only be made when a new candle is opened.
The number of open positions of one currency in an open chart must be shown separately for buy and sell positions in the opened chart.
1. Signal to open a position
A Triple Exponential Moving Average indicator (TEMA) and a Moving Average (EMA) provide buy or sell signals as as the Heiken Ashi confirms the respective signals as a filter (all indicator parameters should be adjustable). All three indicators have the same timeframes - 1minute
A second filter has a higher time frame - 1 hour - than the other indicators. This filter are two Exponential Moving Averages (EMA 3 and 10 - adjustable)
The triggering of the signals for the opening of or short positions should take place at the latest with the following candle.
Long:Exponential Moving Average (EMA_open_long period 3 ) is above Triple Exponential Moving Average (TEMA period 10) and the Heiken Ashi Indicator at candle1 = Heiken Ashi-Indicator at candle2 (it's the colour blue for uptrend ) , the timeframe (TF) is for all 1 minute;
the filter with a 1 hour timeframe for 2 EMA's: EMA_fast_filter = period 3 and EMA_slow-filter = period 10 are in an uptrend and the difference of the values EMA 3 minus EMA14 for candle 1 is greater or equal than for candle 2 (period and timeframe adjustable)
Short:Exponential Moving Average (EMA_open_short period 3) is below Triple Exponential Moving Average (TEMA 10) and the Heiken Ashi Indicator at candle1 = Heiken Ashi-Indicator at candle2 (it's the colour red for downtrend), the timeframe (TF) is for all 1 minute;
the filter with a 1 hour timeframe for 2 EMA's: EMA_fast_filter = 3 and EMA_slow_filter = 10 are in an uptrend and the difference of the values EMA 3 minus EMA14 for candle 1 is less or equal than for candle 2 (period and timeframe adjustable)
2. Signal to close a position
There may be several long / short positions open. Close all open or short positions in one chart of the currency when the opposite signal open a position occurs .
Close for long positions: TEMA_fast_close crosses below TEMA_slow_close (TEMA_fast_close with period 14 and TEMA_slow_close with period 28)
Close for short positions: TEMA_fast_close crosses above TEMA_slow_close (TEMA_fast_close with period 14 ans TEMA_slow_close with period 28)
Close Position at StopLoss
3. A simple StopLoss (SL) is needed in points and a Trail Stop Loss (use adjustable with true or false) at the current price minus ATR * 3 (adjustable)
BreakEven plus X points (for example 10 points above the break even)
Break Even and Trail Stop Loss are alternatively applicable
the Take Profit (TP) function is needed (use adjustable with true or false)
if the "0" values are specified, the functions will not be used.
4. The position volume is calculated as either fixed or as a percentage of the current balance: Lot = Balance / NecessaryMarge * LotProcess / 100, where:
Balance - current account balance;
Necessary margin - the margin necessary to open a position of the size of 1 pound;
PostPercent - an input parameter (the percentage used to calculate the post).
5. several open positions
If there is one or more up to 5 open positions ( adjustable MAXTrades) in a chart and an opposite signal occurs, the opened position must be closed and a new one opened (in the opposite direction).
For a new position, the calculation of the item must be called after closing the open position.
An Open Position have to be shown with the name of the EA in the "Comments" column of the terminal.
When the Expert Advisor is running, it should append the indicators used with the specified parameters;
The information for opening / closing positions and changes to the StopLoss should be stored in the log;
Should there be any errors, the EA must issue a message describing the error.
All program lines of the EA must be explained behind "//" and also especially abbreviations and short names with the full name (I need this for learning and understanding, this is very important to me )
Comment function in the chart picture:
total open position volume
Number of all open positions
Number of open buy positions of the currency in the opened chart
Number of open sell positions of the currency in the open chart
The trading robot should be adjustable with input variables for all the indicators, stop loss, take profit and break even:
input position size (fixed or percentage)
input maximum number of all open positions of all currencies, indices and gold (for example, positions total 10)
input maximum number of open buy positions in a currency (for example, max open buy positions 3)
input maximum number of open sell positions in a currency (for example, max open sell positions 3)
input StopLoss (for Stop Loss a suitable indicator should be selected)
Input BreakEven plus X points (for example 20 points above the break even)
If the "0" values are specified, the input variable will not be used.