Download MetaTrader 5

Problem of CopyOpen()

To add comments, please log in or register
All activity at MQL5.community is clearly visible. Have a look at the Wall!
Jinsong Zhang
15588
Jinsong Zhang 2011.10.25 10:11 

Hi all,

see code:

string _symbol[6]={"EURUSD","EURJPY","USDJPY","AUDUSD","EURGBP","GBPUSD"};
double Open[];

void OnStart()
{
   ArraySetAsSeries(Open,true);
   ushort s=0;
   
   for(int j=0;j<200;j++)
   {
      CopyOpen(_symbol[s],_Period,TimeCurrent()-60,TimeCurrent(),Open);
      s++;
      if(s>5)s=0;
   }
   
}

 After run this script, terminal.exe will always occupy thread even though closed MT5 window. Is this a bug?

minidilly
5
minidilly 2014.03.30 18:30  
https://www.mql5.com/en/docs/series/copyopen
Documentation on MQL5: Timeseries and Indicators Access / CopyOpen
Documentation on MQL5: Timeseries and Indicators Access / CopyOpen
  • www.mql5.com
Timeseries and Indicators Access / CopyOpen - Documentation on MQL5
Alain Verleyen
Moderator
30727
Alain Verleyen 2014.03.30 19:16  
song_song:

Hi all,

see code:

 After run this script, terminal.exe will always occupy thread even though closed MT5 window. Is this a bug?

What is the goal of this loop, that makes no sense.

Why don't you check the returned valie of CopyOpen() to see if there is an error ?

Jinsong Zhang
15588
Jinsong Zhang 2014.04.17 06:12  

Thank you for let me go back to 3 years ago  :D

Alain Verleyen
Moderator
30727
Alain Verleyen 2014.04.17 09:18  
song_song:

Thank you for let me go back to 3 years ago  :D

Oh, I miss it

By the way my questions deserve an answer :-)

Jinsong Zhang
15588
Jinsong Zhang 2014.04.18 04:55  
angevoyageur:

Oh, I miss it

By the way my questions deserve an answer :-)

 

 

actually I have forgot what's the goal of that loop, it seems a little crazy.
Rodrigo Malacarne
Moderator
9892
Rodrigo Malacarne 2014.04.18 05:32  
song_song:
actually I have forgot what's the goal of that loop, it seems a little crazy.

Yes, it is a little crazy... instead of using the "j" index you somehow use the "s" index inside the for loop to do exatly what the "j" index is supposed to do...

Moreover, you set the "j" index to go untill 200, while you have only 6 symbols on your _symbol array.

Basically it is a "bulk" copy of the open values for the 6 symbols on the array (however, bad coded, IMO).

To add comments, please log in or register