Modify historical data using historical files - page 2 123 New comment qjol 2014.04.10 13:22 #11 writeOfflineBar("USDMXN", PERIOD_D1, 1, "00:00", 1.37356, 1.37385, 1.37335, 1.37379, 1000); its declared as an int not a string (but actually its supposed to be a datetime) int position = bars_back * OFFLINE_RECORD_SIZE; change to int position = (bars_back * OFFLINE_RECORD_SIZE) + OFFLINE_RECORD_SIZE; what exactly is it ? a indicator script or EA ? [Deleted] 2014.04.10 14:33 #12 I updated my code but the appropriate historical file becomes empty. This should be an EA. This is the current code based on your input above: #include <WinUser32.mqh> #define OFFLINE_HEADER_SIZE 148 // LONG_VALUE + 64 + 12 + 4 * LONG_VALUE + 13 * LONG_VALUE #define OFFLINE_RECORD_SIZE 44 // 5 * DOUBLE_VALUE + LONG_VALUE int __chart_file = 0; // the cache for the file handle (only used in backtesting mode) int OnInit() { datetime dt = "2013.12.26 00:00"; writeOfflineBar("USDMXN", PERIOD_D1, 1, dt, 86.72, 87.78, 86.7, 87.78, 1000); WindowRedraw(); ChartRedraw(); return(INIT_SUCCEEDED); } void writeOfflineBar(string symbol, int period, int bars_back, datetime time, double open, double high, double low, double close, double volume){ int F = fileOpenEx(symbol + period + ".hst", FILE_BIN|FILE_WRITE|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_ANSI); //int position = bars_back * OFFLINE_RECORD_SIZE; int position = (bars_back * OFFLINE_RECORD_SIZE) + OFFLINE_RECORD_SIZE; FileSeek(F, -position, SEEK_END); if (FileTell(F) >= OFFLINE_HEADER_SIZE){ FileWriteInteger(F, time, LONG_VALUE); FileWriteDouble(F, open, DOUBLE_VALUE); FileWriteDouble(F, low, DOUBLE_VALUE); FileWriteDouble(F, high, DOUBLE_VALUE); FileWriteDouble(F, close, DOUBLE_VALUE); FileWriteDouble(F, volume, DOUBLE_VALUE); // refresh the chart window // this won't work in backtesting mode if (!IsTesting()){ int hwnd=WindowHandle(symbol, period); if (hwnd != 0){ PostMessageA(hwnd, WM_COMMAND, 33324, 0); } } } //FileFlush(F); FileClose(F); } int fileOpenEx(string name, int mode){ if (IsTesting()){ if (__chart_file == 0){ __chart_file = FileOpenHistory(name, mode); } return(__chart_file); }else{ return(FileOpenHistory(name, mode)); } } qjol 2014.04.10 14:38 #13 PostMessageA(hwnd, WM_COMMAND, 33324, 0); change to PostMessageW(hwnd, WM_COMMAND, 33324, 0); [Deleted] 2014.04.11 08:22 #14 No change to the result :-( and the file size go to 0kb. qjol 2014.04.11 08:30 #15 then can you explain to me how this script works just fine for me (i used it on USDCHF) #include <WinUser32.mqh> #import "user32.dll" int RegisterWindowMessageW(string lpString); #import #define OFFLINE_HEADER_SIZE 148 // LONG_VALUE + 64 + 12 + 4 * LONG_VALUE + 13 * LONG_VALUE #define OFFLINE_RECORD_SIZE 44 // 5 * DOUBLE_VALUE + LONG_VALUE int __chart_file = 0; // the cache for the file handle (only used in backtesting mode) void OnStart() { datetime Tm = Time[1]; writeOfflineBar(Symbol(), Period(), 1, Tm, 0.87356, 0.85385, 0.88335, 0.87379, 1000); WindowRedraw(); ChartRedraw(); return;//(INIT_SUCCEEDED); } void writeOfflineBar(string symbol, int period, int bars_back, datetime time, double open, double high, double low, double close, double volume){ int F = fileOpenEx(StringSubstr(symbol, 0, 12) + period + ".hst", FILE_BIN | FILE_READ | FILE_WRITE | 128 | 256); int position = (bars_back * OFFLINE_RECORD_SIZE) + OFFLINE_RECORD_SIZE; FileSeek(F, -position, SEEK_END); if (FileTell(F) >= OFFLINE_HEADER_SIZE){ FileWriteInteger(F, time, LONG_VALUE); FileWriteDouble(F, open, DOUBLE_VALUE); FileWriteDouble(F, low, DOUBLE_VALUE); FileWriteDouble(F, high, DOUBLE_VALUE); FileWriteDouble(F, close, DOUBLE_VALUE); FileWriteDouble(F, volume, DOUBLE_VALUE); FileFlush(F); int hwnd=WindowHandle(symbol, period); PostMessageW(hwnd, WM_COMMAND, 33324, 0); } FileClose(F); } int fileOpenEx(string name, int mode){ if (IsTesting()){ if (__chart_file == 0){ __chart_file = FileOpenHistory(name, mode); } return(__chart_file); }else{ return(FileOpenHistory(name, mode)); } } [Deleted] 2014.04.12 12:24 #16 I tried the same way but still doesn't work. No change for the bar. To demonstrate what I did I created a screen video: > qjol 2014.04.13 01:05 #17 i used B625 [Deleted] 2014.04.13 09:39 #18 I've just tried on a fresh installed B625 version but no change. Here is the video to show it: > [Deleted] 2014.04.14 11:31 #19 @qjol: Have you done it the same way as in the last video (on Build 625) ? Ex Ovo Omnia 2014.04.14 11:57 #20 I am afraid that refresh event applied to an online chart forces data synchronization with the server. 123 New comment
its declared as an int not a string (but actually its supposed to be a datetime)
int position = bars_back * OFFLINE_RECORD_SIZE;change to
int position = (bars_back * OFFLINE_RECORD_SIZE) + OFFLINE_RECORD_SIZE;what exactly is it ? a indicator script or EA ?
I updated my code but the appropriate historical file becomes empty.
This should be an EA.
This is the current code based on your input above:
change to
No change to the result :-( and the file size go to 0kb.
then can you explain to me how this script works just fine for me (i used it on USDCHF)
I tried the same way but still doesn't work. No change for the bar. To demonstrate what I did I created a screen video:
>I've just tried on a fresh installed B625 version but no change. Here is the video to show it:
>@qjol: Have you done it the same way as in the last video (on Build 625) ?