//+------------------------------------------------------------------+ //| TestSymbolStochastic.mq4 | //| satori | //| http://www.metaquotes.ru/forum/7790/ | //+------------------------------------------------------------------+ #property copyright "satori" #property link "http://www.metaquotes.ru/forum/7790/" int handle; string filename="test_expert_log.csv"; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- handle= FileOpen(filename,FILE_CSV|FILE_WRITE,';'); if(handle<1) { Print("Файл не обнаружен, последняя ошибка ", GetLastError()); return(false); } //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- FileClose(handle); //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- double test1,test2,test3; int i; for (i=1;i<10;i++) { test1=iStochastic("GBPUSD",Period(),5,3,3,0,0,0,i); //test2=iStochastic("EURUSD",Period(),5,3,3,0,0,0,i); if (FileWrite (handle,TimeToStr(Time[i]),i,test1,test2)<=0) Print("Ошибка записи!"); } //---- return(0); } //+------------------------------------------------------------------+
对我来说是有效的(但我没有检查整个文件)。
当然,问题不在于关闭文件,因为正如我之前所说,我在终端和从专家顾问中调用指标时面临不同的值。然后我把输出结果画到一个文件里,研究这个 "现象"。
事实上,它在我的另一台电脑上也都能工作。然而,在此期间,它并没有发挥作用。
我发现再增加一个货币对就足够了...
test1=iStochastic("GBPUSD",Period(),5,3,3,0,0,i); test2=iStochastic("EURGBP",Period(),5,3,3,0,0,i)。
情况如何反复
2006.10.22 22:00;1;74.83660131;19.04761905
2006.10.20 20:00;2;76.79738562;13.91304348
2006.10.20 16:00;3;78.13504823;25.26315789
2006.10.20 12:00;4;78.65853659;48.7804878
2006.10.20 08:00;5;80.50139276;81.57894737
2006.10.20 04:00;6;80.25974026;79.74683544
2006.10.20 00:00;7;86.36363636;74.66666667
2006.10.19 20:00;8;86.96969697;76.54320988
2006.10.19 16:00;9;80;79.22077922
2006.10.23 00:00;1;65.15151515;29.78723404
2006.10.22 22:00;2;74.83660131;19.67213115
2006.10.20 20:00;3;76.79738562;19.04761905
2006.10.20 16:00;4;78.13504823;13.91304348
2006.10.20 12:00;5;78.65853659;25.26315789
2006.10.20 08:00;6;80.50139276;48.7804878
2006.10.20 04:00;7;80.25974026;81.57894737
可以看出,在给定条件下的第一对(!)工作正常,然而第二...
让我感到奇怪的是,这个问题并不系统。在看似相似的条件下,同样的代码会得到不同的结果。终端是198个地方。在两个不同的经纪商上测试。其中之一是MIG。
也许尊敬的开发者先生们会告诉我如何对抗这个讨厌的东西?
如果我们做以下抽样调查。
string time1,time2,time3; for (i=1;i<10;i++) { time1=TimeToStr(iTime("GBPUSD",Period(),i)); time2=TimeToStr(iTime("EURGBP",Period(),i)) 。 time3=TimeToStr(iTime("EURUSD",Period(),i)); if (FileWrite (handle,TimeToStr(Time[i]),i,time1,time2,time3)<=0) Print("写入错误!"); }
我得到的信息如下。
2006.10.22 22:00;1;2006.10.22 22:00;2006.10.20 20:00;2006.10.22 22:00
2006.10.20 20:00;2;2006.10.20 20:00;2006.10.20 16:00;2006.10.20 20:00
2006.10.20 16:00;3;2006.10.20 16:00;2006.10.20 12:00;2006.10.20 16:00
2006.10.20 12:00;4;2006.10.20 12:00;2006.10.20 08:00;2006.10.20 12:00
2006.10.20 08:00;5;2006.10.20 08:00;2006.10.20 04:00;2006.10.20 08:00
2006.10.20 04:00;6;2006.10.20 04:00;2006.10.20 00:00;2006.10.20 04:00
2006.10.20 00:00;7;2006.10.20 00:00;2006.10.19 20:00;2006.10.20 00:00
2006.10.19 20:00;8;2006.10.19 20:00;2006.10.19 16:00;2006.10.19 20:00
2006.10.19 16:00;9;2006.10.19 16:00;2006.10.19 12:00;2006.10.19 16:00
2006.10.23 00:00;1;2006.10.23 00:00;2006.10.23 00:00;2006.10.23 00:00
2006.10.22 22:00;2;2006.10.22 22:00;2006.10.22 22:00;2006.10.22 22:00
2006.10.20 20:00;3;2006.10.20 20:00;2006.10.20 20:00;2006.10.20 20:00
从这里开始,它是正常的。
有时崩溃发生在一种货币上,有时发生在两种货币上。我们一直没能搞清楚这个系统。它要么取决于计算机的功率(尽管我在一个相当快的计算机上运行),要么取决于其他东西。
但事实是,测试是不可能的。在第一次访问时,MT给出了不正确的数据。
问题仍然是:这是一个错误还是一个特点。:о)如果它是一个错误,我如何才能打击它?也许有人遇到过这样的问题?
第一次打印显示,指数为1的柱子变成了指数为3的柱子,指数为2的柱子变成了指数为4的柱子,此外,似乎你在H4上启动了专家顾问,而22:00的时间并没有告诉你任何事情。
我可能想再读一下关于测试器中的模拟的文章,它可能会点出所有的 "i "s。
好运,别忘了在这里报告结果;)
P.S. 另外,你可以尝试另一个版本的模拟,看看结果,那里已经可以得出一些结论。
而且这种情况也在其他TFs(1H,30M,15M等)上观察到,不同的价格模拟变体(所有三个)仍然导致上述错误。
而22点的四点钟酒吧也没有什么超自然的东西--一个普通的 "周日 "酒吧。它确实在22:00开放。并非所有的经纪商都会剪掉这个故事,例如Alpari。;о)
然而,问题更趋于本地化。事实证明,这个EA在所有经纪商那里都不会产生错误。就是在那些有 "周日 "数据的经纪公司。具体来说,Alpari工作正常,但FIBO和MIG有错误。而且,只有当我们看 "周日 "条形图时,才会出现错误。
我不认为这是个 "特点"。它看起来更像是一个错误。至少因为这些错误不会发生在同一对上。它可能在某一时刻发生在一对上,在另一时刻发生在另一对上,而在第三时刻发生在两对上。
我仍然希望能引起开发者对这个问题的注意,并从他们那里得到答案:这个问题是什么,如何解决它;o) (不要告诉我:"与Alpari合作":o))。
P.S. 无论如何,感谢Profi_R的参与,但正如你所看到的,简单的解决方案并没有帮助,也许我将不得不深入研究。:о)
#property copyright "Copyright Quark" #property link "" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color2 Red #property indicator_minimum -1 #property indicator_maximum 1 // indicator parameters extern int nPeriod = 9; extern int nPeriod_1 = 6; // indicator buffers double dUsdChf, dUsdChfPrev; double arrGroupBuffer[]; double arrGroupMaBuffer[]; int nExtCountedBars = 0; //////////////////////// int init() { string strIndicatorShortName = "Group(" + Symbol() + " " + nPeriod + ")"; IndicatorShortName(strIndicatorShortName); // drawing settings SetIndexStyle(0, DRAW_NONE); SetIndexShift(0, 0); SetIndexStyle(1, DRAW_LINE); SetIndexShift(1, 0); IndicatorDigits(4); // indicator buffers mapping SetIndexBuffer(0, arrGroupBuffer); SetIndexBuffer(1, arrGroupMaBuffer); return(0); } /////////////////////////// int start() { if(Bars <= nPeriod) return(0); nExtCountedBars = IndicatorCounted(); if(nExtCountedBars < 0) return(-1); // last counted bar will be recounted // if(nExtCountedBars > 0) // nExtCountedBars--; int nPos = Bars - nExtCountedBars - 1; double dPr = 2.0 / (nPeriod + 1); while(nPos > 0) { if(!IsTesting()) { dUsdChf = iMA("USDCHF", 0, nPeriod, 0, MODE_EMA, PRICE_OPEN, nPos - 1); dUsdChfPrev = iMA("USDCHF", 0, nPeriod, 0, MODE_EMA, PRICE_OPEN, nPos); } arrGroupBuffer[nPos - 1] = 0; if(dUsdChfPrev - dUsdChf > 0) arrGroupBuffer[nPos - 1] += 1; else if(dUsdChfPrev - dUsdChf < 0) arrGroupBuffer[nPos - 1] -= 1; if(nPeriod_1 == 1) arrGroupMaBuffer[nPos - 1] = arrGroupBuffer[nPos - 1]; else { dPr = 2.0 / (nPeriod_1 + 1); arrGroupMaBuffer[nPos - 1] = arrGroupBuffer[nPos - 1] * dPr + arrGroupMaBuffer[nPos] * (1 - dPr); } nPos--; } return(0); }
它没有什么实际用途,因为它不适合历史测试(如果两个历史的条形图不同步,第二种货币就会产生奇妙的利润,我以前写过这个问题)。但这不是问题的关键。
正如你从代码中看到的那样,该指标并不依赖于它所连接到图表中的货币。这对美元兑瑞郎始终有效。我们将指标附在 两个图表上,在我的例子中是澳元兑美元和欧元兑美元,但我想我们可以将其附在任何图表上。我们把它放在几天后。我们看到,这些图表是不同的。同样的指标。实时的。同是MT。强行重绘(解缆--解缆)--它们变得相同。一段时间以来。
我现在正在追踪,如果我发现什么,我会告诉你。当然,这可能是因为我的原因 :)
该代码(见下文)从USDCHF、H1中获取(无论该指标连接到哪个窗口)数据,并绘制出a)开盘、MA(开盘,6)和MA(开盘,6,手动计算,不调用标准指标)的图表。
该指标已被附在欧元兑美元H1 和澳元兑美元H1上。经过12个小时的工作,在图表上可以看到差异(注意,数据取自USDCHF,不应该有任何差异)。此外,差异不在MA上,而恰恰在Open线上(当然,在MA上也有,但这是次要的,因为Open)。
所以有一个与使用另一种货币的数据有关的错误。亲爱的开发者?
#property copyright "Copyright Quark" #property link "" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Lime #property indicator_color2 Aqua #property indicator_color3 Red // indicator parameters extern int nPeriod = 6; double arrOpen[]; double arrMa[]; double arrMyMa[]; int nExtCountedBars = 0; double dUsdChf, dUsdChfPrev; //////////////////////// int init() { string strIndicatorShortName = "Test(" + Symbol() + " " + nPeriod + ")"; IndicatorShortName(strIndicatorShortName); // drawing settings SetIndexStyle(0, DRAW_LINE); SetIndexShift(0, 0); SetIndexStyle(1, DRAW_LINE); SetIndexShift(1, 0); SetIndexStyle(2, DRAW_LINE); SetIndexShift(2, 0); IndicatorDigits(4); // indicator buffers mapping SetIndexBuffer(0, arrOpen); SetIndexBuffer(1, arrMa); SetIndexBuffer(2, arrMyMa); return(0); } /////////////////////////// int start() { if(Bars <= nPeriod) return(0); nExtCountedBars = IndicatorCounted(); if(nExtCountedBars < 0) return(-1); int nPos = Bars - nExtCountedBars - 1; double dPr = 2.0 / (nPeriod + 1); while(nPos > 0) { dUsdChf = iMA("USDCHF", 0, nPeriod, 0, MODE_EMA, PRICE_OPEN, nPos - 1); dUsdChfPrev = iMA("USDCHF", 0, nPeriod, 0, MODE_EMA, PRICE_OPEN, nPos); arrOpen[nPos - 1] = iOpen("USDCHF", 0, nPos - 1); arrMa[nPos - 1] = dUsdChf; arrMyMa[nPos - 1] = arrOpen[nPos - 1] * dPr + arrMyMa[nPos] * (1 - dPr); nPos--; } return(0); }
首先,故事越大,错误就越大。
其次,这里是代码(马上为代码的笨拙道歉)。
#property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 Blue #property indicator_color3 Yellow //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; extern int BarsCount=20; //кол-во считаемых баров, если 0 - то все extern string Currency1="EURUSD"; extern string Currency2="GBPUSD"; string Para; int TF; int handle,handle2; int init() { SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexLabel(0,Currency1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexLabel(1,Currency2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); string Para=Symbol(); int TF=Period(); handle= FileOpen("testfile.csv",FILE_CSV|FILE_WRITE,';'); handle2= FileOpen("testfile2.csv",FILE_CSV|FILE_WRITE,';'); if(handle<1 || handle2<1 ) { Print("Файл не обнаружен, последняя ошибка ", GetLastError()); return(false); } return(0); } int deinit() { FileClose(handle); return(0); } int start() { int counted_bars=IndicatorCounted(); int i; double test1,test2; datetime tt1,tt2; BarsCount=MathMin(Bars,(MathMin(iBars(Currency1,Period()),iBars(Currency2,Period())))); for (i=0;i<BarsCount-counted_bars;i++) { ExtMapBuffer1[i]=iTime(Currency1,Period(),i); Sleep(1000); ExtMapBuffer2[i]=iTime(Currency2,Period(),i); ExtMapBuffer3[i]=(ExtMapBuffer1[i]-ExtMapBuffer2[i]); tt1=Time[i]-ExtMapBuffer1[i]; tt2=Time[i]-ExtMapBuffer2[i]; if (ExtMapBuffer3[i]!=0 || tt1!=0 || tt2!=0) { if (FileWrite (handle, i,TimeToStr(Time[i]),TimeToStr(ExtMapBuffer1[i]),TimeToStr(ExtMapBuffer2[i]) )<=0) Print("нифига не пишет!!"); } FileFlush(handle); if ((iTime(Symbol(),Period(),i)!=iTime(Currency1,Period(),i) || Time[i]!=iTime(Currency1,Period(),i) || iTime(Currency1,Period(),i)!=iTime(Currency2,Period(),i) ) && i>0) { if (FileWrite (handle2, TimeToStr(Time[i])," ",TimeToStr(iTime(Currency1,Period(),i))," ",TimeToStr(iTime(Currency2,Period(),i)) )<=0) Print("нифига не пишет!!"); } } return(0); }
在欧元兑美元和英镑兑美元货币对上,对欧元兑英镑在4H上的运行给出了超过2000个错误。
在15M - 超过26500。
而在15M上,转变不是一个小节,而是很多很多(超过100(!)小节)。
这里有一段日志。
15.06.2006 1:45 16.06.2006 0:45 16.06.2006 0:00
15.06.2006 1:30 16.06.2006 0:30 15.06.2006 23:45
15.06.2006 1:15 16.06.2006 0:15 15.06.2006 23:30
15.06.2006 1:00 16.06.2006 0:00 15.06.2006 23:15
15.06.2006 0:45 15.06.2006 23:45 15.06.2006 23:00
15.06.2006 0:30 15.06.2006 23:30 15.06.2006 22:45
15.06.2006 0:15 15.06.2006 23:15 15.06.2006 22:30
15.06.2006 0:00 15.06.2006 23:00 15.06.2006 22:15
14.06.2006 23:45 15.06.2006 22:45 15.06.2006 22:00
14.06.2006 23:30 15.06.2006 22:30 15.06.2006 21:45
14.06.2006 23:15 15.06.2006 22:15 15.06.2006 21:30
14.06.2006 23:00 15.06.2006 22:00 15.06.2006 21:15
14.06.2006 22:45 15.06.2006 21:45 15.06.2006 21:00
14.06.2006 22:30 15.06.2006 21:30 15.06.2006 20:45
这条日志来自Alpari服务器,有新的终端和新的历史(在3.10.2005之前,所有三种货币对的15M)。
所有这些调查的重点是要从开发者那里得到对这种现象的可理解的解释。
而让我困惑的是,亲爱的先生们,我已经有一个星期没有听到你们的消息了。
我不知道如何向你证明问题的严重性,以便你注意到它。
情况和代码的透明简单性使我无法考虑到一个微不足道的错误。所以我 在此请设计师们 务必要保证。
亲爱的先生们!我恳请你关注这个话题,至少给出一些你的意见。如果是我的错误,请不要认为是我的错--至少告诉我去哪里找。在这种情况下,我将为之道歉。如果是MT4的错误 - 那么我认为你应该尊重人们的时间(不仅仅是我,我的意思是),他们花费了宝贵的资源来发现并提请你注意这种情况,这实际上不是他们的直接任务。
带着尊重和希望进行建设性的对话......。:о)
差不多二十年前,我坐在宿舍里,用勺子把茶搅拌成一圈,我发现通过漏斗的图像变得扭曲了。我立即忘记了这个简单的解释,把它看作是证实了在一个圆圈中运动的水团会引起局部的引力变化(这也解释了百慕大三角周围船只的消失),从而导致波(光)的折射。这个日蚀持续了几分钟,我才意识到这是一个从水的漩涡中获得的平庸的镜头 :)
我对你的代码做了些许修改。
//+------------------------------------------------------------------+ //| RedrawIndicators.mq4 | //| Satori | //| http://www.metaquotes.ru/forum/7790/ | //+------------------------------------------------------------------+ #property copyright "Satori" #property link "http://www.metaquotes.ru/forum/7790/" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 Blue #property indicator_color3 Yellow //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; extern int BarsCount=20; //кол-во считаемых баров, если 0 - то все extern string Currency1="EURUSD"; extern string Currency2="GBPUSD"; int handle,handle2; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexLabel(0,Currency1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexLabel(1,Currency2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); handle= FileOpen("TestFile.csv",FILE_CSV|FILE_WRITE,';'); handle2= FileOpen("TestFile2.csv",FILE_CSV|FILE_WRITE,';'); if(handle<1 || handle2<1 ) { Print("Файл не обнаружен, последняя ошибка ", GetLastError()); return(false); } else { FileWrite (handle,"index",Symbol(),Currency1,Currency2); FileWrite (handle2,"index",Symbol()," ",Currency1," ",Currency2); } return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- FileClose(handle); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int i; double test1,test2; datetime tt1,tt2,TimeMain; BarsCount=MathMin(Bars,(MathMin(iBars(Currency1,Period()),iBars(Currency2,Period())))); for (i=0;i<BarsCount-counted_bars;i++) { TimeMain=Time[i]; ExtMapBuffer1[i]=iTime(Currency1,Period(),iBarShift(Currency1,Period(),TimeMain)); //Sleep(1000); ExtMapBuffer2[i]=iTime(Currency2,Period(),iBarShift(Currency2,Period(),TimeMain)); ExtMapBuffer3[i]=(ExtMapBuffer1[i]-ExtMapBuffer2[i]); tt1=Time[i]-ExtMapBuffer1[i]; tt2=Time[i]-ExtMapBuffer2[i]; if (ExtMapBuffer3[i]!=0 || tt1!=0 || tt2!=0) { if (FileWrite (handle, i,TimeToStr(Time[i]),TimeToStr(ExtMapBuffer1[i]),TimeToStr(ExtMapBuffer2[i]) )<=0) Print("нифига не пишет!!"); } FileFlush(handle); if ((iTime(Symbol(),Period(),i)!=iTime(Currency1,Period(),i) || Time[i]!=iTime(Currency1,Period(),i) || iTime(Currency1,Period(),i)!=iTime(Currency2,Period(),i) ) && i>0) { if (FileWrite (handle2,i, TimeToStr(Time[i])," ",TimeToStr(iTime(Currency1,Period(),i))," ",TimeToStr(iTime(Currency2,Period(),i)) )<=0) Print("нифига не пишет!!"); } }//---- return(0); } //+------------------------------------------------------------------+
所以问题听起来真的是这样的--为什么它们不一样,为什么历史上有漏洞?我在GBPJPY H4上运行这个指标,并打开了两个结果文件。
你马上就能看到计时在两个地方被打破了,第二个文件显示了一堆 "错误"
PS 阿尔帕里的报价。
请就以下问题提供建议。
下面是专家顾问的代码。
专家顾问在欧元兑美元 上运行,对已形成的条形进行快速模拟。它从另一个货币对中读取随机指标读数,最终生成一份形式的报告。
2006.10.22 22:00;1;76.79738562
2006.10.20 20:00;2;78.13504823
2006.10.20 16:00;3;78.65853659
2006.10.20 12:00;4;80.50139276
2006.10.20 08:00;5;80.25974026
2006.10.20 04:00;6;86.36363636
2006.10.20 00:00;7;86.96969697
2006.10.19 20:00;8;80
2006.10.19 16:00;9;53.76884422
2006.10.23 00:00;1;65.15151515
2006.10.22 22:00;2;74.83660131
2006.10.20 20:00;3;76.79738562和78.13504823(见上文)
2006.10.20 16:00;4;78.13504823和78.65853659(见上文);等等。
2006.10.20 12:00;5;78.65853659
2006.10.20 08:00;6;80.50139276
2006.10.20 04:00;7;80.25974026
2006.10.20 00:00;8;86.36363636
2006.10.19 20:00;9;86.96969697
2006.10.23 04:00;1;52.85714286
2006.10.23 00:00;2;65.15151515
2006.10.22 22:00;3;74.83660131
2006.10.20 20:00;4;76.79738562
2006.10.20 16:00;5;78.13504823
2006.10.20 12:00;6;78.65853659
2006.10.20 08:00;7;80.50139276
2006.10.20 04:00;8;80.25974026
2006.10.20 00:00;9;86.36363636
2006.10.23 08:00;1;21.83406114
2006.10.23 04:00;2;52.85714286
2006.10.23 00:00;3;65.15151515
2006.10.22 22:00;4;74.83660131
2006.10.20 20:00;5;76.79738562
2006.10.20 16:00;6;78.13504823
2006.10.20 12:00;7;78.65853659
2006.10.20 08:00;8;80.50139276
2006.10.20 04:00;9;80.25974026
很容易看出,在新的运行中,同一棒的指标值是不同的。
我明白,这个EA的实际用途是值得怀疑的:o),但目的是为了显示这个问题。实际情况是这样的:在终端中,该指标显示正确,但当我从专家顾问中调用它时,却显示错误的数据。在剔除了所有不影响指标的东西后,我们得到了以下结果。我一定是笨得很,但找不到我的错误。
顺便说一下,如果我把货币对改为当前的货币对,一切都很好。
我非常感谢您的提前帮助。