There is error on thi code.Can any one fix it,please?

 
#property strict
#property indicator_chart_window

// Input parameters
input int RSI_Period = 14;
input int Stoch_K_Period = 5;
input int Stoch_D_Period = 3;
input int Stoch_Slowing = 3;

// Global variables
double rsiBuffer[];
double stochBuffer[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   // Initialize buffers
   ArraySetAsSeries(rsiBuffer, true);

   // Set indicator properties
   IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
   IndicatorSetString(INDICATOR_SHORTNAME, "RSIStochSignal");

   // Set index buffer
   SetIndexBuffer(0, rsiBuffer);

   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int iRSI(
   string symbol, // Symbol name
   int timeframe, // Timeframe
   int period,    // RSI period
   int applied_price, // Applied price
   int shift       // Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago)
   );   
int iStochastic(
   string symbol, // Symbol name
   int timeframe, // Timeframe
   int period_k,  // K period
   int period_d,  // D period
   int ma_method, // Moving average method for smoothing the K line
   int applied_price, // Applied price
   int shift_k,    // Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago) for the K line
   int ma_method_d, // Moving average method for smoothing the D line
   int shift_d,    // Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago) for the D line
   int index_buffer // Index of the indicator buffer where the resulting indicator values will be stored
);
//+------------------------------------------------------------------+
//| Custom indicator iteration function                             |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   // Calculate RSI
   if (iRSI(_Symbol, _Period, RSI_Period, PRICE_CLOSE, rsiBuffer) < rates_total) return(0);

   // Calculate Slow Stochastic
   if (iStochastic(_Symbol, _Period, Stoch_K_Period* Stoch_Slowing, Stoch_D_Period * Stoch_Slowing, 0, MODE_EMA, 0, MODE_EMA, 0, 0, stochBuffer) < rates_total) return(0);

   // Check for buy/sell signals
   for (int i = 0; i < rates_total; i++)
   {
      if (rsiBuffer[i] > 50 && stochBuffer[i] > 50)
      {
         // Send buy alert/notification
         Alert("Buy Signal at ", TimeToString(time[i]));
         SendNotification("Buy Signal at " + TimeToString(time[i]));
      }
      else if (rsiBuffer[i] < 50 && stochBuffer[i] < 50)
      {
         // Send sell alert/notification
         Alert("Sell Signal at ", TimeToString(time[i]));
         SendNotification("Sell Signal at " + TimeToString(time[i]));
      }
   }

   return(rates_total);
}
//+---------------
 

Is this MQL4 or MQL5 code?

Is this ChatGPT (or other A.I.) generated code generated code?

If so, please, don't request help with it. It generates horrible code, mixing MQL4 and MQL5.

 
  • Usually people who can't code don't receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Book and Documentation
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.