stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Need help for building a history file .
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3582
Page 2 of 3
Author:  milanese [ Sun Apr 27, 2014 11:19 am ]
Post subject:  Need help for building a history file .

this is at exp false:int version = 625 ; as the database version actual used is 401...

.hst file format valid as of Empty4 574 and later

The database header is the same . . . total 148 bytes

Code: Select all

int	version; 	// database version - 401	4 bytes
string	copyright[64];	// copyright info	64 bytes
string	symbol[12];	// symbol name	12 bytes
int	period; 	// symbol timeframe	4 bytes
int	digits;	// the amount of digits after decimal point	4 bytes
datetime	timesign; 	// timesign of the database creation	4 bytes
datetime	last_sync; 	// the last synchronization time	4 bytes
int	unused[13];	// to be used in future	52 bytes
then the bars array (single-byte justification) . . . total 60 bytes

Code: Select all

datetime	ctm;	// bar start time	8 bytes
double	open;	// open price	8 bytes
double	high;	// highest price	8 bytes
double	low;	// lowest price	8 bytes
double	close;	// close price	8 bytes
long	volume;	// tick count	8 bytes
int	spread;	// spread	4 bytes
long	real_volume;	// real volume	8 bytes
Cheers :)

Tommaso
Author:  juniorlcq93 [ Sun Apr 27, 2014 11:32 am ]
Post subject:  Need help for building a history file .

milanese » Sun Apr 27, 2014 7:11 pm wrote:
juniorlcq93 » Sun Apr 27, 2014 10:56 am wrote:
Yup I read that articles which RaptorUK posted too !!! After reading that bytes thingy , then I had the mind to change to INT_VALUE ; and also change my TimeOfBar to datetime type and TotalVolume to long type . But I'm not sure what does the spread and tick volume actually really mean ... the Period Converter that Empty4 admin posted uses Mql rates ... which is totally different from what I'm doing ! I stick to what I'm doing because I don't really understand what Empty4 means and on the top it says that old coding will also be working without needing to modify further .

May I humbly ask , how do you do that ???!?!! Can it be like what I want ??? I wrote a csv file before and it works because I can open up the file to read it . But how can it be open up as a Japanese candlestick pattern form in Empty4 as an custom offline chart ??

I'm sorry to keep bother you cause' I having been waiting for a guider to save my day
T____________________________________T
If you want update the data you should create arrays and the data from the arrays save as hst..., I would do this not with an EA but with an indicator but I don't know why you exactly want do that..

Cheers :)

Tommaso


And the data from the array save as history file ?? Can you explain to me further I don't catch you .




I also tried putting my code as an indicator and remove the OnCalculate() but the expert tabs shows that it keeps on removing itself without even initializing it .
Author:  milanese [ Sun Apr 27, 2014 11:52 am ]
Post subject:  Need help for building a history file .

juniorlcq93 » Sun Apr 27, 2014 11:32 am wrote:
And the data from the array save as history file ?? Can you explain to me further I don't catch you .

I also tried putting my code as an indicator and remove the OnCalculate() but the expert tabs shows that it keeps on removing itself without even initializing it .
I think I don't get what you exactly want to do with this all.., so far I do not not understand the sense to do what you want to do, so please explain again why do you need to create your own hst file

Cheers :)

Tommaso
Author:  juniorlcq93 [ Sun Apr 27, 2014 12:04 pm ]
Post subject:  Need help for building a history file .

Okay , firstly let me thank you for helping me this out .


What I want was creating a custom charts , exactly like how we normally open up a EURUSD chart .
This chart is exactly the same like how we read Japanese candlestick on EURUSD chart .

However it has it's own OHLCV . Example , open price will be the sum of 3 other currency's open ( open of EURUSD + GBPUSD + AUDUSD ) . Same applied to HLCV .

By doing this I have a basket of currencies , plot on ONE CHART ( like how we open up a EURUSD chart ) .





I'm not sure if I'm clear to you .
Do you get what I mean ???
Author:  juniorlcq93 [ Sun Apr 27, 2014 12:20 pm ]
Post subject:  Need help for building a history file .

