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
評価
(24)
プロジェクト
31
16%
仲裁
7
29% / 43%
期限切れ
4
13%
仕事中
2
開発者 2
評価
(343)
プロジェクト
466
52%
仲裁
22
50% / 27%
期限切れ
5
1%
取り込み中
3
開発者 3
評価
(49)
プロジェクト
62
40%
仲裁
1
0% / 100%
期限切れ
7
11%
仕事中
4
開発者 4
評価
(10)
プロジェクト
25
28%
仲裁
2
0% / 0%
期限切れ
1
4%
取り込み中
5
開発者 5
評価
(1)
プロジェクト
3
0%
仲裁
0
期限切れ
0
仕事中
6
開発者 6
評価
(42)
プロジェクト
88
14%
仲裁
30
30% / 53%
期限切れ
36
41%
仕事中
類似した注文
This is not an EA that actually opens/closes trades. Instead this project involves creating a dashboard where the user can create a grid trade scenario with initial entry and scale trade pip distances, lot sizes for each trade, and draw down amount. It then calculates the break-even + profit level where all trades would close. For each new scale trade the BE+ point is recalculated which is then displayed on the
Hi I have the code in pinescript for an indicator that I need done in Ninja Trader, I wanted this indicator in NT bcs I chart in NT, and if the indicator could also have been an automated strategy even better. Please confirm that it will be an indicator and Automated Trading Strategy
Hi guys I would like to k ow if someone has experience with machine learning models? I would like to train a model to identify if there is a range market or trendy market based on several parameters like EMA and ATR for example. If we use for example a 20 and 50 EMA and we measure the distance between both lines the algo should oearn if the trend is strong or weak. If it‘s steong it keeps trending and if it‘s weak
Hello I need a very simple indicator This indicator should show the highest floating or history drawdown of the account It means that it can display the highest number that the account drawdown to be displayed on the chart in this format max drawdown account(xxxx$$) ...date(00/00/00)time:(00:00) max drawdown currency ..( currency name with max drwadown) . (xxxx$$) date(00/00/00)time:(00:00) thanks
I want have the possibility to increase lotsize not alone by Lot-multiplier rather I want add a fix-lot increase for excample for 0,05 lot. I want have this for buy / sell and hedge-buy and hedge sell
Hello, I‘m interested in an indicator to predict the next candles probability (bullish or bearish). But honestly I have no idea how to do this. Would be interested in your opinion how we can create such an indicator. Please let me know if you‘ve done similar work
Profitable EA HFT 50 - 300 USD
From a long time i am searching for a profitable EA i have lost a lot , and now i have only 300$ to buy a profitable EA , i wish to say with 0 losses but some or most traders they don't want to hear this i am really tired of searching for a programmer to just create me a profitable EA with the least losses or zero losses maybe nearly 1 year i am searching i just need an HFT EA that can work very well on MT4,MT5
у нас есть стратегия, нам нужно написать mql5-код ​​для тестера стратегий МТ5,Цена договорная. Мой контакт @abbosaliyev из Telegram Программист должен знать РУССКИЙ ИЛИ УЗБЕКСКИЙ язык. Задание: разработать тестер, который использует шаблон условий на открытие и проверит весь исторический график на всех доступных таймфреймах. Остальная информация будет предоставлена ​​после согласования цены
New york session based strategy 9:30 open Price takes out buy side or sell side liquidity Usually using 15min high and lows 5m entry Price takes out that high/low and price must close strongly back into the zone Is price is above price we have a sell bias vis versa for buys Sl is at the high or low with option for “offset” for cushion Tp is usually the opposite High or low. Would like the option for set pips-points &
Utilizing the MQL5 MetaEditor Wizard, I created an Expert Advisor, having the following Signal indicators: I was able to optimize the EA and reached a backtest with the following specifications: I was able to reach a profit level of 30K, as indicated below. However, the Bot is not without faults and following the backtest, I started a forward test with real live data and the results were not so great. The EA took a

プロジェクト情報

予算
40+ USD
開発者用
36 USD
締め切り
最低 1 最高 4 日