Guys can i please get help fixing the errors in my code here it is:

 

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

//|                                             YourExpertAdvisor.mq5|

//|                        Copyright 2024, MetaQuotes Software Corp. |

//|                                       http://www.metaquotes.net/|

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

#include <Trade\Trade.mqh>

CTrade trade;


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

//| Expert initialization function                                   |

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

int OnInit()

  {

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

   

  }

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

//| Expert tick function                                             |

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

void OnTick()

  {

   double accountBalance = AccountBalance();

   double riskAmount = accountBalance * 0.01; // Risk 1% of account balance

   double profitTarget = accountBalance * 0.03; // Aim for 3% profit


   double sma50 = iMA(NULL, 0, 50, 0, MODE_SMA, PRICE_CLOSE, 0);


   if (Bid > sma50) // Price is above 50 SMA

     {

      // Check for bullish trend and trade logic here

      // For simplicity, let's assume a bullish trend if the close price is above the 50 SMA

      if (Close[1] < sma50 && Close > sma50)

        {

         double entryPrice = Ask;

         double stopLoss = entryPrice - (entryPrice - sma50) * 2; // Set stop loss below the 50 SMA

         double takeProfit = entryPrice + (entryPrice - stopLoss) * 3; // Set take profit at 3 times the risk


         ulong ticket;

         if ((ticket = trade.Buy(0.1)) > 0) // Open a buy position with 0.1 lot size

           {

            trade.PositionModify(ticket, entryPrice, stopLoss, takeProfit);

           }

        }

     }

   else // Price is below 50 SMA

     {

      // Check for bearish trend and trade logic here

      // For simplicity, let's assume a bearish trend if the close price is below the 50 SMA

      if (Close[1] > sma50 && Close < sma50)

        {

         double entryPrice = Bid;

         double stopLoss = entryPrice + (sma50 - entryPrice) * 2; // Set stop loss above the 50 SMA

         double takeProfit = entryPrice - (stopLoss - entryPrice) * 3; // Set take profit at 3 times the risk


         ulong ticket;

         if ((ticket = trade.Sell(0.1)) > 0) // Open a sell position with 0.1 lot size

           {

            trade.PositionModify(ticket, entryPrice, stopLoss, takeProfit);

           }

        }

     }

  }

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

 
Tshepiso Ntshangase: Guys can i please get help fixing the errors in my code
  1. Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
          General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
              Messages Editor
          Forum rules and recommendations - General - MQL5 programming forum (2023)

  2. Help you with what? You haven't stated a problem.

  3. double sma50 = iMA(NULL, 0, 50, 0, MODE_SMA, PRICE_CLOSE, 0);

    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)

Reason: