need help to convert code to mt5

 
Hi, i'm having trouble to convert an mql4 indicator to mql5, as usual, mql5 is not being very friendly, on mql4 i can copy an array like Close[i] easily on a loop, but how can i do that on mql5?


I made some research, i know there is copyclose, but i don't know how to use it, and there is no free manual out there. 


#property indicator_chart_window

input int NumberOfBNars = 10;
int file_handleWrite = -1;
string filename= "pair.csv";
int limit,i;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {

      OnTimer();

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
        if(file_handleWrite >= 0) {
                FileClose(file_handleWrite);
                file_handleWrite = -1;
        }
        Comment("");
        EventKillTimer();
   
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer(){
   
    
        if(1000 -1 >= NumberOfBNars-1)
        {limit = NumberOfBNars-1;}
        
        if(1000 -1 <  NumberOfBNars-1 || NumberOfBNars == 0)
        {limit = 1000 - 1;}
        
         file_handleWrite = FileOpen(filename,FILE_CSV|FILE_WRITE,',');
        
            
       for(i=limit;i>=0;i--)
      {
            
        FileWrite(file_handleWrite,5, "HOW WOULD BE CLOSE[I] ON MT5?"); /// HERE I NEED TO COPY CLOSE [I] DATA, ON THIS LOOP, CAN SOMEONE SHOW ME HOW CAN I DO THIS
      }

   
    
     FileClose(file_handleWrite);
     Comment("done");
          
     
      EventSetTimer(5);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+


 
mrluck012: Hi, i'm having trouble to convert an mql4 indicator to mql5, as usual, mql5 is not being very friendly, on mql4 i can copy an array like Close[i] easily on a loop, but how can i do that on mql5?

I made some research, i know there is copyclose, but i don't know how to use it, and there is no free manual out there.

 

i tried it but i didn't understood the examples, so how can i set:


close [ i ] for MT5? i only need that, i'll copy open, time, low, high, but i just need you to show me this, please

 
mrluck012: i tried it but i didn't understood the examples, so how can i set: close [ i ] for MT5? i only need that, i'll copy open, time, low, high, but i just need you to show me this, please

Migrating from MQL4 to MQL5

3. Predefined Variables

MQL4
 MQL5Description
double Close[]
double Close[];
int count;   // number of elements to copy
ArraySetAsSeries(Close,true);
CopyClose(_Symbol,_Period,0,count,Close);
Close
Series array that contains close prices for each bar of the current chart.
CopyClose, ArraySetAsSeries
 
mrluck012: i tried it but i didn't understood the examples, so how can i set: close [ i ] for MT5? i only need that, i'll copy open, time, low, high, but i just need you to show me this, please
However, why are you using OnTimer() when the close[] values are already available to you in the OnCalculate() even handler (and in a similar way to MT4)?
 

ok, but what star_pos mean? what count mean? i tried to put CopyClose (NULL,5,0,0,i) and it didn't worked. That is the problem, they don't explain what all those pieces mean

 
Fernando Carreiro:
However, why are you using OnTimer() when the close[] values are already available to you in the OnCalculate() even handler (and in a similar way to MT4)?

i need it to update based on time, not incoming ticks, so could you show me how to code close [ i ] on mt5? just show me the code, and i'll try to understand

 
mrluck012: i need it to update based on time, not incoming ticks, so could you show me how to code close [ i ] on mt5?

Why do you need to use a Timer. If there are no new ticks, there is nothing new to output!

Besides, I have already shown you, with 4 lines of basic code. If you don't understand it, then you need to learn the basics first.

 
mrluck012: WTF are you crazy? i ASKED what  star_pos mean? what count mean? NOWHERE they explain it, i don't have time to test all different possibilities to learn this, show me how would be the code, then you'll have really helped

The documentation already answers those questions. I repeat, if you don't understand it then you need to learn the basics first:

English
 Português

Parameters

symbol_name

[in]  Symbol name.

timeframe

[in]  Period.

start_pos

[in]  The start position for the first element to copy.

count

[in]  Data count to copy.

start_time

[in]  The start time for the first element to copy.

stop_time

[in]  Bar time, corresponding to the last element to copy.

close_array[]

[out]  Array of double type.

Parâmetros

symbol_name

[in]  Nome do ativo.

timeframe

[in]  Período.

start_pos

[in]  A posição de início do primeiro elemento para copiar.

count

[in]  Quantidade de dados para copiar.

start_time

[in]  A hora de início para o primeiro elemento para copiar.

stop_time

[in]  Hora da barra, correspondente ao último elemento para copiar.

close_array[]

[out]  Array de tipo double.

 

I can code for mql4 but no mql5, because THERE IS NO BOOK OUT THERE, and it's easy if you study programming in college, but i didn't, i just need 1 example of Close [ 1 ] code, simple, i don't want you to code for me, but show me some examples, that's the purpose of this forum

 
mrluck012:

i think both of you guy are not here for helping anyone, but just to make an appearance to get some jobs on freelance, i don't need that, because i'm a real trader

You don't understand, once again. Fernando and I helped and will continue to help a lot of people (seems you can't even see that).

It's about you. I am trying to disgust you to just come here, as I am tired to read all your stupidities. I hope it's clear enough, you are not welcome.

Reason: