error:" 'iMA' - wrong parameters count " in my expert for two moving average - page 2

 
//+------------------------------------------------------------------+
//|                                                     Robo IFR.mq5 |
//|                         NENE TRADER                              |
//+------------------------------------------------------------------+
#property strict

//--- Input parameters
input int Periodo = 9;
input double PontoCompra = 30.0;
input double PontoVenda = 70.0;
input double QtdPorEntrada = 2;
input bool SaidaParcial = true;
input double OrdemParcial = 1;
input double TamanhoDaParcial = 100.0;
input bool StopLoss = true;
input double TamanhoDoStop = 350.0;

//--- Global variables
double IFR;
bool SinalC, SinalV;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   //--- Initialization code
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   //--- Cleanup code
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   //--- Calculating RSI
   IFR = iRSI(_Symbol, _Period, Periodo, PRICE_CLOSE);
   double IFR_Anterior = iRSI(_Symbol, _Period, Periodo, PRICE_CLOSE, 1); // Valor do RSI da barra anterior
   SinalC = (IFR_Anterior < PontoCompra) && (IFR > PontoCompra);
   SinalV = (IFR_Anterior > PontoVenda) && (IFR < PontoVenda);

   double Ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double Bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

   //--- Positions handling
   double BuyPosition = PositionSelect(_Symbol) ? PositionGetDouble(POSITION_VOLUME) : 0;
   double BuyPrice = PositionSelect(_Symbol) ? PositionGetDouble(POSITION_PRICE_OPEN) : 0;

   MqlTradeRequest request;
   MqlTradeResult result;
   int result_code;

   if (BuyPosition == 0)
     {
      if (SinalC)
        {
         request.action = TRADE_ACTION_DEAL;
         request.symbol = _Symbol;
         request.volume = QtdPorEntrada;
         request.price = Ask;
         request.type = ORDER_TYPE_BUY;
         request.deviation = 3;
         result_code = OrderSend(request, result);
         if (result_code != 10009) Print("OrderSend failed: ", GetLastError());
        }
     }

   if ((BuyPosition == QtdPorEntrada) && SaidaParcial && StopLoss)
     {
      request.action = TRADE_ACTION_PENDING;
      request.symbol = _Symbol;
      request.volume = OrdemParcial;
      request.price = BuyPrice + TamanhoDaParcial * _Point;
      request.type = ORDER_TYPE_SELL_LIMIT;
      request.deviation = 3;
      result_code = OrderSend(request, result);
      if (result_code != 10009) Print("OrderSend failed: ", GetLastError());

      request.price = BuyPrice - TamanhoDoStop * _Point;
      request.type = ORDER_TYPE_SELL_STOP;
      result_code = OrderSend(request, result);
      if (result_code != 10009) Print("OrderSend failed: ", GetLastError());
     }

   if ((BuyPosition == QtdPorEntrada) && SaidaParcial && !StopLoss)
     {
      request.action = TRADE_ACTION_PENDING;
      request.symbol = _Symbol;
      request.volume = OrdemParcial;
      request.price = BuyPrice + TamanhoDaParcial * _Point;
      request.type = ORDER_TYPE_SELL_LIMIT;
      request.deviation = 3;
      result_code = OrderSend(request, result);
      if (result_code != 10009) Print("OrderSend failed: ", GetLastError());
     }

   if ((BuyPosition == QtdPorEntrada) && !SaidaParcial && StopLoss)
     {
      request.action = TRADE_ACTION_PENDING;
      request.symbol = _Symbol;
      request.volume = BuyPosition;
      request.price = BuyPrice - TamanhoDoStop * _Point;
      request.type = ORDER_TYPE_SELL_STOP;
      request.deviation = 3;
      result_code = OrderSend(request, result);
      if (result_code != 10009) Print("OrderSend failed: ", GetLastError());
     }

   if ((BuyPosition > 0) && StopLoss)
     {
      request.action = TRADE_ACTION_PENDING;
      request.symbol = _Symbol;
      request.volume = BuyPosition;
      request.price = BuyPrice - TamanhoDoStop * _Point;
      request.type = ORDER_TYPE_SELL_STOP;
      request.deviation = 3;
      result_code = OrderSend(request, result);
      if (result_code != 10009) Print("OrderSend failed: ", GetLastError());

      if (SinalV)
        {
         request.action = TRADE_ACTION_DEAL;
         request.symbol = _Symbol;
         request.volume = BuyPosition + QtdPorEntrada / 100;
         request.price = Bid;
         request.type = ORDER_TYPE_SELL;
         result_code = OrderSend(request, result);
         if (result_code != 10009) Print("OrderSend failed: ", GetLastError());
        }
     }

   se ((PosiçãoDeCompra > 0) && !StopLoss)
     {
      se (SinalV)
        {
         request.action = NEGÓCIO_AÇÃO_COMERCIAL;
         solicitação.symbol = _Symbol;
         request.volume = BuyPosition + QtdPorEntrada / 100;
         request.price = Lance;
         request.type = TIPO_DE_PEDIDO_VENDA;
         result_code = OrderSend(solicitação, resultado);
         se (código_resultado != 10009) Print("Falha no OrderSend: ", GetLastError());
        }
     }

   //--- Manuseio de posições de venda
   double SellPosition = PositionSelect(_Symbol) ? PositionGetDouble(VOLUME_DA_POSIÇÃO) : 0;
   duplo PreçoDeVenda = PositionSelect(_Símbolo) ? PositionGetDouble(POSITION_PRICE_OPEN) : 0;

   se (PosiçãoDeVenda == 0)
     {
      se (SinalV)
        {
         request.action = NEGÓCIO_AÇÃO_COMERCIAL;
         solicitação.symbol = _Symbol;
         request.volume = QtdPorEntrada;
         request.price = Lance;
         request.type = TIPO_DE_PEDIDO_VENDA;
         solicitação.desvio = 3;
         result_code = OrderSend(solicitação, resultado);
         se (código_resultado != 10009) Print("Falha no OrderSend: ", GetLastError());
        }
     }

   se ((PosiçãoDeVenda == QtdPorEntrada) && SaidaParcial && StopLoss)
     {
      request.action = AÇÃO_COMERCIAL_PENDENTE;
      solicitação.symbol = _Symbol;
      request.volume = OrdemParcial;
      request.price = PreçoDeVenda - TamanhoDaParcial * _Ponto;
      request.type = TIPO_DE_PEDIDO_LIMITE_DE_COMPRA;
      solicitação.desvio = 3;
      result_code = OrderSend(solicitação, resultado);
      se (código_resultado != 10009) Print("Falha no OrderSend: ", GetLastError());

      request.price = PreçoDeVenda + TamanhoDoParada * _Ponto;
      request.type = TIPO_DE_PEDIDO_PARAR_COMPRA;
      result_code = OrderSend(solicitação, resultado);
      se (código_resultado != 10009) Print("Falha no OrderSend: ", GetLastError());
     }

   se ((PosiçãoDeVenda == QtdPorEntrada) && SaidaParcial && !StopLoss)
     {
      request.action = AÇÃO_COMERCIAL_PENDENTE;
      solicitação.symbol = _Symbol;
      request.volume = OrdemParcial;
      request.price = PreçoDeVenda - TamanhoDaParcial * _Ponto;
      request.type = TIPO_DE_PEDIDO_LIMITE_DE_COMPRA;
      solicitação.desvio = 3;
      result_code = OrderSend(solicitação, resultado);
      se (código_resultado != 10009) Print("Falha no OrderSend: ", GetLastError());
     }

   se ((PosiçãoDeVenda == QtdPorEntrada) && !SaidaParcial && StopLoss)
     {
      request.action = AÇÃO_COMERCIAL_PENDENTE;
      solicitação.symbol = _Symbol;
      request.volume =PosiçãoDeVenda;
      request.price = PreçoDeVenda + TamanhoDoParada * _Ponto;
      request.type = TIPO_DE_PEDIDO_PARAR_COMPRA;
      solicitação.desvio = 3;
      result_code = OrderSend(solicitação, resultado);
      se (código_resultado != 10009) Print("Falha no OrderSend: ", GetLastError());
     }

   se ((PosiçãoDeVenda > 0) && StopLoss)
     {
      se (SinalC)
        {
         request.action = NEGÓCIO_AÇÃO_COMERCIAL;
         solicitação.symbol = _Symbol;
         request.volume =PosiçãoVenda + QtdPorEntrada / 100;
         request.price = Pedir;
         request.type = TIPO_DE_PEDIDO_COMPRA;
         result_code = OrderSend(solicitação, resultado);
         se (código_resultado != 10009) Print("Falha no OrderSend: ", GetLastError());
        }

      request.action = AÇÃO_COMERCIAL_PENDENTE;
      solicitação.symbol = _Symbol;
      request.volume =PosiçãoDeVenda;
      request.price = PreçoDeVenda + TamanhoDoParada * _Ponto;
      request.type = TIPO_DE_PEDIDO_PARAR_COMPRA;
      solicitação.desvio = 3;
      result_code = OrderSend(solicitação, resultado);
      se (código_resultado != 10009) Print("Falha no OrderSend: ", GetLastError());
     }

   se ((PosiçãoDeVenda > 0) && !StopLoss)
     {
      se (SinalC)
        {
         request.action = NEGÓCIO_AÇÃO_COMERCIAL;
         solicitação.symbol = _Symbol;
         request.volume =PosiçãoVenda + QtdPorEntrada / 100;
         request.price = Pedir;
         request.type = TIPO_DE_PEDIDO_COMPRA;
         result_code = OrderSend(solicitação, resultado);
         se (código_resultado != 10009) Print("Falha no OrderSend: ", GetLastError());
        }
     }

   //--- Cores de barra de tinta
   int índice de barras = 0;
   barra de coresColor = clrWhite;
   se (SinalC)
      barColor = clrLime;
   se (SinalV)
      barColor = clrVermelho;
   ChartSetInteger(0, CHART_COLOR_CANDLE_BULL, cor_da_barra);
   ChartSetInteger(0, CHART_COLOR_CANDLE_BEAR, barColor);
  }
