Scripts: sHistoryExport - handy script to export the historical data in the МТ4 format - page 4

 

Hello,


Is it possible to change the script so that the generated .csv file is made from the present to the past?

Grateful for the attention.

Thank you

 
CarlosFa:

Is it possible to change the script so that the generated .csv file is made from the present to the past?

Yes, just change this row:

for ( int i = copy_count-1; i > 0; i -- )

to the following:

for ( int i = 1; i < copy_count; i ++ )
 
metatrader 5 custom chart convert file. File do not open.Help please
 
Lvbey:

Thank you very much.  It's works for me!

But I found that there is a line of code should be  like this(about line 125 in this script):

line 125: for ( int i = copy_count-1; i >= 0; i -- )...

because of the i > 0(I think it should be i >= 0), there is not the first record.

^_^ 

if you replace > 0 with >= 0, you retrieve also the data of the last (ie most recent, the current) bar, which is probably incomplete. While this may be the desired behaviour, it may be quite misleading.


Thanks Andrey Khatimlianskii !

 
Hello my friend, when I run the script the last candle does not appear in the .csv files. For example, in Brazil, the last day of negotiations was the last 4th of September and the export only shows until the 3rd of September.
I exported the .csv in the standard form of Metatrader 5 (File> Save) and the September 4th candle appears. Would you help me?
 
gscruzz:
Hello my friend, when I run the script the last candle does not appear in the .csv files. For example, in Brazil, the last day of negotiations was the last 4th of September and the export only shows until the 3rd of September.
I exported the .csv in the standard form of Metatrader 5 (File> Save) and the September 4th candle appears. Would you help me?

Hi!

Just change "i > 0" to "i >= 0" in this row:

for ( int i = copy_count-1; i >= 0; i -- )
 

Hello,

I believe I am doing something wrong. After I finish running my EA on the Strategy Tester, I drag and drop this script into the output chart but I only get empty results. There´s something really basic that I am not getting. Can you help me?

Thanks

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 

2021.01.05 21:10:32.910 HistoryExport (Usa500,H1) Downloading history and writing files: 0.0% complete...


// no more than 100 failed attempts
if(++fail_cnt >= 100)
   return false;

Doesn't matter if it is 100 or 1 million attempts, the following block never succeeds:

//copying of next part forces data loading
if (CopyTime(symbol,period,size-1,1,times)==1)
{
   return true;
}
Also in CheckServerHistory:
//Enough data on server?
if (first_server_date>TimeCurrent()-size*PeriodSeconds(period))
   return false;

this hard condition is *always* returning false because the recognised first_server_date is usually nearer to the present than the expected history would reach into the past. Especially if you assign in the charts option the "max bars in chart" to "unlimited" then TERMINAL_MAXBARS will return 1000000 and thus this condition would always consider that there is never enough history loaded.

 
The script is not that long now, go through it with the debugger to see at which line the script 'turns wrong'.
 
Marcel Fitzner:

2021.01.05 21:10:32.910 HistoryExport (Usa500,H1) Downloading history and writing files: 0.0% complete...


Doesn't matter if it is 100 or 1 million attempts, the following block never succeeds:

Also in CheckServerHistory:

this hard condition is *always* returning false because the recognised first_server_date is usually nearer to the present than the expected history would reach into the past. Especially if you assign in the charts option the "max bars in chart" to "unlimited" then TERMINAL_MAXBARS will return 1000000 and thus this condition would always consider that there is never enough history loaded.

You're right, I just copied this code from the standard library.

I've already rewritten these functions to fit my needs. But not ready to update the publication at the moment.