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 1 of 3
Author:  juniorlcq93 [ Fri Apr 25, 2014 4:30 am ]
Post subject:  Need help for building a history file .

May I humbly ask one tough question ( is tough for me ) ? Is about writing a history file ( like FILE_BIN, FILEFLUSH, FILETELL, FILESEEK ; I don't understand how these works ) .

Have you all ever heard of a EA that can create an offline chart with live data syncing into the offline chart, the offline chart you open will then be plotted exactly like how we open up an EURUSD online chart . I have trouble when writing the history file header and the body content of the history file . Not sure is it just me cause' I can't find explaination on how does the history file header format is written and what is the header like ( something like that ) .


The body content of the history file I wrote is also not showing when opening the offline chart . The 'From' and 'To' when opening the offline chart also shows opposite direction, From 2002 To 2990 . Would you all mind to help me out ?? I only use FileOpenHistory, FileWriteX, and FileClose . Do you mind to also explain to me how actually the history file format is ??



Can you guys help me to modify it to make it works ..? :| :|
Please T_______________T
Author:  juniorlcq93 [ Sun Apr 27, 2014 6:56 am ]
Post subject:  Need help for building a history file .

I see most people build a custom charts ( Own symbol, time frame, and others ) by using history file . Is it the part of my iTime is wrong ?? How do you write the Time of the charts correctly ? I use iTime to look for the historical bar ( meaning it return the value in seconds since 1970 ) . Then FileWriteLong comes in, but it's still not building up my own custom charts !


I put FileOpenHistory, FileWriteX and FileClose together as it SHOULD BE overwriting the old history file every time the timer run the function . Cause' this apply to my csv file .
Author:  milanese [ Sun Apr 27, 2014 9:49 am ]
Post subject:  Need help for building a history file .

You should code it simil this way..

Code: Select all

if (handle>0) {
                       FileWrite(handle,iTime(symbol,PERIOD_M1,0), iOpen(symbol,PERIOD_M1,0),
                       iHigh(symbol,PERIOD_M1,0), iLow(symbol,PERIOD_M1,0),
                       iClose(symbol,PERIOD_M1,0), iVolume(symbol,PERIOD_M1,0));
                              }
Cheers :)

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

But I thought FileWrite is used not for binary files , and history file is a binary file .... that's why it need to use FileWriteX ( Integer or Long or Double or String ) ...
Author:  milanese [ Sun Apr 27, 2014 10:12 am ]
Post subject:  Need help for building a history file .

juniorlcq93 » Sun Apr 27, 2014 10:03 am wrote:But I thought FileWrite is used not for binary files , and history file is a binary file .... that's why it need to use FileWriteX ( Integer or Long or Double or String ) ...
If you want an exp how to write hst files look here http://www.mql5.com/en/code/7936 the Period Converter contains code to write history files..

Cheers :)

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

I had also read the Period Converter script many times already . I had even download many Renko EA and almost all of them write a history file . I build the header file quite similar to to theirs except I use INT_VALUE ( Which should be the correct one I think ) .

Is the body content that troubles me cause' what I have in mind is different from theirs , but the way I wrote it looks okay , but it just doesn't pop out the custom chart as it suppose to be .

If I'm right the history file body content should be as shown below right ??
datetime time
double open
double high
double low
double close
long volume

I use long on volume cause' iVolume is a long type and not a double type . And beneath the FileWriteX I use FileWriteLong for TimeOfBar and TotalVolume . There's no FileWriteDateTime for TimeOfBar .

Not sure is it the start of the for loop or is it the FileWriteX .

Also since I wrote it as an EA and not a script, I don't think so I need to use the windows' function to update right ??? ( I tried putting into ( I said putting cause' I don't know about user32's function ) the code above also makes no difference )
Author:  milanese [ Sun Apr 27, 2014 10:52 am ]
Post subject:  Need help for building a history file .

juniorlcq93 » Sun Apr 27, 2014 10:40 am wrote:I had also read the Period Converter script many times already . I had even download many Renko EA and almost all of them write a history file . I build the header file quite similar to to theirs except I use INT_VALUE ( Which should be the correct one I think ) .

Is the body content that troubles me cause' what I have in mind is different from theirs , but the way I wrote it looks okay , but it just doesn't pop out the custom chart as it suppose to be .

If I'm right the history file body content should be as shown below right ??
datetime time
double open
double high
double low
double close
long volume

I use long on volume cause' iVolume is a long type and not a double type . And beneath the FileWriteX I use FileWriteLong for TimeOfBar and TotalVolume . There's no FileWriteDateTime for TimeOfBar .

Not sure is it the start of the for loop or is it the FileWriteX .

Also since I wrote it as an EA and not a script, I don't think so I need to use the windows' function to update right ??? ( I tried putting into ( I said putting cause' I don't know about user32's function ) the code above also makes no difference )
The hst format has changed since the new builds look here..http://forum.mql4.com/60455 that is why I would use csv format for building your own history file...

Cheers :)

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

I use 1000 on Historical Bars , it should actually gives me back 1000 bars when creating the custom charts however sometimes gives me a very random value . I tried to fix it ( I do this many times with IndicatorCounted() ) , and when I did that the From and To goes off ( From 2014 To 1970 , definately something is wrong lol ) .

1.PNG
2.PNG
3.PNG
Author:  juniorlcq93 [ Sun Apr 27, 2014 10:56 am ]
Post subject:  Need help for building a history file .

milanese » Sun Apr 27, 2014 6:52 pm wrote:
juniorlcq93 » Sun Apr 27, 2014 10:40 am wrote:I had also read the Period Converter script many times already . I had even download many Renko EA and almost all of them write a history file . I build the header file quite similar to to theirs except I use INT_VALUE ( Which should be the correct one I think ) .

Is the body content that troubles me cause' what I have in mind is different from theirs , but the way I wrote it looks okay , but it just doesn't pop out the custom chart as it suppose to be .

If I'm right the history file body content should be as shown below right ??
datetime time
double open
double high
double low
double close
long volume

I use long on volume cause' iVolume is a long type and not a double type . And beneath the FileWriteX I use FileWriteLong for TimeOfBar and TotalVolume . There's no FileWriteDateTime for TimeOfBar .

Not sure is it the start of the for loop or is it the FileWriteX .

Also since I wrote it as an EA and not a script, I don't think so I need to use the windows' function to update right ??? ( I tried putting into ( I said putting cause' I don't know about user32's function ) the code above also makes no difference )
The hst format has changed since the new builds look here..http://forum.mql4.com/60455 that is why I would use csv format for building your own history file...

Cheers :)

Tommaso
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
Author:  milanese [ Sun Apr 27, 2014 11:11 am ]
Post subject:  Need help for building a history file .

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
All times are UTC Page 1 of 3