Errors, bugs, questions - page 2458
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
When switching from MQL4 to MQL5 I encountered a glitch:
Code:
ResetLastError();
int ObjTotal = ObjectsTotal(0);
int Error = GetLastError();
returns:
ObjTotal = 0.
Error = 4022
What is this error and why it is not mentioned in the documentation?
I tried different variants: ObjectsTotal(0, -1, -1), ObjectsTotal(ChartID(), 0, OBJ_TREND), etc.
The result is the same.
How to make it work?
Advice: If you want to ask something, insert the FULL code, not a piece of it.
What's the point: anyone takes your code and runs it on their own. And almost no one looks at chunky code - chunky code is disrespectful.
Example of your code:
Run it on a graph that doesn't have any graphical objects on it. Result:
That is, there is no error.
Using the terminal:
A word of advice: if you want to ask something, insert the FULL code, not a piece.
Thanks for the advice, that's what I'll do.
However, the question remains open.
Clarification: if the piece of code from the previous post is in the OnDeinit() function of the indicator, the result is this:
2019.05.10 14:08:20.105 PtS (EURUSD,H1) ObjectsTotal: 0, GetLastError: 4022
If you run the same code after deleting the indicator from the chart, like the script (1.mq5 from the previous post), we get
2019.05.10 14:08:33.609 1 (EURUSD,H1) ObjectsTotal: 8575, GetLastError: 0
Please help me to understand the reason.
error in strategy tester during optimisation.
" task rejected by tester agent "
For example if your account currency is EUR,
If your account currency is USD
appears when other currency pairs are used in the code.
In my example it's using calculation of dynamic lot
i.e. when EA is requesting price of another currency.
@Vladislav Andruschenko
Hi, did you get any answer or solution to this problem?
When the schedule/period is changed, PBB receives a value of 10, no matter what value you have specified in the input field.
At the moment of re-initialisation, it is as if it were the first run.
There are two ways to solve your problem
1 - Storing PBB value in global variables and get the period from there.
2 - When OnChartEvent triggers, reinitialize MA indicator and get a new handle...
Checked all options. It does not work.
Fault in MQL5.
It does not initialize new values. Only with parameter input int PBB_=. No other options. This is not good at all.
Checked all the options. Doesn't work.
Flaw in MQL5 program.
New values are not initialized. Only with input int PBB_= parameter. No other options. This is not good at all.
Everything is fine in MQL, you just don't understand what you are doing in your code and how everything works...
Once again, when you callChartSetSymbolPeriod(0,_Symbol,_Period);
You're resetting everything to default...
Alternatively, try the inite to request a value from your text field.
When you start indicator for the first time, everything is created and when you change data in the field, it will call new unity and set value from your text field...
Everything is fine in MQL, you just don't understand what you're doing in the code and how everything works...
Once again, when you callChartSetSymbolPeriod(0,_Symbol,_Period);
You're resetting everything to default...
Alternatively, try to query the value from your text field in the init.
After logic, the first start of the indicator, everything is created, but when you change data in the field, there will be a new call in the unity and value setting from your text field...
I tried it with the text field and through GlobalVariable, but I've never tried anything. It's as silent as in a tank.
In other variantOnCalculate works without problems.
I tried both from a text field and via GlobalVariable and whatever else I tried. It's as silent as a tank.
The other version of OnCalculate works without problems.
That means you are doing something wrong
Then you're doing something wrong.
You've already posted the code.
If I'm inept, someone must be a pro. I don't see it yet.
I accept your effort to find an answer. There's more to it than that. That is, at the level of the developers.