But the only idea which i did have was to change the for loop to make only 1 or 2 runs, but if i do that, then i have later just 1 or 2 candelsticks in the chart, because it looks like the complete .hst file is overwritten.
I dont know if you need to open the .hst file with different parameters or if you need to make something else to get it just updateing the last candelstick, if somebody know how to do it correctly your help would be appricated.
Here is my current EA script code, i just show the part of the code which does create the candelstick .hst file:
- Code: Select all
//+------------------------------------------------------------------+
//| Save HST File |
//+------------------------------------------------------------------+
ExtHandle=FileOpenHistory(NewFileName,FILE_BIN|FILE_WRITE|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_ANSI);
if(ExtHandle<0) return;
//--- write history file header
c_copyright="(C)opyright 2003, MetaQuotes Software Corp.";
ArrayInitialize(i_unused,0);
FileWriteInteger(ExtHandle,file_version,LONG_VALUE);
FileWriteString(ExtHandle,c_copyright,64);
FileWriteString(ExtHandle,c_symbol,12);
FileWriteInteger(ExtHandle,i_period,LONG_VALUE);
FileWriteInteger(ExtHandle,i_digits,LONG_VALUE);
FileWriteInteger(ExtHandle,0,LONG_VALUE);
FileWriteInteger(ExtHandle,0,LONG_VALUE);
FileWriteArray(ExtHandle,i_unused,0,13);
int BarsBack=1000; // when i change this to 1 or 2 then i have just 1 or 2 candelsticks data in the file
for(int i=BarsBack; i>=1; i--)
{
//--- write history file
if(date>0)
{
start_pos=BarsBack;
rate.open=open;
rate.low=low;
rate.high=high;
rate.close=close;
rate.tick_volume=(long)volume;
rate.spread=0;
rate.real_volume=0;
rate.time=date;
if(IsStopped()) break;
last_fpos=FileTell(ExtHandle);
last_volume=(long)volume;
FileWriteStruct(ExtHandle,rate);
}
}//for
//---
FileFlush(ExtHandle);
FileClose(ExtHandle);