论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 8
前往
共 157 条
wfy05
注册时间2005-07-23
MT4自定义周期实时更新程序
楼主发表于:2005-12-02 00:02只看该作者
21楼 电梯直达
电梯直达
原帖由 韩儿 于 2005-12-1 23:31 发表 楼主,H4的图表数据很全,而制出H8的数据不全,则该如何制全H8的数据???
我这里没问题啊, H8的数据多少以及是否完全取决于H4, 差不多是H4的柱条数/2 你转化后看离线历史数据列表里面H4和H8的柱条数量以及时间数据看看.111.gif111.gif
个性签名

韬客社区www.talkfx.co

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
ob
注册时间2005-11-22
发表于:2005-12-02 07:53只看该作者
22楼
建议置顶,造幅大家 谢谢
上海环球油轮
注册时间2005-11-17
发表于:2005-12-02 08:20只看该作者
23楼
原帖由 wfy05 于 2005-12-2 08:02 发表 我这里没问题啊, H8的数据多少以及是否完全取决于H4, 差不多是H4的柱条数/2 你转化后看离线历史数据列表里面H4和H8的柱条数量以及时间数据看看.
谢谢回复
个性签名

解放思想

韩儿
注册时间2004-06-20
发表于:2005-12-02 13:10只看该作者
24楼
原帖由 wfy05 于 2005-12-2 08:02 发表 我这里没问题啊, H8的数据多少以及是否完全取决于H4, 差不多是H4的柱条数/2 你转化后看离线历史数据列表里面H4和H8的柱条数量以及时间数据看看.
谢谢
个性签名

韬客外汇论坛TALKFOREX.COM

广告
论坛谏言--外汇交易不应是你投资的全部,交易外汇也不应是你生活的全部
韩儿
注册时间2004-06-20
发表于:2005-12-02 13:11只看该作者
25楼
原帖由 wfy05 于 2005-12-2 08:02 发表 我这里没问题啊, H8的数据多少以及是否完全取决于H4, 差不多是H4的柱条数/2 你转化后看离线历史数据列表里面H4和H8的柱条数量以及时间数据看看.
谢谢
lhmm000029
注册时间2005-05-04
发表于:2005-12-04 05:37只看该作者
26楼
参数设定根据自己的需要,默认的是2,我想改为3,怎么改不了?
wfy05
注册时间2005-07-23
楼主发表于:2005-12-04 05:39只看该作者
27楼
原帖由 lhmm000029 于 2005-12-4 13:37 发表 参数设定根据自己的需要,默认的是2,我想改为3,怎么改不了?
你怎么改的? 操作不对吧
个性签名

韬客社区www.talkfx.co

