i need to fix this code pls somebody help me do it , itll be a great help

 
//+------------------------------------------------------------------+
//|                                                    gap_finder.mq4|
//|                                        Copyright 2023, MetaQuotes|
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+

#property copyright "Copyright 2023, MetaQuotes"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
 
input string Symbol1 = "AUDUSD";
input string Symbol2 = "EURUSD";
 
double max_gap[];
double min_gap[];
double current_gap;
string max_gap_symbol, min_gap_symbol;
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
    //--- indicator buffers mapping
    SetIndexBuffer(0, max_gap, INDICATOR_DATA);
    SetIndexBuffer(1, min_gap, INDICATOR_DATA);
    IndicatorSetString(INDICATOR_SHORTNAME, "Gap Finder");
    IndicatorSetInteger(INDICATOR_LEVELS, 2);
    IndicatorSetString(INDICATOR_LEVELTEXT, "Max Gap;Min Gap");
 
    //--- modify the indicator properties
    IndicatorSetInteger(INDICATOR_DIGITS, MarketInfo(Symbol(), MODE_DIGITS));
    IndicatorSetInteger(INDICATOR_HEIGHT, 25);
    IndicatorSetInteger(INDICATOR_WIDTH, 160);
    IndicatorSetInteger(INDICATOR_COLOR, clrWhite);
    IndicatorSetInteger(INDICATOR_LEVELCOLOR, clrWhite);
    IndicatorSetString(INDICATOR_FONT, "Arial");
    IndicatorSetInteger(INDICATOR_TEXTSIZE, 11);
 
    return(INIT_SUCCEEDED);
}
 
//+------------------------------------------------------------------+
//| 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[])
{
    double price1 = 0, price2 = 0;
 
    if (Symbol() == Symbol1)
    {
        price1 = close[0];
    }
    else if (Symbol() == Symbol2)
    {
        price2 = close[0];
    }
 
    if (prev_calculated < 1)
    {
        ArrayInitialize(max_gap, 0);
        ArrayInitialize(min_gap, 0);
        max_gap[0] = MathAbs(price1 - price2);
        min_gap[0] = MathAbs(price1 - price2);
        max_gap_symbol = Symbol();
        min_gap_symbol = Symbol();
    }
    else
    {
        double gap = MathAbs(price1 - price2);
 
        if (gap > max_gap[1])
        {
            max_gap[1] = gap;
            max_gap_symbol = Symbol();
        }
 
        if (gap < min_gap[1])
        {
            min_gap[1] = gap;
            min_gap_symbol = Symbol();
        }
 
        current_gap = gap;
 
        double percent_of_max_gap = (current_gap / max_gap[1]) * 100;
        if (percent_of_max_gap >= 80)
        {
            Alert("Current gap is ", DoubleToStr(percent_of_max_gap, 2), "% of the maximum gap (", DoubleToStr(max_gap[1], MarketInfo(Symbol(), MODE_DIGITS)), ") between ", Symbol1, " and ", Symbol2);
        }
    }
 
    return(rates_total);
}
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2023.04.28
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
  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. Naveen Raaj J R:

    i need to fix this code pls somebody help me do it , itll be a great help

    Help you with what? You haven't stated a problem. Show us your attempt (using the CODE button) and state the nature of your difficulty.
              No free help (2017)

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2018)

    We're not going to code it for you (although it could happen if you are lucky or the issue is interesting).
              No free help (2017)

 
Naveen Raaj J R:

When pasting code, please clean up the white-space. Leaving every second line empty makes it difficult to read.

I will edit your post this time, but please do it properly next time.