milanese » Sun Apr 27, 2014 7:19 pm wrote:this is at exp false:int version = 625 ; as the database version actual used is 401...

.hst file format valid as of Empty4 574 and later

The database header is the same . . . total 148 bytes

Code: Select all

int	version; 	// database version - 401	4 bytes
string	copyright[64];	// copyright info	64 bytes
string	symbol[12];	// symbol name	12 bytes
int	period; 	// symbol timeframe	4 bytes
int	digits;	// the amount of digits after decimal point	4 bytes
datetime	timesign; 	// timesign of the database creation	4 bytes
datetime	last_sync; 	// the last synchronization time	4 bytes
int	unused[13];	// to be used in future	52 bytes
then the bars array (single-byte justification) . . . total 60 bytes

Code: Select all

datetime	ctm;	// bar start time	8 bytes
double	open;	// open price	8 bytes
double	high;	// highest price	8 bytes
double	low;	// lowest price	8 bytes
double	close;	// close price	8 bytes
long	volume;	// tick count	8 bytes
int	spread;	// spread	4 bytes
long	real_volume;	// real volume	8 bytes
Cheers :)

Tommaso


OMG !! I change version 625 to version 401 like what you suggested , and now the waiting for update display turns out to be A CHART !!!!!!!!!!

THANK YOU SIR !!!!!


Howver there's still some problem here :( . Each individual bar should be 1 Hour , but seems like all my Time , OHLCV are totally messed up . Also , the bars on the offline charts tab should be 1000 not 801 .



I'll show you the screen shot !!
Screen Shot 04-27-14 at 08.13 PM.PNG
Screen Shot 04-27-14 at 08.18 PM.PNG
Screen Shot 04-27-14 at 08.23 PM.PNG
Screen Shot 04-27-14 at 08.15 PM.PNG
Screen Shot 04-27-14 at 08.15 PM 001.PNG
Author:  milanese [ Sun Apr 27, 2014 12:34 pm ]
Post subject:  Need help for building a history file .

juniorlcq93 » Sun Apr 27, 2014 12:04 pm wrote:Okay , firstly let me thank you for helping me this out .


What I want was creating a custom charts , exactly like how we normally open up a EURUSD chart .
This chart is exactly the same like how we read Japanese candlestick on EURUSD chart .

However it has it's own OHLCV . Example , open price will be the sum of 3 other currency's open ( open of EURUSD + GBPUSD + AUDUSD ) . Same applied to HLCV .

By doing this I have a basket of currencies , plot on ONE CHART ( like how we open up a EURUSD chart ) .





I'm not sure if I'm clear to you .
Do you get what I mean ???
I got what you mean now.. , the new hst file format asks you for period converting to code in this style:

Code: Select all

if(time0>=rate.time+periodseconds || i==0)
  {
   if(i==0 && time0<rate.time+periodseconds)
     {
      rate.tick_volume+=(long)Volume[0];
      if(rate.low>Low[0])
         rate.low=Low[0];
      if(rate.high<High[0])
         rate.high=High[0];
      rate.close=Close[0];
     }
   last_fpos=FileTell(ExtHandle);
   last_volume=(long)Volume[i];
   FileWriteStruct(ExtHandle,rate);
   cnt++;
   if(time0>=rate.time+periodseconds)
     {
      rate.time=time0/periodseconds;
      rate.time*=periodseconds;
      rate.open=Open[i];
      rate.low=Low[i];
      rate.high=High[i];
      rate.close=Close[i];
      rate.tick_volume=last_volume;
     }
  }
Structure for storing information about prices, volumes and spread

Code: Select all

struct MqlRates
  {
   datetime time;    // period start time
   double open;      // Open price
   double high;      // High price for the period
   double low;       // Low price for the period
   double close;     // Close price
   long tick_volume; // tick volume
   int spread;       // spread
   long real_volume; // trade volume
  };
Cheers :)

Tommaso
Author:  juniorlcq93 [ Sun Apr 27, 2014 1:00 pm ]
Post subject:  Need help for building a history file .

Things are getting smoother , OMG thank you Tommaso , god bless .