广告
论坛谏言--外汇交易不应是你投资的全部,交易外汇也不应是你生活的全部
wfy05
注册时间2005-07-23
楼主发表于:2005-12-04 05:43只看该作者
28楼
更新到1.3版本,解决了当重新启动后新加载的数据过多时候可能出现的数据丢失情况, 并且现在支持源数据窗口中新增加了开头的历史数据时候的自动更新. 不过因为现在是周末服务器没有数据刷新没有进行完整测试, 请大家帮忙测试. //+------------------------------------------------------------------+ //| Period_Converter_Opt.mq4| //| Copyright ?2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //| Modified by wfy05@talkforex based on Period_Converter| //| http://www.talkfx.com | //+------------------------------------------------------------------+ #property copyright "[email protected]" #property link "http://www.talkfx.com" #property indicator_chart_window #property show_inputs #include /* Readme: I. Features: This is an improved version of period converter for MT4 based on the MT4's default period converter by metaquotes. The default period converter script do not support real-time refreshing, and consume lots of CPU (50%-9x%) making the whole system slow. Also, the default one is a script which do not save when you exit MT4, so you have to apply every converter script again after restarting, quite annoying. This one fixed all above problems: 1. Real-time updating or custom interval millisecond level updating. 2. Low CPU cost, average 5%-10% or less. 3. Works as an indicator, so can be saved and reloaded during restart. 4. There is no one converter per chart limitation as it is not script any more, you can only use one window as source to generate as many new timeframe chart as possible. 5. Auto updating if there is new history block loaded. II. How to use: Copy the mq4 file to your MT4 indicators folder (experts\indicators) to install it as an indicator, NOT script. then in the custom indicator list, attach period_converter_opt to the chart you want. It support 4 parameters: PeriodMultiplier: new period multiplier factor, default is 2 UpdateInterval: update interval in milliseconds, zero means update real-time. default is zero. Enabled: You can disable it without remove it with this option. Other parameters are comments or for debugging, it is safe to ignore them. Also Make sure you have Allow Dll imports option checked in common tab or it won't work After that, File->Open Offline to open the generated offline data. then the offline data will be updated automatically. As long as you keep the source chart open and the converter indicator running, the generated chart including indicators inside will always be updated. also you can close the generated chart and open again later from File->Open Offline without problem. If you want to quit MT4, you can leave those offline chart as other normal online charts. when you start MT4 next time, those charts will also be loaded and updated. III. Notes: 1. Do NOT uncheck the "offline chart" option in offline chart common properties. or after MT4 restart, it will treat that chart as online chart and request the data from server, resulting empty chart window. 2. You can attach more than one converter to same window with different PeriodMultiplier, e.g: you can attach 3 converter with PeriodMultiplier = 2, 4, 10 to M1 to generate M2, M4, M10 at the same time. It is even ok to use the M1 chart to generate Hourly chart like H2, which only cost a few more CPU resource during initial conversion. but usually most server don't have much data for those short period. resulting the generated data isn't long enough for long period. so it is suggested to use Hourly/Daily charts as source when needed. 3. The real-time updating mode updates quotes as fast as possible, but as this is done via script, and MT will skip calling start() function when your PC is busy and lots of quotes income. anyway, this seldom happen, and you can at least get 10 updates each seconds which is much more than enough. 4. The offline chart don't have a bid line showing in chart, but all data in the chart including the indicators is still being updated, so don't worry. you can show the bid line by unclick the "offline chart" option in chart properties. but which don't helps much and if you forget to check "offline chart" option before exit. it will cause errors and become empty on next startup. you have to close the window and open again from File->Open offline, which don't worth the trouble. IV. History: 2005.12.04 1.3 Fixed missing data when there is large amount of data loaded in several blocks, and support auto updating when new history is loaded. 2005.11.29 1.2 Additional fix for missing data and server changing. 2005.11.29 1.1 Fixed missing partial data after restart. Reinitialize after changing server or data corrupted. 2005.11.28 1.0 Initial release */ extern double Version = 1.3; // code version extern string BuildInfo = "2005.12.04 by [email protected]"; extern int PeriodMultiplier = 2; // new period multiplier factor extern int UpdateInterval = 0; // update interval in milliseconds, zero means update real-time. extern bool Enabled = true; extern bool Debug = false; int FileHandle = -1; int NewPeriod = 0; #define CHART_CMD_UPDATE_DATA 33324 void DebugMsg(string msg) { if (Debug) Alert(msg); } int init() { NewPeriod = Period() * PeriodMultiplier; if (OpenHistoryFile() < 0) return (-1); WriteHistoryHeader(); WriteHistoryFile(Bars-1, true); UpdateChartWindow(); return (0); } void deinit() { //Close file handle if(FileHandle >= 0) { FileClose(FileHandle); FileHandle = -1; } } int OpenHistoryFile() { FileHandle = FileOpenHistory(Symbol()+NewPeriod+".hst", FILE_BIN|FILE_WRITE); if(FileHandle < 0) return(-1); return (0); } int WriteHistoryHeader() { string c_copyright; int i_digits = Digits; int i_unused[13] = {0}; int version = 400; if (FileHandle < 0) return (-1); c_copyright = "(C)opyright 2003, MetaQuotes Software Corp."; FileWriteInteger(FileHandle, version, LONG_VALUE); FileWriteString(FileHandle, c_copyright, 64); FileWriteString(FileHandle, Symbol(), 12); FileWriteInteger(FileHandle, NewPeriod, LONG_VALUE); FileWriteInteger(FileHandle, i_digits, LONG_VALUE); FileWriteInteger(FileHandle, 0, LONG_VALUE); //timesign FileWriteInteger(FileHandle, 0, LONG_VALUE); //last_sync FileWriteArray(FileHandle, i_unused, 0, ArraySize(i_unused)); return (0); } int WriteHistoryFile(int start_pos, bool init = false) { static int last_fpos, i_time; static double d_open, d_low, d_high, d_close, d_volume; int i, ps; if (FileHandle < 0) return (-1); // normalize open time ps = NewPeriod * 60; i_time = Time[start_pos]/ps; i_time *= ps; if (init) { //first time, init data d_open = Open[start_pos]; d_low = Low[start_pos]; d_high = High[start_pos]; d_close = Close[start_pos]; d_volume = Volume[start_pos]; i = start_pos - 1; } else { i = start_pos; FileSeek(FileHandle,last_fpos,SEEK_SET); } if (i < 0) return (-1); int cnt = 0; int LastBarTime; //processing bars while (i >= 0) { LastBarTime = Time; //a new bar if (LastBarTime >= i_time+ps) { //write the bar data FileWriteInteger(FileHandle, i_time, LONG_VALUE); FileWriteDouble(FileHandle, d_open, DOUBLE_VALUE); FileWriteDouble(FileHandle, d_low, DOUBLE_VALUE); FileWriteDouble(FileHandle, d_high, DOUBLE_VALUE); FileWriteDouble(FileHandle, d_close, DOUBLE_VALUE); FileWriteDouble(FileHandle, d_volume, DOUBLE_VALUE); cnt++; i_time = LastBarTime/ps; i_time *= ps; d_open = Open; d_low = Low; d_high = High; d_close = Close; d_volume = Volume; } else { //no new bar d_volume += Volume; if (Lowd_high) d_high = High; d_close = Close; } i--; } //record last_fpos before writing last bar. last_fpos = FileTell(FileHandle); //write last bar's data FileWriteInteger(FileHandle, i_time, LONG_VALUE); FileWriteDouble(FileHandle, d_open, DOUBLE_VALUE); FileWriteDouble(FileHandle, d_low, DOUBLE_VALUE); FileWriteDouble(FileHandle, d_high, DOUBLE_VALUE); FileWriteDouble(FileHandle, d_close, DOUBLE_VALUE); FileWriteDouble(FileHandle, d_volume, DOUBLE_VALUE); cnt++; d_volume -= Volume[0]; //flush the data writen FileFlush(FileHandle); return (cnt); } int UpdateChartWindow() { static int hwnd = 0; if(hwnd == 0) { //trying to detect the chart window for updating hwnd = WindowHandle(Symbol(), NewPeriod); } if(hwnd!= 0) { if (IsDllsAllowed() == false) { //DLL calls must be allowed DebugMsg("Dll calls must be allowed"); return (-1); } if (PostMessageA(hwnd,WM_COMMAND,CHART_CMD_UPDATE_DATA,0) == 0) { //PostMessage failed, chart window closed hwnd = 0; } else { //PostMessage succeed return (0); } } //window not found or PostMessage failed return (-1); } /* int PerfCheck(bool Start) { static int StartTime = 0; static int Index = 0; if (Start) { StartTime = GetTickCount(); Index = 0; return (StartTime); } Index++; int diff = GetTickCount() - StartTime; Alert("Time used [" + Index + "]: " + diff); StartTime = GetTickCount(); return (diff); } */ static int LastStartTime = 0; static int LastEndTime = 0; static int LastBarCount = 0; int reinit() { deinit(); init(); LastStartTime = Time[Bars-1]; LastEndTime = Time[0]; LastBarCount = Bars; } bool IsDataChanged() { static int LastBars = 0, LastTime = 0, LastVolume = 0; static double LastOpen = 0, LastClose = 0, LastHigh = 0, LastLow = 0; if (LastVolume != Volume[0] || LastBars != Bars || LastTime != Time[0]|| LastClose != Close[0] || LastHigh != High[0] || LastLow != Low[0] || LastOpen != Open[0]) { LastBars = Bars; LastVolume = Volume[0]; LastTime = Time[0]; LastClose = Close[0]; LastHigh = High[0]; LastLow = Low[0]; LastOpen = Open[0]; return (true); } return (false); } int CheckNewData() { static string LastServer = ""; if (Bars < 2) { //the data is not loaded yet. DebugMsg("Data not loaded, only " + Bars + " Bars"); return (-1); } string serv = ServerAddress(); if (serv == "") { //no server yet DebugMsg("No server connected"); return (-1); } //server changed? check this and reinit to prevent wrong data while changing server. if (LastServer != serv) { DebugMsg("Server changed from " + LastServer + " to " + serv); LastServer = serv; reinit(); return (-1); } if (!IsDataChanged()) { //return if no data changed to save resource //DebugMsg("No data changed"); return (-1); } if (Time[Bars-1] != LastStartTime) { DebugMsg("Start time changed, new history loaded or server changed"); reinit(); return (-1); } int i, cnt; //try to find LastEndTime bar, which should be Time[0] or Time[1] usually, //so the operation is fast for (i = 0; i < Bars; i++) { if (Time <= LastEndTime) { break; } } if (i >= Bars || Time != LastEndTime) { DebugMsg("End time " + TimeToStr(LastEndTime) + " not found"); reinit(); return (-1); } cnt = Bars - i; if (cnt != LastBarCount) { DebugMsg("Data loaded, cnt is " + cnt + " LastBarCount is " + LastBarCount); reinit(); return (-1); } //no new data loaded, return with LastEndTime position. LastBarCount = Bars; LastEndTime = Time[0]; return (i); } //+------------------------------------------------------------------+ //| program start function | //+------------------------------------------------------------------+ int start() { static int last_time = 0; if (!Enabled) return (0); //always update or update only after certain interval if (UpdateInterval != 0) { int cur_time; cur_time = GetTickCount(); if (MathAbs(cur_time - last_time) < UpdateInterval) { return (0); } last_time = cur_time; } //if (Debug) PerfCheck(true); int n = CheckNewData(); //if (Debug) PerfCheck(false); if (n < 0) return (0); //update history file with new data WriteHistoryFile(n); //refresh chart window UpdateChartWindow(); //if (Debug) PerfCheck(false); return(0); }
lhmm000029
注册时间2005-05-04
发表于:2005-12-04 05:44只看该作者
29楼
参数设定根据自己的需要,默认的是2,我想改为3,一直改不动,怎么改不了?
lhmm000029
注册时间2005-05-04
发表于:2005-12-04 14:50只看该作者
31楼
今晚我比较3分钟和5分钟的K线,发现当某个时间既是3分钟收盘时间也是5分钟收盘时间时,这两个K线图表中显示同一收盘时间的收盘价位却是不同,而且相差较大,比如GPBUSD在2005.12.2 14:45(MT里的时间)3分钟图里显示收盘价为1.7313,在5分钟图里显示收盘价为1.7326,这是怎么回事?盼请高手解析
wfy05
注册时间2005-07-23
楼主发表于:2005-12-04 15:22只看该作者
32楼
原帖由 lhmm000029 于 2005-12-4 22:50 发表 今晚我比较3分钟和5分钟的K线,发现当某个时间既是3分钟收盘时间也是5分钟收盘时间时,这两个K线图表中显示同一收盘时间的收盘价位却是不同,而且相差较大,比如GPBUSD在2005.12.2 14:45(MT里的时间)3分钟图 ...
具体哪个服务器? 不同服务器数据有差别的而且时区也不一样. 另外你对比的时间也有问题, 2005.12.2 14:45(MT里的时间)3分钟图里显示收盘价为 14:47的, 5分钟图里收盘价为14:49的,应该是对比2005.12.2 14:42的3分钟收盘以及14:40的5分钟收盘价. [ 本帖最后由 wfy05 于 2005-12-4 23:27 编辑 ]
bsun
注册时间2005-04-13
发表于:2005-12-05 09:05只看该作者
33楼
原帖由 wfy05 于 2005-12-4 13:43 发表 更新到1.3版本,解决了当重新启动后新加载的数据过多时候可能出现的数据丢失情况, 并且现在支持源数据窗口中新增加了开头的历史数据时候的自动更新. 不过因为现在是周末服务器没有数据刷新没有进行完整测试, 请大 ...
谢谢wfy05兄,试用中,效果很好emoji-image:handshake
个性签名

