Need someone to check this coding it wordks but stops after a few trades and it has the 103 and 4110 errors, thanks in advance

 
//+------------------------------------------------------------------+
//|                                                      YourEA.mq4 |
//|                        Copyright 2024, Your Company             |
//|                                       https://www.yourcompany.com|
//+------------------------------------------------------------------+
#property strict

// Define input parameters
input int rsiPeriod = 14; // RSI period
input int maPeriod = 20; // MA period
input int bbPeriod = 20; // BB period
input double bbDeviation = 2.0; // BB deviation
input int buyThreshold = 70; // RSI level for buying
input int sellThreshold = 30; // RSI level for selling
input double lotSize = 0.01; // Trading lot size
input double maxLot = 1.0; // Maximum lot size allowed
input double minLot = 0.01; // Minimum lot size allowed
input double marginSafetyFactor = 1.5; // Margin safety factor
input int superTrendPeriod = 10; // SuperTrend period
input double superTrendMultiplier = 1.0; // SuperTrend multiplier
input int stopLossPips = 100; // Stop loss in pips
input int takeProfitPips = 200; // Take profit in pips
input int slippage = 3; // Slippage value
input int stopLossBuffer = 98; // Stop loss buffer in pips
input int takeProfitBuffer = 198; // Take profit buffer in pips
input int maxAllowedTrades = 100; // Maximum allowed trades

// Define global variables
int ticket = 0; // Variable to store the order ticket number
int totalTrades = 0; // Total number of trades
int winningTrades = 0; // Number of winning trades
bool trendUp = false; // Flag to indicate if the trend is up
bool trendDown = false; // Flag to indicate if the trend is down

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
{
    RSIMA_BB_SuperTrend_Strategy();
}

//+------------------------------------------------------------------+
//| RSI, MA, BB, and SuperTrend Strategy function                     |
//+------------------------------------------------------------------+
void RSIMA_BB_SuperTrend_Strategy()
{
    double rsi = iRSI(NULL, 0, rsiPeriod, PRICE_CLOSE, 0); // Calculate RSI on the current timeframe
    double ma = iMA(NULL, 0, maPeriod, 0, MODE_SMA, PRICE_CLOSE, 0); // Calculate MA on the current timeframe
    double bbUpper = iBands(NULL, 0, bbPeriod, bbDeviation, 0, PRICE_CLOSE, MODE_UPPER, 0); // Calculate BB Upper on the current timeframe
    double bbLower = iBands(NULL, 0, bbPeriod, bbDeviation, 0, PRICE_CLOSE, MODE_LOWER, 0); // Calculate BB Lower on the current timeframe

    // Calculate SuperTrend values
    double superTrendUp = iCustom(NULL, 0, "SuperTrend", superTrendPeriod, superTrendMultiplier, 0, 0);
    double superTrendDown = iCustom(NULL, 0, "SuperTrend", superTrendPeriod, superTrendMultiplier, 0, 0);

    // Check if the trend is up or down
    if (Close[1] > superTrendUp)
        trendUp = false;
    else
        trendUp = true;

    if (Close[1] < superTrendDown)
        trendDown = false;
    else
        trendDown = true;

    // Limiting trades
    if (totalTrades >= maxAllowedTrades) {
        Print("Maximum number of trades reached. No new trades will be placed.");
        return;
    }

    // Buy condition
    if (trendUp && rsi < buyThreshold && Close[1] > ma && Low[1] > bbLower)
    {
        double stopLossLevel = NormalizeDouble(Bid - stopLossPips * Point, Digits);
        double takeProfitLevel = NormalizeDouble(Bid + takeProfitPips * Point, Digits);

        // Add buffer to stop loss and take profit levels
        stopLossLevel -= stopLossBuffer * Point;
        takeProfitLevel += takeProfitBuffer * Point;

        ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, slippage, stopLossLevel, takeProfitLevel, "RSI Buy", 0, Blue);
        if (ticket > 0)
        {
            totalTrades++;
        }
        else
        {
            Print("OrderSend (Buy) failed with error: ", GetLastError());
        }
    }

    // Sell condition
    if (trendDown && rsi > sellThreshold && Close[1] < ma && High[1] < bbUpper)
    {
        double stopLossLevel = NormalizeDouble(Ask + stopLossPips * Point, Digits);
        double takeProfitLevel = NormalizeDouble(Ask - takeProfitPips * Point, Digits);

        // Add buffer to stop loss and take profit levels
        stopLossLevel += stopLossBuffer * Point;
        takeProfitLevel -= takeProfitBuffer * Point;

        ticket = OrderSend(Symbol(), OP_SELL, lotSize, Bid, slippage, stopLossLevel, takeProfitLevel, "RSI Sell", 0, Red);
        if (ticket > 0)
        {
            totalTrades++;
        }
        else
        {
            Print("OrderSend (Sell) failed with error: ", GetLastError());
        }
    }
}
 
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Your code
        if (Close[1] > superTrendUp)
            trendUp = false;
        else
            trendUp = true;
    Simplified
        trendUp = Close[1] <= superTrendUp;
  3. Aldan Parris:

    it has the 103 and 4110 errors

    There is no such error 103 in MT4.
              Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL4 Reference

  4. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)