Make EA based on EMA, RSI for MT5

Работа завершена

Время выполнения 19 часов

Техническое задание

### Explanation for Developing the Multi-Timeframe EA

**Objective:**
Create an Expert Advisor (EA) for MetaTrader 5 (MT5) that replicates the functionality of the Ultimate RSI indicator from TradingView. The EA will open and manage trades based on the crossover signals of the RSI and EMA within the same window, incorporating multi-timeframe analysis.

**Specifications:**
1. **Indicators Used:**
   - Relative Strength Index (RSI)
   - Exponential Moving Average (EMA)

2. **Trading Logic:**
   - Open a buy position when the RSI crosses the EMA from below.
   - Open a sell position when the RSI crosses the EMA from above.
   - Always have one trade open:
     - Close the current trade when an opposite signal is generated and open a new trade in the opposite direction.

3. **Multi-Timeframe Analysis:**
   - Use higher timeframe data for confirming signals.
   - For example, check RSI and EMA crossovers on the H1 timeframe for signals, but execute trades on the M15 timeframe.

4. **No Take Profit (TP) or Stop Loss (SL):**
   - The EA will not use traditional TP or SL levels. Instead, it will close and reverse positions based on the crossover signals.

### Step-by-Step Development Plan

1. **Initialization:**
   - Initialize the RSI and EMA indicators with the desired periods and timeframes.

2. **Indicator Calculation:**
   - In the `OnCalculate` function, calculate the RSI and EMA values for the current and higher timeframes.

3. **Crossover Detection:**
   - Identify when RSI crosses above or below the EMA on the higher timeframe.
   - Use these signals to make trading decisions on the current timeframe.

4. **Trade Execution:**
   - Implement logic to open, close, and reverse trades based on the detected signals.
   - Ensure only one trade is open at any time.

### Detailed Implementation Steps

1. **Indicator Initialization:**
   - Define the periods for RSI and EMA.
   - Define the timeframes for analysis (e.g., H1 for signals, M15 for execution).
   - Initialize buffers to store RSI and EMA values for both timeframes.

2. **Calculate Indicators:**
   - In the `OnCalculate` function, calculate the RSI and EMA for the higher timeframe.
   - Store these values in the respective buffers.

3. **Check for Crossover:**
   - Compare the RSI and EMA values for the current and previous bars on the higher timeframe to detect a crossover.

4. **Trade Logic:**
   - On a bullish crossover (RSI crossing above EMA):
     - Close any open sell position.
     - Open a buy position.
   - On a bearish crossover (RSI crossing below EMA):
     - Close any open buy position.
     - Open a sell position.

5. **Order Management:**
   - Ensure that only one trade is open at any time.
   - Handle errors and edge cases (e.g., if no trade is currently open).

### Pseudocode Outline


#include <Trade\Trade.mqh>


input double LotSize = 0.1;

input int RSIPeriod = 14;

input int EMAPeriod = 14;

input ENUM_TIMEFRAMES TimeFrame = PERIOD_M1;


CTrade trade;


//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

   static double previous_rsi = 0;

   static double previous_ema = 0;


   // Create handles for RSI and EMA

   int handle_rsi = iRSI(_Symbol, TimeFrame, RSIPeriod, PRICE_CLOSE);

   int handle_ema = iMA(_Symbol, TimeFrame, EMAPeriod, 0, MODE_EMA, PRICE_CLOSE);


   // Declare arrays to store indicator values

   double rsi[2];

   double ema[2];


   // Check if handles are valid

   if (handle_rsi < 0 || handle_ema < 0)

   {

      Print("Error creating indicator handles");

      return;

   }


   // Copy indicator values into arrays

   if (CopyBuffer(handle_rsi, 0, 0, 2, rsi) < 0 || CopyBuffer(handle_ema, 0, 0, 2, ema) < 0)

   {

      Print("Error copying indicator values");

      return;

   }


   // Log current RSI and EMA values for debugging

   double current_rsi = rsi[0];

   double current_ema = ema[0];

   Print("Current RSI: ", current_rsi);

   Print("Current EMA: ", current_ema);


   // Ensure previous values are set to current if they are not yet initialized

   if (previous_rsi == 0 && previous_ema == 0)

   {

      previous_rsi = current_rsi;

      previous_ema = current_ema;

      return;

   }


   // Check if there's an open position

   bool isPositionOpen = PositionSelect(_Symbol);


   // Entry criteria

   if (previous_rsi != 0 && previous_ema != 0)

   {

      // Close existing position and open the opposite trade

      if (previous_rsi > previous_ema && current_rsi < current_ema)

      {

         // Sell signal

         if (isPositionOpen && PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)

         {

            trade.PositionClose(_Symbol);

         }

         trade.Sell(LotSize, _Symbol, 0, 0, 0, "Sell on RSI cross below EMA");

         Print("Sell on RSI cross below EMA");

      }

      else if (previous_rsi < previous_ema && current_rsi > current_ema)

      {

         // Buy signal

         if (isPositionOpen && PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)

         {

            trade.PositionClose(_Symbol);

         }

         trade.Buy(LotSize, _Symbol, 0, 0, 0, "Buy on RSI cross above EMA");

         Print("Buy on RSI cross above EMA");

      }

   }


   // Update previous RSI and EMA values

   previous_rsi = current_rsi;

   previous_ema = current_ema;

  }

