//+------------------------------------------------------------------+
//|                                            AI RSI BB SCALPER.mq5 |
//|                                                           Alfr5d |
//|                                       https://www.49design.co.za |
//+------------------------------------------------------------------+

#property copyright   "Copyright 2023, Alfred Mandala. "
#property description "www.billionairebulls.co.za\n"
#property version     "1.5"
#property description "RSI GRID SCALPING EA com Stochastic\n"

// Incluindo bibliotecas necessárias
#include <Trade/Trade.mqh>

// ---- INPUTS ----
input group "--- Trading Inputs ---";
input double Lots                    = 0.01;           // Tamanho do Lote
input int TpPoints                   = 100;             // Take Profit em pontos [m5-50p, h1-200p]
input int StopLossPoints             = 500;             // Stop Loss em pontos [Ex: 20 pontos]
input ENUM_TIMEFRAMES RsiTimeFrame   = PERIOD_CURRENT; // Timeframe

input group "--- RSI Inputs ---";
input int RsiPeriods                 = 18;             // Periodo do RSI
input ENUM_APPLIED_PRICE RsiAppPrice = PRICE_CLOSE;   // Preço aplicado pelo RSI
input double RsiSellTrigger          = 70;             // Zona de Venda do RSI
input double RsiBuyTrigger           = 30;             // Zona de Compra do RSI

input group "--- Bollinger Bands Inputs ---";
input int         BbPeriods          = 23;             // Períodos das BB
input double      BbDeviation        = 2.0;            // Desvio
input double      BbShift            = 0;              // Deslocamento

input group "--- Stochastic Inputs ---";
input int StochKPeriod               = 5;              // Período K do Stoch
input int StochDPeriod               = 3;              // Período D do Stoch
input int StochSlowing               = 3;              // Atraso do Stoch
input double StochOverbought         = 80.0;           // Nível de sobrecompra
input double StochOversold           = 20.0;           // Nível de sobrevenda

input group "--- Moving Averages Inputs ---";
input int MAMainPeriod1              = 50;             // Período da MA de 50
input int MAMainPeriod2              = 200;            // Período da MA de 200

input group "--- Volume Inputs ---";
input int VolumePeriod               = 50;             // Período da média de volume

// ---- GLOBAL VARIABLES ----
int handleRsi, handleBb, handleStochastic, handleMA1, handleMA2, handleVolume;
double rsi[], bbUpper[], bbLower[], stochMain[], ma1[], ma2[], volume[];

CTrade trade;

// ---- EXPERT INIT ----
int OnInit()
{
   handleRsi      = iRSI(_Symbol, RsiTimeFrame, RsiPeriods, RsiAppPrice);
   handleBb       = iBands(_Symbol, PERIOD_CURRENT, BbPeriods, BbShift, BbDeviation, PRICE_CLOSE);
   handleStochastic = iStochastic(_Symbol, PERIOD_CURRENT, StochKPeriod, StochDPeriod, StochSlowing, MODE_SMA, STO_LOWHIGH);
   handleMA1      = iMA(_Symbol, PERIOD_CURRENT, MAMainPeriod1, 0, MODE_SMA, PRICE_CLOSE);
   handleMA2      = iMA(_Symbol, PERIOD_CURRENT, MAMainPeriod2, 0, MODE_SMA, PRICE_CLOSE);
   handleVolume   = iMA(_Symbol, PERIOD_CURRENT, VolumePeriod, 0, MODE_SMA, VOLUME_TICK);

   return (INIT_SUCCEEDED);
}

// ---- EXPERT DEINIT ----
void OnDeinit(const int reason)
{
   IndicatorRelease(handleBb);
   IndicatorRelease(handleRsi);
   IndicatorRelease(handleStochastic);
   IndicatorRelease(handleMA1);
   IndicatorRelease(handleMA2);
   IndicatorRelease(handleVolume);
}

// ---- ON TICK FUNCTION ----
void OnTick()
{
   double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
   CopyBuffer(handleBb, 1, 0, 1, bbUpper);
   CopyBuffer(handleBb, 2, 0, 1, bbLower);
   CopyBuffer(handleRsi, 0, 0, 2, rsi);
   CopyBuffer(handleStochastic, 0, 0, 2, stochMain);
   CopyBuffer(handleMA1, 0, 0, 2, ma1);
   CopyBuffer(handleMA2, 0, 0, 2, ma2);
   CopyBuffer(handleVolume, 0, 0, 2, volume);

   // Febrero para evitar múltiplas ordens (apenas uma por vez)
   if (PositionsTotal() == 0) // Verifica se não há posições abertas
   {
      // Condição de venda usando RSI e Stochastic
      if (rsi[1] > RsiSellTrigger && rsi[0] < RsiSellTrigger && stochMain[0] > StochOverbought && bid < ma1[0] && bid < ma2[0])
      {
         if (bid >= bbUpper[0])
         {
            Print(__FUNCTION__, " > SELL Signal...");
            trade.Sell(Lots, _Symbol, bid, bid + StopLossPoints * _Point, bid - TpPoints * _Point);
         }
      }
      // Condição de compra usando RSI e Stochastic
      else if (rsi[1] < RsiBuyTrigger && rsi[0] > RsiBuyTrigger && stochMain[0] < StochOversold && bid > ma1[0] && bid > ma2[0])
      {
         if (bid <= bbLower[0])
         {
            Print(__FUNCTION__, " > BUY Signal...");
            trade.Buy(Lots, _Symbol, bid, bid - StopLossPoints * _Point, bid + TpPoints * _Point);
         }
      }
   }

   // Lógica para fechamento de posições
   ManagePositions();
   Comment("\nRSI[0]: ", DoubleToString(rsi[0], 5),
           "\nRSI[1]: ", DoubleToString(rsi[1], 5),
           "\nStochastic: ", DoubleToString(stochMain[0], 2),
           "\nMA50: ", DoubleToString(ma1[0], 5),
           "\nMA200: ", DoubleToString(ma2[0], 5),
           "\nVolume: ", DoubleToString(volume[0], 2));
}

// --- Função para gerenciar posições abertas ---
void ManagePositions()
{
   for (int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong posTicket = PositionGetTicket(i);
      if (PositionSelectByTicket(posTicket))
      {
         ENUM_POSITION_TYPE posType = (ENUM_POSITION_TYPE) PositionGetInteger(POSITION_TYPE);
         double posOpenPrice = PositionGetDouble(POSITION_PRICE_OPEN);
         double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
         int points = (posType == POSITION_TYPE_BUY) ? (int)((bid - posOpenPrice) / _Point) : (int)((posOpenPrice - SymbolInfoDouble(_Symbol, SYMBOL_ASK)) / _Point);

         if (points > TpPoints)
         {
            trade.PositionClose(posTicket);
         }
      }
   }
}


corrija os erros:
'AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5'			1
Trade.mqh			
Object.mqh			
StdLibErr.mqh			
OrderInfo.mqh			
HistoryOrderInfo.mqh			
PositionInfo.mqh			
DealInfo.mqh			
possible loss of data due to type conversion	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	57	64
declaration of 'volume' hides global variable	Trade.mqh	303	93
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	546	68
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	599	67
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	646	90
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	808	31
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	827	32
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	846	36
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	864	35
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	882	37
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	900	36
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
declaration of 'volume' hides global variable	Trade.mqh	1386	55
   see previous declaration of 'volume'	AI RSI BB SCALPER_MESA_PRO_FIRM_V8_MAs.mq5	49	64
code generated			1
0 errors, 12 warnings, 752 msec elapsed, cpu='X64 Regular'			13