Another Waiting for Update question--offline charts

 

Hi,

I am new to MQL4 but have been coding and playing with EA's for the last six weeks. I am trying to view a chart of the TICKS in the eur/usd as they appear and play with that data.

I am new enough to not know if there is an easy way to do that. I am stubborn enough to try and do it myself. I understand I can play with the raw data without a chart but would like to see if I can visualize it outside of a spreadsheet.

So far I have successfully collected hours of tick data and written it to a csv. I have also examined PeriodConverter and written a .hst in the history directory. My approach is to re-write the file every time a new tick appears and have an offline chart show that data, refreshing with each tick (or so--I realize that that may be overburdensome and slow--probably better to append).

When I open the file in an offline chart I see one of two results: If the currency pair name is the same as a live chart I get the live chart data and not the data out of the .hst file. If I change the name of the currency pair to something unrecognizable it shows "Waiting for Update". I've tried this with the ea off so it is not trying to write file while it is in use.

I'm not asking for someone to debug my code--But I could use a few suggestiong for what to look for. For example, I've read that the currency pair name should be dissimilar from a live pair or MT4 will use the live data. If I change the name to something unrecognizable will it reject the file due to an unkown currency pair? Do I need to add it somehow to symbols.sel? Is there some other sample code I can look at that does this or something similar?

I am pretty sure my file format is fine but I'll verify it with a binary reader.

Many Thanks

bool write_hst()
   {
      
      double d_low, d_high, d_open, d_close;
      double d_volume = 1;
      
      string c_symbol = Symbol();
      int    i_period =  1;            //Default, not sure what to put here
      int    i_digits = Digits;
      int    i_unused[13];
      
      int    i_time;
      int    ExtHandle   = -1;            //File handle

      string FileName = c_symbol + "" + i_period + ".hst";



      // Make sure that at least MinItems in array before processing
      if (LastItem < MinItems) return (false);


      //Open the file in the HISTORY directory           
      ExtHandle = FileOpenHistory(FileName, FILE_BIN|FILE_WRITE);

      
      if (ExtHandle < 0) return (false);      //Unable to open the file

      Alert("History File Opened");
      
      //Write file header
      FileWriteInteger(ExtHandle, Version, LONG_VALUE);
      FileWriteString (ExtHandle, CopyRight, 64);
      FileWriteString (ExtHandle, c_symbol + "", 12);
      FileWriteInteger(ExtHandle, i_period, LONG_VALUE);
      FileWriteInteger(ExtHandle, i_digits, LONG_VALUE);
      FileWriteInteger(ExtHandle, 0, LONG_VALUE);       //timesign
      FileWriteInteger(ExtHandle, 0, LONG_VALUE);       //last_sync
      FileWriteArray  (ExtHandle, i_unused, 0, 13);
      

      int count = 0;
      while (count <= LastItem)
         {
            d_low   = Ticks[0][count];       //bid      
            d_high  = Ticks[1][count];       //ask 
            d_open  = (d_low + d_high) /2;   //open and closed are simply average of Bid/Ask
            d_close =  d_open;      
            i_time  = TickTime[count];
         
            FileWriteInteger(ExtHandle, i_time, LONG_VALUE);
            FileWriteDouble(ExtHandle, d_open, DOUBLE_VALUE);
            FileWriteDouble(ExtHandle, d_low, DOUBLE_VALUE);
            FileWriteDouble(ExtHandle, d_high, DOUBLE_VALUE);
            FileWriteDouble(ExtHandle, d_close, DOUBLE_VALUE);
            FileWriteDouble(ExtHandle, d_volume, DOUBLE_VALUE);   //Volume is set to default of 1 for the moment
            FileFlush(ExtHandle);
         
            count++;
         }
      
      Alert(count, "  Items written");

      FileClose(ExtHandle);               
      return (true);
      
   }

 
niqmadu:

Hi,

I am new to MQL4 but have been coding and playing with EA's for the last six weeks. I am trying to view a chart of the TICKS in the eur/usd as they appear and play with that data.

I am new enough to not know if there is an easy way to do that. I am stubborn enough to try and do it myself. I understand I can play with the raw data without a chart but would like to see if I can visualize it outside of a spreadsheet.

So far I have successfully collected hours of tick data and written it to a csv. I have also examined PeriodConverter and written a .hst in the history directory. My approach is to re-write the file every time a new tick appears and have an offline chart show that data, refreshing with each tick (or so--I realize that that may be overburdensome and slow--probably better to append).

When I open the file in an offline chart I see one of two results: If the currency pair name is the same as a live chart I get the live chart data and not the data out of the .hst file. If I change the name of the currency pair to something unrecognizable it shows "Waiting for Update". I've tried this with the ea off so it is not trying to write file while it is in use.

Don't use a standar period and standard symbol, for example, if you set EURUSD M1 and open the offline chart why d=wouldn't it simply open EURUSD M1 ? try using a period of 2 instead . . . M2 in effect, and add a suffix to the symbol name, for example EURUSDtic
 

First I want to say thank you--I've read alot of your replies in other threads that have helped me on other things.

I just added an "x" to the filename and an "x" to the name of the currency pair and with a period of 2--No problem finding the file to open offline but see waiting for update (just verified now).

 
Solved. I had changed the version number from what the period converter had not knowing that the actual number mattered. I saw in an updated period converter the same version so I realized it might be important. When I changed the Version to 400 it showed in the offline chart fine.
 
niqmadu:
Solved. I had changed the version number from what the period converter had not knowing that the actual number mattered. I saw in an updated period converter the same version so I realized it might be important. When I changed the Version to 400 it showed in the offline chart fine.
Cool, well done for finding your issue
Reason: