I need to print this ... and having trouble. please help

 

hi

I have a normalized value

   MqlTick tick;
   SymbolInfoTick(_Symbol,tick);
//---
   double Highest = iHighest(Symbol(),my_timeframe,MODE_REAL_VOLUME,shift,1);
   double Lowest = iLowest(Symbol(),my_timeframe,MODE_REAL_VOLUME,shift,1);

   double Normalizado = ((tick.last - Lowest)*100)/(Highest - Lowest);

I'm using Normalizado as handle

And making an array with this

   double Normalizado_val[];
   ArraySetAsSeries(Normalizado_val,true);
   int start_pos_n=0,count_n=50;
   if(!iGetArray_n(Normalizado,0,start_pos_n,count_n,Normalizado_val))
      return;

and this:

bool iGetArray_n(const int handle_n,const int buffer_n,const int start_pos_n,
                 const int count_n,double &arr_buffer_n[])
  {
   bool result_n=true;
   if(!ArrayIsDynamic(arr_buffer_n))
     {
      //if(InpPrintLog)
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__);
      return(false);
     }
   ArrayFree(arr_buffer_n);
//--- reset error code
   ResetLastError();
//--- fill a part of the iBands array with values from the indicator buffer
   int copied_n=CopyBuffer(handle_n,buffer_n,start_pos_n,count_n,arr_buffer_n);
   if(copied_n!=count_n)
     {
      //--- if the copying fails, tell the error code
      //if(InpPrintLog)
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d",
                  __FILE__,__FUNCTION__,count_n,copied_n,GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
   return(result_n);
  }

but getting this error:

2023.06.19 22:21:28.296 2013.03.08 03:11:33   ERROR! EA: Mean Reversion Trading Strategy.mq5, FUNCTION: iGetArray_n, amount to copy: 50, copied: -1, error code 4807

what is this and how can I fix this.

Also; not getting values normaliced to 100 ...  getting values under  0, how can I fix this?



Also ... How can I print this array?

 
  1. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum #6 (2017)

  2. Javier Santiago Gaston De Iriarte Cabrera: I have a normalized value
       double Highest = iHighest(Symbol(),my_timeframe,MODE_REAL_VOLUME,shift,1);
       double Lowest = iLowest(Symbol(),my_timeframe,MODE_REAL_VOLUME,shift,1);

    No you don't. iHighest does not return a double. Perhaps you should read the manual.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.


 
William Roeder #:
  1. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum #6 (2017)

  2. No you don't. iHighest does not return a double. Perhaps you should read the manual.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.


yes! Thanks.

 
William Roeder #:
  1. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum #6 (2017)

  2. No you don't. iHighest does not return a double. Perhaps you should read the manual.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.


Hi I modified iHigh and the rest to this:


   int Highest = iHighest(Symbol(),my_timeframe,MODE_REAL_VOLUME,shift,1);
   int Lowest = iLowest(Symbol(),my_timeframe,MODE_REAL_VOLUME,shift,1);
   double Low= {iLow(Symbol(),my_timeframe,Highest)};
   double High = {iHigh(Symbol(),my_timeframe,Lowest)};

   double Normalizado = (((tick.last - (Low))*100)/((High) - (Low)));
   if(Normalizado!=-1)
     {
      Print(Normalizado);



      double Normalizado_val[];
      ArraySetAsSeries(Normalizado_val,true);
      int start_pos_n=0,count_n=50;
      if(!iGetArray_n(Normalizado,0,start_pos_n,count_n,Normalizado_val))
         return;

     }


but getting values over 100 and under 0, and getting an error in iGetArray_n:

2023.06.20 16:59:09.313 Core 01 2013.05.21 17:12:53   ERROR! EA: Mean Reversion Trading Strategy.mq5, FUNCTION: iGetArray_n, amount to copy: 50, copied: -1, error code 4807

why?

 
Javier Santiago Gaston De Iriarte Cabrera #: but getting values over 100 and under 0 ... why?

The most recent tick is within the range of the current candle. However, your iHighest/iLowest range does not include the current candle as it starts from the previous candle.

So, obviously, the most recent tick can easily be out of the range and break the 0 to 100 normalisation.

 
Fernando Carreiro #:
most recent tick is withi

you are all genius. Thanks, that solved the problem.

Reason: