How to solve the array out of range in my code?

 

Was trying to write a signal trigger alert that only appear once but not sure what it keeps pop out "array out of range"  in my code. Anyone can help on this?

#include <Trade\Trade.mqh>


CTrade trade;


datetime LastActiontime;


void OnTick()

  {

      double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);

      double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);

      datetime myTime[];

      

      double myRSIArray[];

      

      ArraySetAsSeries(myRSIArray,true);

      ArrayResize(myTime,100000,100000);

      int myRSIDefinition = iRSI(_Symbol,_Period,14,PRICE_CLOSE);

      datetime Time = iTime(_Symbol,_Period,0);

      

      CopyBuffer(myRSIDefinition,0,0,3,myRSIArray);

      CopyTime(Time,_Period,0,999999,myTime);

      double myRSIValue0=NormalizeDouble(myRSIArray[0],2);

      double myRSIValue1=NormalizeDouble(myRSIArray[1],2);

      double myRSIValue2=NormalizeDouble(myRSIArray[2],2);

      

      

      if(myRSIValue1>=70 && myRSIValue2<70 

      && LastActiontime!=myTime[0]

      ){

         Alert("RSI cross-up 70"+" "+_Symbol);

         LastActiontime=myTime[0];

      }

      

      if(myRSIValue1<70 && myRSIValue2>=70 

      && LastActiontime!=myTime[0]

      ){

         Alert("RSI cross-down 70"+" "+_Symbol);

         LastActiontime=myTime[0];

      }

      

      if(myRSIValue1<=30 && myRSIValue2>30 

      && LastActiontime!=myTime[0]

      ){

         Alert("RSI cross-down 30"+" "+_Symbol);

         LastActiontime=myTime[0];

      }

      

      if(myRSIValue1>30 && myRSIValue2<=30 

      && LastActiontime!=myTime[0]

      ){

         Alert("RSI cross-up 30"+" "+_Symbol);

         LastActiontime=myTime[0];

      }


  }

 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button



 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2. Your code
     Documentation
          CopyTime(
    Time,          
    _Period,
    0,
    999999,
    myTime
    );
    int  CopyTime(
       string          symbol_name, // symbol name
       ENUM_TIMEFRAMES timeframe,   // period
       int             start_pos,   // start position
       int             count,       // data count to copy
       datetime        time_array[] // target array to copy open times
       );
    Since your call is bogus, nothing happens and your array has zero size. You would know that if you had bothered to check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.

              What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014