//+------------------------------------------------------------------+



MEUCODIGO ESTA DANDO ERRO NESSA PARTE 

 duplo IFR_Anterior = iRSI(_Símbolo, _Período, Período, PREÇO_FECHAMENTO, 1); // Valor do RSI da barra anterior
 
NENE RECORDS #:
iRSI


English forum.


Check the API. iRSI uses 4 parameters. You took 5.

https://www.mql5.com/en/docs/indicators/irsi

Documentation on MQL5: Technical Indicators / iRSI
Documentation on MQL5: Technical Indicators / iRSI
  • www.mql5.com
The function returns the handle of the Relative Strength Index indicator. It has only one buffer. Parameters symbol [in] The symbol name of the...
 
//+------------------------------------------------------------------+
//|                                                     DavinExpert.mq5 |
//|                        Copyright 2024, MetaQuotes Software Corp. |
//|                                      Davin                         |
//+------------------------------------------------------------------+
#include <Trade\Trade.mqh>

input string   trade_symbol = "EURUSD";    // Symbol to trade
input int      fast_period  = 10;          // Fast MA period
input int      slow_period  = 30;          // Slow MA period
input double   lot_size     = 0.1;         // Lot size
input double   take_profit  = 50;          // Take profit in points
input double   stop_loss    = 50;          // Stop loss in points
input int      magic_number = 123456;      // Magic number