//+------------------------------------------------------------------+



Откликнулись

1
Разработчик 1
Оценка
(27)
Проекты
34
15%
Арбитраж
6
33% / 50%
Просрочено
5
15%
Работает
2
Разработчик 2
Оценка
(355)
Проекты
484
51%
Арбитраж
24
54% / 25%
Просрочено
5
1%
Загружен
3
Разработчик 3
Оценка
(49)
Проекты
62
40%
Арбитраж
1
0% / 100%
Просрочено
7
11%
Работает
4
Разработчик 4
Оценка
(10)
Проекты
25
28%
Арбитраж
3
0% / 0%
Просрочено
1
4%
Загружен
5
Разработчик 5
Оценка
(2)
Проекты
5
0%
Арбитраж
1
0% / 0%
Просрочено
1
20%
Работает
6
Разработчик 6
Оценка
(42)
Проекты
88
14%
Арбитраж
31
29% / 55%
Просрочено
36
41%
Работает
Похожие заказы
I need to fix the alerts of my SMC Order Blocks indicator, which is a custom indicator created for me some time ago. This custom indicator already has several types of alerts built-in, but I need to fix specific ones while keeping the other existing alerts unchanged, as those do not have any errors. The alert is for a specific Order Blocks pattern. This indicator graphically provides a zigzag, and from there, CHoCH
Mobile robot 50 - 100 USD
I want a profitable scalping EA robot for mt5 and mobile phones (licence key should be provided).the video link attached below indicates how the EA robot should operate it.it analyses the market before taking trades and it trades candle to candle .also coding samples are provided on the video .it should be applicable to all timeframes.it should trade indices(Nas100,US30,S&p500,GER30,)
Martingale EA for MT5 30 - 100 USD
Criteria: Only one trade at a time. Cannot open another trade if one is running Trade on EURUSD only, once job is completed I will be happy to schedule more for other pairs You choose entry strategy and criteria win rate must be above 50% in long term backtest of EURUSD Every trade has got TP and SL Trades to last about a day, few trades a week, at least 10 pips gain per trade, so that it can be launched on normal
I have a indicator, mql file. The signals are seen below on a EURNZD H1 chart. Very important to get accurate entries. The signal to trade is the first tic after the the indicator signal paints. I've tried to demonstrate that below. Other than that the EA will have a lot size escalation, an on-screen pip counter, a button to stop taking new trades, SL/TP, and magic number. I would like the indicator to be within the
I would like to create an EA based on the Shved Supply and Demand indicator. you can find the Shved Supply and Demand v1.7 indicator in the following link https://www.mql5.com/en/code/29395 NB: Checks the trading robot must pass before publication in the Market ( https://www.mql5.com/en/articles/2555 ) MQ5 file to be provided
I want grate robot for making profits that know when to start a good trade and close a trade and must be active all time to avoid lost of money
Hi Guys, I am looking to someone that can generate an indicator for MT4 as explained below. Basically I would need that the indicator point out the price that will close my position in stop out/margin call. The indicator should pick automatically the level of trade out for the broker (which can be different from a broker to another broker) It should write (ideally on the bottom on the left) the following information
Mbeje fx 50+ USD
I like to own my robot that why I want to build my own.i like to be a best to every robot ever in the life to be have more money
I need an MT5 EA that can do the following: I have to give the EA a price in advance, when the price is reached the EA has to automatically place a buy stop or sell stop order 0.5 pips below or above the price. Is this possible
Good day, I want someone to help me create a universal news filter with on/off switch, with start and end settings, and drawdown control with magic number of EAs, etc. Thanks

Информация о проекте

Бюджет
40+ USD
Исполнителю
36 USD
Сроки выполнения
от 1 до 4 дн.