Trabalho concluído
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Termos de Referência
Only apply if you are free and can complete this EA and you can share your whatsapp number
Expert advisor should work on MT5. Source code should be given and code should be modular and well documented in each block. Before sharing EA developer should self test on Demo account of any broker, Naming of variables should be as per best practices and code should be formatted and indented clearly with proper nesting. EA will be attached to any 1 single symbol chart but it will run all the symbols and timeframes that are specified in the Input. Allow upto 10 symbols in input. Each Higher Timeframe(s)-Lower Timeframe and Symbol combination will have a separate and unique magic number and also a unique comment should be populated which is like 1H_1MIN_200_50 where 1 hour is Higher timeframe where Narrow range(Doji candle or small body candle) is checked, 1 Min is lower timeframe where Moving average crossover and after that the crossabove/crossbelow/retest on fast moving average is checked. Show Broker Timezone like GMT+3 or GMT-5 etc. in chart.
Inputs will be
1. Symbols: Accept comma separated Symbol list.
2. Timeframes: Accept multiple selection from all timeframes that are available in MT5. 1 Min, 5 Min, 15 Min, 30 Min etc. till 1 Month.
3. Moving Average Type: Simple, Exponential etc. Select one option.
4. Slow or Higher moving average: Accept Number from 1 to 960. Default is 200
5. Fast or Lower moving average: Accept Number from 1 to 960. Default is 50
6. Minimum Number of continuous Doji or small body candles in Narrow Range in Higher timeframe before starting to trade: Optional parameter. Give selection of a single Higher timeframe and also accept input as Number. So Suppose if we select 1 Hour as Higher timeframe and then 4 as number of candles for Minimum Narrow range then only after this condition is formed and the candles are closed then the Expert advisor will start checking for Crossover and new entries. Purpose is to avoid Consolidation range bound market conditions. Also accept another input in this which will be for checking the Body range in pips like 20 Pips or 30 pips. That has to be entered by user. So If I enter 20 pips then all the candles should be below or equal to 20 pips in higher timeframe continuously. Then only the moving average crossover will be checked in lower timeframe. Once this condition is satisfied then for that same trading day no need to check for Doji candles again, only moving average crossover on lower timeframes will be checked and entry will be taken after crossover when there is a retest/crossabove of fast moving average on Buy side and retest/crossbelow of fast moving average for new Short Sell side entry. Then the higher timeframe check of Doji will be done next trading day.
If Higher timeframes is selected from 5 Minute to 4 Hour candles, This narrow range condition should be checked on daily basis only once and after that new trade entry is started if this optional parameter is selected then. For timeframe higher than 4 Hour it should be checked on Weekly basis once before starting new trades if this optional parameter is selected. Once the condition is satisfied on Daily basis or Weekly basis once then after that all crossovers have to be traded for that day/week without checking the Narrow range condition again. The next check of Higher timeframe Doji will only start the next day or the next week.
7. SL type:
A. Default Stop Loss will be when there is opposite type of crossover then the position should be exited whether in profit or loss. This will be default.
B. High/Low of candle that closes above fast moving average in smaller timeframe (like 50 SMA etc. of 1 minute), so If we are in a buy trade then low of that candle which closed just above 50 SMA. And if we are in a sell trade then High of the candle that closed just below the 50 SMA.
C: Need below SL and Target options also as mentioned in the article below User should be able to select any one method of SL/trailing. This trailing input will be optional.
. Trailing SL input options give as per below article
https://www.earnforex.com/guides/how-to-automate-trailing-stop-loss-in-metatrader-with-ea/
8. Target calculation: Default target will be whenever opposite type of crossover happens in lower timeframe then exit at market rate. This will be default.
If this is not selected in Input then Target can be set either in fix pips or in percentage as alternate or in ATR multiples(ATR of last 14 candles in lower timeframe).
9. Maximum Spread Allowed Filter: Accept a number and if the Realtime spread is higher than this number then do not initiate a new trade. Existing trade can be closed at any spread. Optional.
10. Lot Size Selection: 1. Fix accept input like 0.01 or 0.1 or 1 etc. 2. Autolot as per Balance in terms of percentage.
Logic of EA:
When a positive crossover happens that is fast moving (example 50 EMA) crosses above slow moving average(example 200 EMA) for the selected timeframe and symbol then note that, do not initiate a trade just on the basis of this. After this when the price goes below the fast moving average then note it(no need for price to close below 50 EMA just check if low price is going below 50 EMA or not), do not open the trade even at this time. Then when price rises above fast moving average and when that same candle closes then open a Buy trade at market price when the next candle opens. Do not set any SL at this time whenever there is a opposite crossover then exit at market price or if the trailing SL is set and its hit then exit. Also if optional Narrow range parameter is selected then wait for the narrow range to form , then the crossover should happen and after that retest or crossabove should happen. Then there should be entry of Buy or Sell. There are 2 scenarios here as shown below
1. Price briefly goes just below 50 EMA but closes above it in this case it will lead to a Hammer type of candle and then when this candle closes above the 50 EMA, When next candle opens buy at market price. Pyramiding is not required. Martingale is not required.
2. Price fully goes below 50 EMA but price still remains above 200 EMA. In this scenario we wait for price to close above 50 EMA then when a candle closes above 50 EMA then when next candle opens initiate a buy trade at market price. Remember in both scenarios Price should be above 50 EMA and 200 EMA when initiating a new buy order, also the fast moving average should be above slow moving average always when a Buy trade is initiated. Pyramiding is not required. Martingale is not required.
Reverse is true for Short side trades.
Close above scenario is shown below
Bounce or Retest scenario is shown below.