类似于iBarShift - 页 15 1...891011121314151617 新评论 Nikolai Semko 2018.04.10 11:17 #141 Alexey Kozitsyn: 顺便说一下,关于Bars()函数。这可能是导致成交的原因。 这很容易检查。将所有Bars改为我的iBars。如果楔子消失了,那么问题就出在这个功能上。我也搞不清楚我的一些指标冻结的原因。原来是这个特殊的错误,现在一切都在飞。 Nikolai Semko 2018.04.10 13:41 #142 fxsaber:除了感兴趣的那个人之外,所有的角色都可以去做Cotypes。 好了,看了看新的源代码。看到讨论过的编辑还没有做。退出。只有当要求的符号不在市场观察窗口中时,使用SYMBOL_TIME才有意义。那么TimeCurrent 就不能完成它的工作。但在我看来,这种使用Bars的变体似乎不太可能。但通过SYMBOL_TIME获取当前时间的代价要高得多,因为SymbolInfoInteger(symbol_name,SYMBOL_TIME)几乎要花费一个数量级的时间。当然,你可以检查符号是否在市场报告中,并根据结果使用TimeCurrent 或SYMBOL_TIME,但这不是免费的,特别是你必须不断检查是否有新的符号被添加或从市场报告中删除。因此,为了iBars的正确工作,在市场报告中拥有所要求的符号是合理的,这样的条款比较容易。 关于SERIES_LASTBAR_DATE,我认为你错了。SymbolInfoInteger(symbol_name,SYMBOL_TIME)是一个较小的邪恶。 SeriesInfoInteger函数不会引起任何历史分页。如果有什么原因的话,那就是对Bars的要求,这也是符合逻辑的。而刹车的来源可以在这个简短的脚本中看到,如果你运行它的话 void OnStart() { Print("1"); Print(Bars(_Symbol,PERIOD_W1,D'2020.01.01 00:00',UINT_MAX)); Print("2"); } Nikolai Semko 2018.04.10 14:50 #143 一般来说,这是一个非常奇怪的错误。我检查了下载历史对它的影响,当我发现今天突然在欧元兑美元的符号 上它几乎没有显示出来。 迫使我下载所有的历史资料。而这个错误又出现了。 我想下载历史对这个错误没有影响。 我不明白为什么这个错误会四处流传。 用这个脚本来测试。 附加的文件: TestiBars.mq5 11 kb [删除] 2018.04.10 19:39 #144 Nikolai Semko:我不明白为什么这个错误会四处流传。SD知道这整个话题吗? [删除] 2018.04.10 19:39 #145 总的来说,我认为数据加载/上载是终端的弱点。 Nikolai Semko 2018.04.10 19:44 #146 Alexey Kozitsyn:SD知道这整个话题吗?是的,已经在2018年3月30日在那里写了--至今沉默不语。 阿列克谢-科齐岑。 总的来说,我认为数据加载/上载是终端的弱点。同意,但这也是最困难的任务之一。 Aleksey Vyazmikin 2018.04.21 11:44 #147 Nikolai Semko:iBars功能相当麻烦,但我仍然建议使用它而不是普通的Bars,直到MQ修复了其中的挂起错误。 iBar在逻辑上应该返回0的时候却挂了。作为一项规则,它的返回时间超过10秒。在MQL4中没有这样的错误。 在大多数任务中,iBars会比普通的Bars工作得更快,因为它不仅会避免bug,而且由于保存先前值的算法,尽可能不使用Bars 和SeriesInfoInteger函数。 我已经对这个功能进行了广泛的测试。它似乎是Bars的完整副本。 也许可以用一种更优雅的方式来完成。如果你有愿望,我们欢迎你。如果你发现错误,我们将予以纠正。 所以... 那么iBarsShift函数的完整类似物将有以下形式。 而没有最后一个参数的变体,即在绝大多数情况下使用的变体将看起来像这样。 我使用你的代码iBarsShift+iBars(和其他iBarsShift),从iBarsShift得到0,而在TF图表H1和计算H1时出现错误 2018.04.21 14:38:01.059 SVA_LinearRegression_test (Si Splice,H1) zero divide in 'SVA_LinearRegression_test.mq5' (176,44) 与这行代码相对应的是 if(timeframe<PERIOD_W1) TimeCur-=TimeCur% PerSec; 以下是整个指标的代码 #property version "1.00" #property indicator_chart_window #property indicator_buffers 3 #property indicator_plots 3 //--- plot Label1 #property indicator_label1 "LR_line" #property indicator_type1 DRAW_LINE #property indicator_color1 clrGold #property indicator_style1 STYLE_DOT #property indicator_width1 1 //--- plot Label2 #property indicator_label2 "Sup_line" #property indicator_type2 DRAW_LINE #property indicator_color2 clrAquamarine #property indicator_style2 STYLE_DOT #property indicator_width2 1 //--- plot Label3 #property indicator_label3 "Res_line" #property indicator_type3 DRAW_LINE #property indicator_color3 clrOrangeRed #property indicator_style3 STYLE_DOT #property indicator_width3 1 //--- input parameters input ENUM_TIMEFRAMES TF=PERIOD_D1; input int Bar=3; input bool UseClose = true; //--- indicator buffers double LR_line_Ind[]; double Sup_line_Ind[]; double Res_line_Ind[]; //--- int limit,start; //Список переменных: static datetime TimeN=0; int barsToCount=0; int InpChannelPeriod=1000; double OpenI[]; double HighI[]; double LowI[]; double CloseI[]; double arr[]; double Calc_LR_line=0.0; double Calc_Sup_line=0.0; double Calc_Res_line=0.0; ////////////////////////////////////////////////////////////////////// //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,LR_line_Ind,INDICATOR_DATA); SetIndexBuffer(1,Sup_line_Ind,INDICATOR_DATA); SetIndexBuffer(2,Res_line_Ind,INDICATOR_DATA); //--- set accuracy IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //--- set first bar from what index will be drawn PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpChannelPeriod); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpChannelPeriod); PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,InpChannelPeriod); //--- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { ArraySetAsSeries(LR_line_Ind,true); ArraySetAsSeries(Sup_line_Ind,true); ArraySetAsSeries(Res_line_Ind,true); ArraySetAsSeries(time,true); //--- check for rates if(rates_total<InpChannelPeriod) return(0); //--- preliminary calculations if(prev_calculated==0) limit=InpChannelPeriod; else limit=prev_calculated; //--- the main loop of calculations for(int C=limit;C<rates_total && !IsStopped();C++) { LRegrf(C); LR_line_Ind[C]=Calc_LR_line; Sup_line_Ind[C]=Calc_Sup_line; Res_line_Ind[C]=Calc_Res_line; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ double LRegrf(int index) { int Day_Shift=iBarShift(_Symbol,TF,iTime(_Symbol,PERIOD_CURRENT,index),false); Print(iTime(_Symbol,PERIOD_CURRENT,index)); Print(Day_Shift); return (0); } //------------------------------------------------------------------- //==MQL4toMQL5 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ datetime iTime(string symbol,ENUM_TIMEFRAMES tf,int index) { if(index < 0) return(-1); // ENUM_TIMEFRAMES timeframe=TFMigrate(tf); //ENUM_TIMEFRAMES timeframe=PERIOD_CURRENT; datetime Arr[]; if(CopyTime(symbol,tf,index,1,Arr)>0) return(Arr[0]); else return(-1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int iBarShift(const string Symb,const ENUM_TIMEFRAMES TimeFrame,datetime time,bool exact=false) { int Res=iBars(Symb,TimeFrame,time+1,UINT_MAX); if(exact) if((TimeFrame!=PERIOD_MN1 || time>TimeCurrent()) && Res==iBars(Symb,TimeFrame,time-PeriodSeconds(TimeFrame)+1,UINT_MAX)) return(-1); return(Res); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int iBars(string symbol_name,ENUM_TIMEFRAMES timeframe,datetime start_time,datetime stop_time) { static string LastSymb=NULL; static ENUM_TIMEFRAMES LastTimeFrame=0; static datetime LastTime=0; static datetime LastTime0=0; static int PerSec=0; static int PreBars=0; static datetime LastBAR=0; static datetime LastTimeCur=0; datetime TimeCur; if(stop_time<start_time) {TimeCur=stop_time; stop_time=start_time; start_time=TimeCur; } TimeCur=TimeCurrent(); if(LastTimeFrame!=timeframe) if(timeframe==PERIOD_MN1) PerSec=2419200; else PerSec=::PeriodSeconds(timeframe); if(timeframe<PERIOD_W1) TimeCur-=TimeCur%PerSec; if(start_time>TimeCur) {LastSymb=NULL; return(0);} if(LastTimeFrame!=timeframe || LastSymb!=symbol_name || ((TimeCur-LastBAR)>0 && TimeCur!=LastTimeCur)) LastBAR=(datetime)SeriesInfoInteger(symbol_name,timeframe,SERIES_LASTBAR_DATE); LastTimeCur=TimeCur; if(PerSec==0) return(0); if(start_time>LastBAR) {LastTimeFrame=timeframe; LastSymb=symbol_name; return(0);} datetime tS,tF=0; bool check=true; if(timeframe<PERIOD_W1) tS=start_time-(start_time-1)%PerSec-1; else if(timeframe==PERIOD_W1) tS=start_time-(start_time-259201)%PerSec-1; else { PerSec=2678400; MqlDateTime dt; TimeToStruct(start_time-1,dt); tS=dt.year*12+dt.mon; } if(stop_time<=LastBAR) { if(timeframe<PERIOD_W1) tF=stop_time-(stop_time)%PerSec; else if(timeframe==PERIOD_W1) tF=stop_time-(stop_time-259200)%PerSec; else { MqlDateTime dt0; TimeToStruct(stop_time,dt0); tF=dt0.year*12+dt0.mon; } if(tS==tF) {PreBars=0; check=false;} } if((LastTimeFrame!=timeframe || LastSymb!=symbol_name || tS!=LastTime || tF!=LastTime0) && check) PreBars=Bars(symbol_name,timeframe,start_time,stop_time); LastTime=tS; LastTime0=(datetime)tF; LastTimeFrame=timeframe; LastSymb=symbol_name; return(PreBars); } 为什么Print(Day_Shift)总是返回0,而日期和时间是正确的? 这似乎是周末的影响,因为前几天一切都在正常工作(虽然有不同的功能,但今天也不工作了)。 Nikolai Semko 2018.04.22 00:16 #148 Aleksey Vyazmikin:我使用你的代码iBarsShift+iBars(和其他iBarsShift),从iBarsShift得到0,当TF图表H1和H1上的计算出现错误 与这行代码相对应的是 以下是整个指标的代码 为什么Print(Day_Shift)总是返回0,而date和日期是正确的? 这似乎是一个周末的影响,因为前几天一切都在正常工作(虽然有一个不同的功能,但今天也不工作了)。我为以错误的形式留下代码而道歉。 我当时就注意到了这个不准确的地方,并几乎把它修好了,但还是有一个小的、容易解决的问题。 我刚刚放弃了这个代码,原因是我现在正在学习,考试已经开始,我只是没有时间。最后一次考试是在4月24日。 之后,我将修复一切并在CB上发布。 我已经开始出版了,但已经搁置了。 Aleksey Vyazmikin 2018.04.22 00:22 #149 Nikolai Semko:我为以错误的形式留下代码而道歉。 我当时就注意到了工作不准确的问题,几乎把它修好了,但还是有一个容易解决的小问题。 我只是放弃了这个代码,因为我现在正在学习,考试时间已经开始,我只是没有时间。最后一次考试是在4月24日。 之后,我将修复一切并在CB上发布。 我已经开始发帖,但已经搁置了。 我将等待最终形式的更正,感谢您的回应。 祝你考试顺利! Nikolai Semko 2018.04.22 00:25 #150 Aleksey Vyazmikin:我将等待最终形式的更正,感谢您的回复。 祝你考试顺利! 谢谢你))。 1...891011121314151617 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
顺便说一下,关于Bars()函数。这可能是导致成交的原因。
除了感兴趣的那个人之外,所有的角色都可以去做Cotypes。
好了,看了看新的源代码。看到讨论过的编辑还没有做。退出。
只有当要求的符号不在市场观察窗口中时,使用SYMBOL_TIME才有意义。那么TimeCurrent 就不能完成它的工作。但在我看来,这种使用Bars的变体似乎不太可能。但通过SYMBOL_TIME获取当前时间的代价要高得多,因为SymbolInfoInteger(symbol_name,SYMBOL_TIME)几乎要花费一个数量级的时间。当然,你可以检查符号是否在市场报告中,并根据结果使用TimeCurrent 或SYMBOL_TIME,但这不是免费的,特别是你必须不断检查是否有新的符号被添加或从市场报告中删除。因此,为了iBars的正确工作,在市场报告中拥有所要求的符号是合理的,这样的条款比较容易。
关于SERIES_LASTBAR_DATE,我认为你错了。SymbolInfoInteger(symbol_name,SYMBOL_TIME)是一个较小的邪恶。
SeriesInfoInteger函数不会引起任何历史分页。如果有什么原因的话,那就是对Bars的要求,这也是符合逻辑的。而刹车的来源可以在这个简短的脚本中看到,如果你运行它的话
一般来说,这是一个非常奇怪的错误。我检查了下载历史对它的影响,当我发现今天突然在欧元兑美元的符号 上它几乎没有显示出来。
迫使我下载所有的历史资料。而这个错误又出现了。
我想下载历史对这个错误没有影响。
我不明白为什么这个错误会四处流传。
用这个脚本来测试。
我不明白为什么这个错误会四处流传。
SD知道这整个话题吗?
SD知道这整个话题吗?
是的,已经在2018年3月30日在那里写了--至今沉默不语。
总的来说,我认为数据加载/上载是终端的弱点。
同意,但这也是最困难的任务之一。
iBars功能相当麻烦,但我仍然建议使用它而不是普通的Bars,直到MQ修复了其中的挂起错误。
iBar在逻辑上应该返回0的时候却挂了。作为一项规则,它的返回时间超过10秒。在MQL4中没有这样的错误。
在大多数任务中,iBars会比普通的Bars工作得更快,因为它不仅会避免bug,而且由于保存先前值的算法,尽可能不使用Bars 和SeriesInfoInteger函数。
我已经对这个功能进行了广泛的测试。它似乎是Bars的完整副本。
也许可以用一种更优雅的方式来完成。如果你有愿望,我们欢迎你。如果你发现错误,我们将予以纠正。
所以...
那么iBarsShift函数的完整类似物将有以下形式。
而没有最后一个参数的变体,即在绝大多数情况下使用的变体将看起来像这样。
我使用你的代码iBarsShift+iBars(和其他iBarsShift),从iBarsShift得到0,而在TF图表H1和计算H1时出现错误
与这行代码相对应的是
以下是整个指标的代码
为什么Print(Day_Shift)总是返回0,而日期和时间是正确的?
这似乎是周末的影响,因为前几天一切都在正常工作(虽然有不同的功能,但今天也不工作了)。
我使用你的代码iBarsShift+iBars(和其他iBarsShift),从iBarsShift得到0,当TF图表H1和H1上的计算出现错误
与这行代码相对应的是
以下是整个指标的代码
为什么Print(Day_Shift)总是返回0,而date和日期是正确的?
这似乎是一个周末的影响,因为前几天一切都在正常工作(虽然有一个不同的功能,但今天也不工作了)。
我为以错误的形式留下代码而道歉。
我当时就注意到了这个不准确的地方,并几乎把它修好了,但还是有一个小的、容易解决的问题。
我刚刚放弃了这个代码,原因是我现在正在学习,考试已经开始,我只是没有时间。最后一次考试是在4月24日。
之后,我将修复一切并在CB上发布。
我已经开始出版了,但已经搁置了。
我为以错误的形式留下代码而道歉。
我当时就注意到了工作不准确的问题,几乎把它修好了,但还是有一个容易解决的小问题。
我只是放弃了这个代码,因为我现在正在学习,考试时间已经开始,我只是没有时间。最后一次考试是在4月24日。
之后,我将修复一切并在CB上发布。
我已经开始发帖,但已经搁置了。
我将等待最终形式的更正,感谢您的回应。
祝你考试顺利!
我将等待最终形式的更正,感谢您的回复。
祝你考试顺利!