can soeone help me fiz this code for the bot/signal i am trying to make

 
//+------------------------------------------------------------------+
//|                                                      ATR_Trailing |
//|                        Generated for MetaTrader 5                 |
//+------------------------------------------------------------------+
#include <Trade\Trade.mqh>

input double keyvalue = 3.0;          // Key Value for sensitivity
input int atrperiod = 10;             // ATR Period
input int emaLength = 9;              // Length for EMA
input int smoothingLength = 5;        // Length for smoothing
input string typeMA = "SMA";          // Type of Moving Average for smoothing
input double lotSize = 0.1;           // Lot size for trading

double atrValue, atrTrailingStop, nLoss, prevAtrTrailingStop, smoothingValue;
double emaValue;
int pos = 0;
CTrade trade;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   // Initialization of indicators
   atrValue = iATR(_Symbol, PERIOD_CURRENT, atrperiod);
   emaValue = iMA(_Symbol, PERIOD_CURRENT, emaLength, 0, MODE_EMA, PRICE_CLOSE);
   
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   // Cleanup code if necessary
  }

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double currentClose = Close[0];
   double prevClose = Close[1];
   
   // Calculate ATR
   atrValue = iATR(_Symbol, PERIOD_CURRENT, atrperiod);
   nLoss = keyvalue * atrValue;

   // Calculate ATR Trailing Stop
   if (currentClose > prevAtrTrailingStop)
      atrTrailingStop = currentClose - nLoss;
   else
      atrTrailingStop = currentClose + nLoss;

   if (prevClose > prevAtrTrailingStop && currentClose < prevAtrTrailingStop)
      pos = -1; // Sell condition
   else if (prevClose < prevAtrTrailingStop && currentClose > prevAtrTrailingStop)
      pos = 1; // Buy condition

   // Execute trades based on signals
   if (pos == 1 && !PositionSelect(_Symbol))
     {
      trade.Buy(lotSize, _Symbol);
     }
   else if (pos == -1 && !PositionSelect(_Symbol))
     {
      trade.Sell(lotSize, _Symbol);
     }

   prevAtrTrailingStop = atrTrailingStop;

   // Calculate EMA
   emaValue = iMA(_Symbol, PERIOD_CURRENT, emaLength, 0, MODE_EMA, PRICE_CLOSE);

   // Calculate smoothing line (if needed, based on selected type)
   if (typeMA == "SMA")
      smoothingValue = iMAOnArray(emaValue, 0, smoothingLength, 0, MODE_SMA);
   else if (typeMA == "EMA")
      smoothingValue = iMAOnArray(emaValue, 0, smoothingLength, 0, MODE_EMA);
   else if (typeMA == "SMMA (RMA)")
      smoothingValue = iMAOnArray(emaValue, 0, smoothingLength, 0, MODE_RMA);
   else if (typeMA == "WMA")
      smoothingValue = iMAOnArray(emaValue, 0, smoothingLength, 0, MODE_WMA);
  }

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

Files:
unnamed.png  39 kb
 
  1.    double currentClose = Close[0];
       double prevClose = Close[1];
    

    There are no predefined arrays in MT5 unless you define them.
              Using global arrays like Open[], Close[], Low[], High[] in custom indicator for MetaTrader 5 - MQL5 programming forum (2023)

  2. There is no imaOnArray in MT5. Migrating from MQL4 to MQL5 - MQL5 Articles

  3. //|                        Generated for MetaTrader 5                 |

    ChatGPT (the worst), “Bots Builder”, “EA builder”, “EA Builder Pro”, EATree, “Etasoft forex generator”, “Forex Strategy Builder”, ForexEAdvisor (aka. ForexEAdvisor STRATEGY BUILDER, and Online Forex Expert Advisor Generator), ForexRobotAcademy.com, forexsb, “FX EA Builder”, fxDreema, Forex Generator, FxPro, “LP-MOBI”, Molanis, “Octa-FX Meta Editor”, Strategy Builder FX, “Strategy Quant”, “Visual Trader Studio”, “MQL5 Wizard”, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.

    Since you haven't learned MQL4/5, therefor there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.

    We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

    ChatGPT
    1. Even it says do not use it for coding. * 
    2. Mixing MT4 and MT5 code together.
    3. Creating multiple OnCalculate/OnTick functions.
    4. OnCalculate returning a double.
    5. Filling buffers with zero in OnInit (they have no size yet). Setting buffer elements to zero but not setting Empty Value to correspond.
    6. Calling undefined functions.
    7. Calling MT4 functions in MT5 code.
    8. Sometimes, not using strict (MT4 code).
    9. Code that will not compile.
    10. Creating code outside of functions. * 
    11. Creating incomplete code. * 
    12. Initialization of Global variables with non-constants. * 
    13. Assigning a MT5 handle to a double or missing the buffer and bar indexes in a MT4 call. * 
    14. Useing MT4 Trade Functions without first selecting an order. * 
    15. Uses NULL in OrderSend. * 
    bot builder Creating two OnInit() functions. * 
    EA builder
    1. Counting up while closing multiple orders.
    2. Not useing time in new bar detection.
    3. Not adjusting for 4/5 digit brokers, TP/SL and slippage. * 
    4. Not checking return codes.
    EATree Uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)
    ForexEAdvisor
    1. Non-updateing global variables.
    2. Compilation errors.
    3. Not checking return codes.
    4. Not reporting errors.
    FX EA Builder
    1. Not checking return codes.
    2. Loosing open tickets on terminal restart. No recovery (crash/power failure.)
    3. Not adjusting stops for the spread. * 
    4. Using OrdersTotal directly.
    5. Using the old event handlers.

  4.    atrValue = iATR(_Symbol, PERIOD_CURRENT, atrperiod);

    Perhaps you should read the manual, especially the examples.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

    They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
              Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
              Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
              How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
              How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
              MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
              How to call indicators in MQL5 - MQL5 Articles (2010)