CTrade trade;

double fast_ma, slow_ma;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   Print("DavinExpert initialized.");
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   // Your existing code here...

   // Ensure that the EA only trades EUR/USD
   if (_Symbol != trade_symbol)
      return;

   fast_ma = iMA(trade_symbol, PERIOD_CURRENT, fast_period, 0, MODE_SMA, PRICE_CLOSE, 0);
   slow_ma = iMA(trade_symbol, PERIOD_CURRENT, slow_period, 0, MODE_SMA, PRICE_CLOSE, 0);

   if (fast_ma > slow_ma && PositionSelect(trade_symbol) == false)
   {
      // Open a buy position
      double price = SymbolInfoDouble(trade_symbol, SYMBOL_ASK);
      double sl = price - stop_loss * _Point;
      double tp = price + take_profit * _Point;
      trade.SetExpertMagicNumber(magic_number);
      trade.Buy(lot_size, trade_symbol, price, sl, tp, "Buy order");
   }

   if (fast_ma < slow_ma && PositionSelect(trade_symbol) == true)
   {
      // Close the position
      trade.PositionClose(trade_symbol);
   }

}

my ima parameter count have error please help

 

1. Stop hijacking threads and make your own

2. Stop using AI to try to do the work for you

3. Learn to code, and learn to read an API