韬客社区www.talkfx.co

lhmm000029
注册时间2005-05-04
ysj2008
注册时间2004-04-23
发表于:2005-12-06 05:55只看该作者
35楼
原帖由 fx007 于 2005-12-1 20:46 发表 十分欣赏楼主的专业知识和乐于助人的态度,谢谢
007的帖子说出了我的心里话。我虽然不会添加这个程序但我看到这麽多的人应用成功,使我深深感到wfy05的无私。谢谢! [ 本帖最后由 ysj2008 于 2005-12-6 13:59 编辑 ]
zhouzhouqu
注册时间2005-05-19
firesnake
注册时间2004-11-21
firesnake
注册时间2004-11-21
发表于:2005-12-09 07:17只看该作者
38楼
我的为什么实时更新不了?不知道问题出在哪里了?我已经下载了1.3版了
风帆
注册时间2005-11-08
发表于:2005-12-09 14:42只看该作者
39楼
1.3的更新速度好象比1.2的要慢很多.不知是什么原因.
蚂_蚁
注册时间2012-01-20
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 8
前往
共 157 条

本站免责声明:

1、本站所有广告及宣传信息均与韬客无关,如需投资请依法自行决定是否投资、斟酌资金安全及交易亏损风险;

2、韬客是独立的、仅为投资者提供交流的平台,网友发布信息不代表韬客的观点与意思表示,所有因网友发布的信息而造成的任何法律后果、风险与责任,均与韬客无关;

3、金融交易存在极高法律风险,未必适合所有投资者,请不要轻信任何高额投资收益的诱导而贸然投资;投资保证金交易导致的损失可能超过您投入的资金和预期。请您考虑自身的投资经验及风险承担能力,进行合法、理性投资;

4、所有投资者的交易帐户应仅限本人使用,不应交由第三方操作,对于任何接受第三方喊单、操盘、理财等操作的投资和交易,由此导致的任何风险、亏损及责任由投资者个人自行承担;

5、韬客不隶属于任何券商平台,亦不受任何第三方控制,韬客不邀约客户投资任何保证金交易,不接触亦不涉及投资者的任何资金及账户信息,不代理任何交易操盘行为,不向客户推荐任何券商平台,亦不存在其他任何推荐行为。投资者应自行选择券商平台,券商平台的任何行为均与韬客无关。投资者注册及使用韬客即表示其接受和认可上述声明,并自行承担法律风险。

版权所有:韬客外汇论坛 www.talkfx.com 联络我们:[email protected]