Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1076
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
How do I read a large file in one line?
FileReadString()
When reading from a bin-file. the length of a string to read must be specified. When reading from a txt-file the string length is not required, and the string will be read from the current position to the line feed character "\r\n". When reading from a csv-file, the string length isn't required also, the string will be read from the current position till the nearest delimiter or till the text string end character.
That's not what I mean.
"And with a logical NOT to solve - invert the bits, but I don't have a terminal - I can't remember how to do a bitwise NOT in MQL, and I don't want to read the online help".
I mean either give me a proof or don't muddy the waters ))))
"Anybody can make a mistake. Only the strong can admit to a mistake!". If no one has voiced it yet, that's my wisdom ))). If someone has already said it - I have repeated the wisdom of a wise man ))))
I still do not understand your claims? You suggesting that I should prove something to you? - Why? ))))
Here I reproduced via NOT and checked all discussed variants:
NOT variant works with any TF, but fill according to (~TF_ below which we display & TF_one older than required TF)-1;
Good day everyone! One more question...
There is an MQL5 program, it has a setting (a lot) of "Input parameters". The program performs calculations and creates / deletes and manages graphical objects as needed.
After the change of input parameters from setup window the eventInit is generated, which leads to program initialization and "recalculate" and "redraw" objects, which is, in principle, what is needed, butthe eventInitis also generated when the chart period is changed (and other), as a result the process repeats every time, even when it is not needed.
Question:How can I exclude program initialization atInit eventifinput parameters are not changed but leave initialization at program (terminal) start?
Possible variant: to remember the set values and compare them when the event Init occursand if they are different allow initialization, but there are a lot of input parameters...
Good day everyone! One more question...
There is an MQL5 program, it has a setting (a lot) of "Input parameters". The program performs calculations and creates / deletes and manages graphical objects as needed.
After the change of input parameters from setup window the eventInit is generated, which leads to program initialization and "recalculate" and "redraw" objects, which is, in principle, what is needed, but the eventInit is also generated when the chart period is changed (and others), as a result the process repeats every time, even when it is not needed.
Question:How can I exclude program initialization atInit eventif input parameters are not changed but leave initialization at program (terminal) start?
Possible variant: to remember the set values and compare them when event Init occursand if they are different to allow initialization, but there are a lot of input parameters...
Here are some tips for another, similar problem
Forum on trading, automated trading systems & strategy testing
Works in EA, but not right in indicator, music when indicator starts
Ihor Herasko, 2019.06.17 14:12
Yes.
Forum on trading, automated trading systems and strategy testing
It works in Expert Advisor, but it is not correct in indicator, music on indicator start
Taras Slobodyanik, 2019.06.17 16:25
5. You can also leave an object on the chart and check its presence-state when you start.Here are some tips for another, similar problem
Thanks for the reply, it looks like in our case we will have to keep track of the state of a couple of dozen changes of correspondences by describing this through a "blank" on the graph to keep track of their changes, or put up with unnecessary initialisation as long as there are not so many objects...
But the question you asked was.
Good day, everyone! One more question...
There is an MQL5 program, it has settings (a lot) "Input parameters". The program performs calculations and creates / deletes and manages graphical objects as needed.
After the change of input parameters from setup window the eventInit is generated, which leads to program initialization and "recalculate" and "redraw" objects, which is, in principle, what is needed, but the eventInit is also generated when the chart period (and other)is changed , as a result the process repeats every time, even when it is not needed.
Question:How can I exclude program initialization atInit eventif input parameters are not changed but leave initialization at program (terminal) start?
Possible variant: to remember the set values and compare them when event Init occursand if they are different to allow initialization, but there are a lot of input parameters...
And in your situation, one of those tips will prevent these unnecessary redraws of objects. And if these objects are deleted in OnDeinit(), you should prohibit deletion there too when switching the chart.
This is a forum for trading, automated trading systems and strategy testing.
How to delete global variable of the terminal at chart close?
Alexey Viktorov, 2019.06.29 08:40
Pay attention to this table
REASON_PROGRAM
0
Expert stopped working by calling ExpertRemove()
REASON_REMOVE
1
Program removed from the chart
REASON_RECOMPILE
2
Program recompiled
REASON_CHARTCHANGE
3
The chart symbol or period has been changed
REASON_CHARTCLOSE
4
The chart is closed
REASON_PARAMETERS
5
Input parameters were changed by the user
REASON_ACCOUNT
6
Another account was activated or reconnected to the trade server because the account settings were changed
REASON_TEMPLATE
7
Another chart template was applied
REASON_INITFAILED
8
OnInit() handler returned a non-zero value
REASON_CLOSE
9
Terminal was closed
and on this line of your code
But if I remember correctly the beginning of your problem, it is better to put the condition like this
But in your question it was
In your situation, one of those tips will prevent these unnecessary object redraws. And if these objects are deleted in OnDeinit(), then you should prohibit deletion there as well when switching the chart.
I haven't found an EA example in Codebase where a closing condition can be set, not only standard SL/TP. Can someone give me a hint?
What is the difference between opening and closing condition?
I have not found in Codebase an example of an EA where one can write the closing condition of a position, and not only the standard SL/TP. Can someone tell me?
Vladimir Karputov had such conditions in his codes, but you have to learn how to read his code yourself)