Trying to do an ADR Indicator Dashboard

 

Hi Guys I'm trying to do an ADR-Indicator Dashboard. First i want to create the ADR Indicator. I modified an ADR Indicator i found on the forum.

For the dashboard i want to calculate ADR values for several pairs. I wanted to store the calculated values in an array. But as soon I try this, the Indicator shuts down.

Can anybody see the problem? I just can't figure it out.

The problem are the lines of code which I marked with the "//" (last 3 lines of code). The calculated ADR values are correct. I checked them with help of the "Alert" command. But when i wanna store these Values in the Array the Indicator crashes.

Maybe you can help me.

Best regards.


//Input Variables
extern int      NumOfDays             = 10;

//more Variables
double pnt;
int    dig;
string objname = "*DRPE";

string SymbolsArray[]={"", "USDJPY","GER30","AUDCHF"};
double ADRArray[1][3];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()                             
  {
  ArrayInitialize(ADRArray,0);

    
//---
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)

 
//+------------------------------------------------------------------+
//| 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[])
                        
   {
    for(int j=1; j<4; j++)                              // For Loop to go through all pairs
       {                                             
        pnt = MarketInfo(SymbolsArray[j],MODE_POINT); 
        dig = MarketInfo(SymbolsArray[j],MODE_DIGITS);
        if (dig == 1 || dig == 3 || dig == 5)
        {             
          pnt *= 10;
        }
        if (dig == 2)
         {
            pnt *= 100;
         }  
       
        double sum=0;
        
        for (int i=1; i<=NumOfDays+2; i++)                        // Calculating Hi-Lo of the last 10 Days
        {                              
          double hi = iHigh(SymbolsArray[j],PERIOD_D1,i);                      
          double lo = iLow(SymbolsArray[j],PERIOD_D1,i);
          datetime dt = iTime(SymbolsArray[j],PERIOD_D1,i);
          if (TimeDayOfWeek(dt) > 0 && TimeDayOfWeek(dt) < 6)       
          {    
            sum += hi - lo;
            
          }
        }
         double ADR = sum/NumOfDays/pnt;             // Calculating the ADR
         //ADRArray[1][j]= ADR;
         Alert(SymbolsArray[j], "         ", DoubleToStr(ADR,1));
         //Alert(SymbolsArray[j], "         ", DoubleToStr(ADRArray[1][j]));
       }
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2022.11.21
  • 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
 

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 (2019)
          Messages Editor

 

Sorry i forgot it.

Done, thank u for the Short Cut alt+f5. I didn't know it.

 
double ADRArray[4];   //[1][3];
 
@Nagisa Unada: Thank u so much it worked fine! =) <333