Hi . I write this code in mql4 and run in mt4 and works good . Means if i drop this indicator in 7 chart , then 7 symbols write in the file.
But when i write in mql5 and run in mt5 , when i drop this indicator in 7 chart i see in the file just 2 symbol by random.
Is it a bug in mql5 ?
string Handle2;
Handle2 =FileOpen("test.txt",FILE_TXT|FILE_READ|FILE_WRITE,"\r\n");
FileSeek(Handle2, 0,SEEK_END);
FileWriteString(Handle2,Symbol()+ "\r\n");
FileClose(Handle2);
Please read carefully the documentation https://www.mql5.com/en/docs/files
Especially check FileOpen: the type for the delimiter is short (not string); and the return type is int, not string.
Insert
#property strict
at the beginnig of your code.
Matthias
- www.mql5.com
-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor -
Handle2 =FileOpen("test.txt",FILE_TXT|FILE_READ|FILE_WRITE,"\r\n");
When another thread has the file open, this fails. You don't handle failures. Delay and retry.Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014
Please read carefully the documentation https://www.mql5.com/en/docs/files
Especially check FileOpen: the type for the delimiter is short (not string); and the return type is int, not string.
Insert
at the beginnig of your code.
Matthias
thank you.
Can you Drop this indicator in mt5 int 7 chart and see the result? In mt4 code works.
-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor - When another thread has the file open, this fails. You don't handle failures. Delay and retry.
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014
thank you anyway.
-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor - When another thread has the file open, this fails. You don't handle failures. Delay and retry.
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014
I added this code to end of code because of last thread.
Sleep(5000);
But does not works. How can say that run multithread?
Please read carefully the documentation https://www.mql5.com/en/docs/files
Especially check FileOpen: the type for the delimiter is short (not string); and the return type is int, not string.
Insert
at the beginnig of your code.
Matthias
- mir202020: But does not works.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button).
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problemWe can't see your broken code. You added to the end of code? What part of “retry” was unclear?
-
You were asked to edit your (original) post. Why didn't you?
I write code by script instead indicator because of thread.
It works good . thank you.
Indeed we only have broken code without the environment. Difficult problem...
A proposition for an (rudimentary) indicator:
#property strict #property indicator_chart_window int OnInit() { int Handle2; Handle2 =FileOpen("test.txt",FILE_TXT|FILE_READ|FILE_WRITE|FILE_ANSI); FileSeek(Handle2, 0,SEEK_END); FileWriteString(Handle2,Symbol() + "\r\n"); FileClose(Handle2); return(INIT_SUCCEEDED); } int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { return(rates_total); }
Please note the FILE_ANSI flag in call of FileOpen.
It works fine without any problems here :-)
Matthias
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi . I write this code in mql4 and run in mt4 and works good . Means if i drop this indicator in 7 chart , then 7 symbols write in the file.
But when i write in mql5 and run in mt5 , when i drop this indicator in 7 chart i see in the file just 2 symbol by random.
Is it a bug in mql5 ?