![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi RaptorUk,
Now the ea is running and I've update the code per your advise.
As soon the error comes I come back.
Here is the information from the Journal tab of the demo account. This error appears here but not on Experts tab.
From the Experts tab
Thank you for your time
Luis
Hi RaptorUk,
Now the ea is running and I've update the code per your advise.
As soon the error comes I come back.
Here is the code for order modify;
After a quick look this may be your issue . . .
. . . this can't be an int . . . 10 + 0.25 as an int = 10
It's difficult to be sure without all the information though . . .
This makes no sense . . . don't convert to points twice . . .
Maybe do this instead for clarity . . .
After a quick look this may be your issue . . .
. . . this can't be an int . . . 10 + 0.25 as an int = 10
It's difficult to be sure without all the information though . . .
This makes no sense . . . don't convert to points twice . . .
Maybe do this instead for clarity . . .
Hi RaptorUK,
Is the code that follows the right one to get the total OrderPprofit ?
I mean, if the result is the same that the AccountProfit() but in this case just limited to the orders that the ea is processing.
Thank you for clarification.
Luis
Hi RaptorUK,
Is the code that follows the right one to get the total OrderPprofit ?
I mean, if the result is the same that the AccountProfit() but in this case just limited to the orders that the ea is processing.
It looks OK . . . but haven't we just totally jumped to a different subject ? what about the OrderModify() issues ?
Hi RaptorUk,
Yes, I'am testing the ea on demo account and waiting for an error to appear. Once the error appear I will come back with the issue. The error do not appear always and now the ea have is code updated per your recommendations.
Thank you for your concern in keep support me.
Best regards
Luis
Update: Seems that the error comes when the spread increase and in case that the spread value is at least equal to the opposite distance that forces the other order to open and then the error appears....That occurred just now.
Need to scratch my head to find a way that is spread proof.......
Here is the Log from experts tab;
Update: Seems that the error comes when the spread increase and in case that the spread value is at least equal to the opposite distance that forces the other order to open and then the error appears....That occurred just now.
Need to scratch my head to find a way that is spread proof.......
Here is the Log from experts tab;
That is something else, that is a problem with an Ordersend() not an OrderModify() you are not printing the position size as part of the error reporting, you need to print all the information you need so that after the event you can diagnose the issue . . . you only see why error reporting is so important when you have an issue and you don't have the information you need to understand what is causing the issue.
Hi RaptorUK,
So, the error appears again. follows are the logs from Journal and Experts tabs.
I've update the error routine with more information as Lotsize for the Initial orders and MLots from the Opposite orders as well spread for both.
From Journal an error appears but from the Experts there is no information for the same order.......
From Journal
From Experts;
Thank you in advance for support provided.
Luis
Hi RaptorUK,
So, the error appears again. follows are the logs from Journal and Experts tabs.
I've update the error routine with more information as Lotsize for the Initial orders and MLots from the Opposite orders as well spread for both.
From Journal an error appears but from the Experts there is no information for the same order.......
This means you are not printing the required information to the log . . . so we still don't know what the error number was, or any other needed information. It is critical that you sort out your error reporting and test it on Several Brokers so that you know it is working as it should . . . when you have an error it is all you have to determine the cause.
In the mean time lets look at the information you do have:
You have this:
and this:
Note: not the line you marked, check the date and time at the start of the line.
What do we know:
You also report that the Spread: 0 which it obviously isn't, are your Freeze Level and Stop Levels also wrong ? why are you reporting the Spread incorrectly ? why do you only have 4 digits for the Trailing and Stop Loss figures ?
Perhaps your Bid and Ask are becoming out of date ? you can determine this by printing Bid, Ask, MarketInfo(Symbol(), MODE_BID) and MarketInfo(Symbol(), MODE_ASK) when a function fails that could be as a result of stale Bid or Ask.
You cannot write code that will never experience an issue you had not thought of . . . even the best coders will have issues, what is important is how you handle these issues. You cannot go back in time and see what happened, the best you can do is to print all the information you need when you detect a problem, so when a function fails print ALL the info you are going to need when you come to diagnose the problem later on.
You need to do this for ALL your major Trading Function calls, OrderSend(), OrderModify(), OrderClose(), OrderDelete() & OrderCloseBy()
This means you are not printing the required information to the log . . . so we still don't know what the error number was, or any other needed information. It is critical that you sort out your error reporting and test it on Several Brokers so that you know it is working as it should . . . when you have an error it is all you have to determine the cause.
In the mean time lets look at the information you do have:
You have this:
and this:
Note: not the line you marked, check the date and time at the start of the line.
What do we know:
You also report that the Spread: 0 which it obviously isn't, are your Freeze Level and Stop Levels also wrong ? why are you reporting the Spread incorrectly ? why do you only have 4 digits for the Trailing and Stop Loss figures ?
Perhaps your Bid and Ask are becoming out of date ? you can determine this by printing Bid, Ask, MarketInfo(Symbol(), MODE_BID) and MarketInfo(Symbol(), MODE_ASK) when a function fails that could be as a result of stale Bid or Ask.
You cannot write code that will never experience an issue you had not thought of . . . even the best coders will have issues, what is important is how you handle these issues. You cannot go back in time and see what happened, the best you can do is to print all the information you need when you detect a problem, so when a function fails print ALL the info you are going to need when you come to diagnose the problem later on.
You need to do this for ALL your major Trading Function calls, OrderSend(), OrderModify(), OrderClose(), OrderDelete() & OrderCloseBy()
Hi RaptorUK,
Thank you for your time in support me.
Regarding the spread and as far I understand that information comes from;
So, why this line of code do not return the spread value as should ?
Is there other way to get the spread value ?
Regarding Bid and Ask don't these values are updated if one use RefreshRates(); just on the line where theses values are and in such case there is not the need to use the markinfo ?
Nevertheless I go update the error line to include these information of Bid and Ask, as well get the right way to get these values using doubleToStr.
Another issue that keeps me confused is how the error appear in Journal and not in Experts tabs.
By the way, the code as is now regarding Ask and Bid is;
DoubleToStr(Ask,Digits)
How can I include
MarketInfo(Symbol(),MODE_ASK)
Regarding your advise about;
Am confused. Should I use;
StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);
or;
StopLevel.point = StopLevel * Point;
Thank you for keep support me
Luis
Hi RaptorUK,
Thank you for your time in support me.
Regarding the spread and as far I understand that information comes from;
I'm not sure how you are getting 0 for the Spread, are you multiplying the figure from MarketInfo() by point ? or just using the value as it is ? the Spread is also Ask - Bid.
Bid and Ask are updated by using RefreshRates(), if you use MarketInfo() to get Bid and Ask you don't need to use RefreshRates() . . . either method is OK but you need to be aware of when prices can become out of date and then take precautions to guard against it happening.
By the way, the code as is now regarding Ask and Bid is;
DoubleToStr(Ask,Digits)
How can I include
MarketInfo(Symbol(),MODE_ASK)
You can do this . . .
Regarding your advise about;
Am confused. Should I use;
StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);
or;
StopLevel.point = StopLevel * Point;
You can use either, you need to understand the difference though. StopLevel is the STOPLEVEL expressed as a number of points, so a STOPLEVEL of 10 is 10 points, the value is 10. StopLevel.point for the same STOPLEVEL is 0.0001
I would use the code as you have posted it above . . . with some additional changes.
I think the issue with the Spread showing as 0 will be fixed if you use DoubleToStr(x, Digits) with the variable, any variables that are price values must be used with DoubleToStr(x, Digits). So if you print FreezeLevel you can do it without DoubleToStr(x, Digits), if you print FreezeLevel.point you must use DoubleToStr(x, Digits) . . . do you see the difference ?