Make EA based on EMA, RSI for MT5

Trabajo finalizado

Plazo de ejecución 19 horas

Tarea técnica

### 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;

  }

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



Han respondido

1
Desarrollador 1
Evaluación
(28)
Proyectos
37
14%
Arbitraje
7
29% / 43%
Caducado
5
14%
Libre
2
Desarrollador 2
Evaluación
(358)
Proyectos
491
52%
Arbitraje
24
54% / 25%
Caducado
5
1%
Trabaja
3
Desarrollador 3
Evaluación
(49)
Proyectos
62
40%
Arbitraje
1
0% / 100%
Caducado
7
11%
Trabaja
4
Desarrollador 4
Evaluación
(11)
Proyectos
27
30%
Arbitraje
3
0% / 0%
Caducado
1
4%
Ocupado
5
Desarrollador 5
Evaluación
(2)
Proyectos
5
0%
Arbitraje
1
0% / 0%
Caducado
1
20%
Trabaja
6
Desarrollador 6
Evaluación
(42)
Proyectos
88
14%
Arbitraje
31
29% / 55%
Caducado
36
41%
Trabaja
Solicitudes similares
The job is simple, I want a custom indicator which consist of a combination of 3 indicators in separate window as I will show you in the screenshot of my mt5 trading platform. The indicators are RSI(period 14, Apply to close) Level 10 Buy, Level 50 Take profit, level 90 Sell) MA( Period 200, Method Exponential, Apply to Median price, Shift 0) BB (Period 25, Apply to close, Deviation 0.035, Shift 0) Ideally on a 1
the code wasn't mine, i have got it somewhere on the web, but i like the performance of the EA, so i want to use it on mt5 platform. the given code based on price movements with ladder entry concept
Good Day I would like to order a trading robot. Pairs: XAUUSD (GOLD) EUR/USD USD/JPY The robot should be trading daily with TP/SL build in, would like to have trailing and stop loss, should execute up to 5 trades (preffarable setting choice) up to 10 trades Los sizes to be choise setting, must also trade major US vews events Like:US- PPI, CPI, NFP, Sales m/m and so on Must also show/display alert when opening
Hello Guys, I need a trading bot for the MT5 to place order based on my trading strategy which is based on - >> entry based on EMA with rejection from specific levels like support and resistance area - levels and time frame i will apply into the robot manually on daily basis. also need - trailing stoploss , shift to breakeven after gaining some points. need a highly expert developer
I have a full strategy based on indicator and candle based on . i would like to make it into a robot which will trade for me on a specific time and specific rules. i need a person who can do this project for me. If you have done this type of job . you are most welcome for this. Apply only if you know binary trading option and binomo trading platform well and how it works
Enter buy trade at close of candle when bar closes above the 3 emas. Emas are 34 ema, 64 ema and 128 ema. For a buy trade the 34 ema must be above the other two emas. The 64 ema should be in the middle. The 128 ema should be below the other two emas. For a buy trade the Awesome Oscillator should be above the middle line and colored green. Exit a buy trade when price touches 64 ema. Sell trade same conditions as buy
I want to make AI based on Attached Picture Swing High low. If you have experience can share demo first. Stop loss, take profit, trailing , break even ,DD etc. also amiable
Hello, I’m looking for a TradingView indicator that fits my forex trading needs. If you can create or customize one for me, please reach out. I'd appreciate your help! Thanks in advance."
Pls I need help I don’t have much but pls accept my little payment for the work thanks 🙏 mt5 file Once it opens buy and move positively to buy let it use auto trailing to follow the trend that’s if I choose to use trailing option and before the trailing starts it must reach the actual profit target example if I set profit target to 500 then once profit is at 500 let trailing immediately protect it and any 1 pip
Hey greetings am in need of a developer that can convert my simple tradingview indicator to MT4 I have the source code of the indicator and is also a public indicator on Tradingview site Kindly bid and let started

Información sobre el proyecto

Presupuesto
40+ USD
Para el ejecutor
36 USD
Plazo límite de ejecución
de 1 a 4 día(s)