Code: Select all

            FileWriteLong ( Data , TimeOfBar ) ;
            FileWriteDouble ( Data , TotalOpen , DOUBLE_VALUE ) ;
            FileWriteDouble ( Data , TotalHigh , DOUBLE_VALUE ) ;
            FileWriteDouble ( Data , TotalLow , DOUBLE_VALUE ) ;
            FileWriteDouble ( Data , TotalClose , DOUBLE_VALUE ) ;
            FileWriteLong ( Data , TotalVolume ) ;
            FileWriteInteger ( Data , Spread , INT_VALUE ) ;
            FileWriteLong ( Data , TotalVolume ) ;


I follow what you suggest by adding a Integer spread and one more Long for tick volume . However I set spread as 0 .

What does spread and tick volume actually means ?
Author:  milanese [ Sun Apr 27, 2014 1:05 pm ]
Post subject:  Need help for building a history file .

juniorlcq93 » Sun Apr 27, 2014 1:00 pm wrote:Things are getting smoother , OMG thank you Tommaso , god bless .

Code: Select all

            FileWriteLong ( Data , TimeOfBar ) ;
            FileWriteDouble ( Data , TotalOpen , DOUBLE_VALUE ) ;
            FileWriteDouble ( Data , TotalHigh , DOUBLE_VALUE ) ;
            FileWriteDouble ( Data , TotalLow , DOUBLE_VALUE ) ;
            FileWriteDouble ( Data , TotalClose , DOUBLE_VALUE ) ;
            FileWriteLong ( Data , TotalVolume ) ;
            FileWriteInteger ( Data , Spread , INT_VALUE ) ;
            FileWriteLong ( Data , TotalVolume ) ;


I follow what you suggest by adding a Integer spread and one more Long for tick volume . However I set spread as 0 .

What does spread and tick volume actually means ?
tick volume is the tick-count and spread actual difference from bid ask price..

Code: Select all

long	volume;	// tick count	8 bytes
int	spread;	// spread	4 bytes
Cheers :)

Tommaso
Author:  juniorlcq93 [ Sun Apr 27, 2014 1:12 pm ]
Post subject:  Need help for building a history file .

milanese » Sun Apr 27, 2014 9:05 pm wrote:
juniorlcq93 » Sun Apr 27, 2014 1:00 pm wrote:Things are getting smoother , OMG thank you Tommaso , god bless .

Code: Select all

            FileWriteLong ( Data , TimeOfBar ) ;
            FileWriteDouble ( Data , TotalOpen , DOUBLE_VALUE ) ;
            FileWriteDouble ( Data , TotalHigh , DOUBLE_VALUE ) ;
            FileWriteDouble ( Data , TotalLow , DOUBLE_VALUE ) ;
            FileWriteDouble ( Data , TotalClose , DOUBLE_VALUE ) ;
            FileWriteLong ( Data , TotalVolume ) ;
            FileWriteInteger ( Data , Spread , INT_VALUE ) ;
            FileWriteLong ( Data , TotalVolume ) ;


I follow what you suggest by adding a Integer spread and one more Long for tick volume . However I set spread as 0 .

What does spread and tick volume actually means ?
tick volume is the tick-count and spread actual difference from bid ask price..

Code: Select all

long	volume;	// tick count	8 bytes
int	spread;	// spread	4 bytes
Cheers :)

Tommaso

so can I say tick volume is actually my Total Volume ??
Spread = difference from bid and ask price ?? Means it is not 0 Integer then ??? I had to use MarketInfo to get bid and ask price minus ?
Author:  milanese [ Sun Apr 27, 2014 2:48 pm ]
Post subject:  Need help for building a history file .

juniorlcq93 » Sun Apr 27, 2014 1:12 pm wrote:
so can I say tick volume is actually my Total Volume ??
Spread = difference from bid and ask price ?? Means it is not 0 Integer then ??? I had to use MarketInfo to get bid and ask price minus ?
for spread you can use this:

Code: Select all

 spread=MarketInfo(Symbol(),MODE_SPREAD);
Cheers :)

Tommaso
All times are UTC Page 2 of 3