Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Does it start working again once the connection is re-established?
I made a few changes and now it resumes operation after the Internet connection is interrupted
The first change is the argument of the function CopyTime()
I don't know why but if Bars() exceeds 99999 then CopyTime() returns 1970.01.01 00:00:00
When reconnecting, sometimes Bars() returned 0 or -1
that's why I did it:
if(Bars(SymbolArray[Symb],TFArray[TF]) >= 100000) { BarsStart = 99999; } else if(Bars(SymbolArray[Symb],TFArray[TF]) < 1) { BarsStart = 1500; } else { BarsStart = Bars(SymbolArray[Symb],TFArray[TF]) - 1 ; }
In int OnCalculate()I added:
if(CopyTime(SymbolArray[Symb],TFArray[TF],BarsStart,1,DTArray)==-1) { Comment("Error defining data start, please try again later. bars = " + SymbolArray[Symb] + "_" + TIMEFRAME(TFArray[TF]) + " " + Bars(SymbolArray[Symb],TFArray[TF]) + " " + BarsStart); ArrayResize(DTArray,1); DTArray[0] = TimeCurrent() - 60*5; Alert(SymbolArray[Symb] + TIMEFRAME(TFArray[TF]) + "DTArray[0] = " + DTArray[0]); }
This helped when the connection was disconnected and the indicator resumed operation
In void OnTick() this is not necessary, the "indicator" resumes operation itself.
The question remains:
To run the indicator I have to place it in the chart window. this can somehow be omitted. Run indicator or EA or something else entirely without a chart window.
Do not hard code constants | ENUM_TIMEFRAMES TFArray[] = {1,30,16385}; |
Use the proper symbols. | ENUM_TIMEFRAMES TFArray[] = {PERIOD_M1, PERIOD_M30, PERIOD_H1}; |
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello
I made an indicator that exports data from mt5 to txt.
The problem occurs when the Internet connection is interrupted.
Message appears -> "Error defining data start, please try again later"
So I think I did something wrong with theCopyTime() function
I have one additional question. I am a beginner in mt5 and mql5.
To run the indicator I have to place it in the chart window. this can somehow be omitted. Run indicator or EA or something else entirely without a chart window.
Thank you for your answer.
Best regards.