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
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.
You can do this . . .
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 ?
Hi RaptorUK,
Thank you for clarification about the last issues.
While waiting for errors to appear I'm working in the part of code that open the opposite order.Here am testing al line of code to achieve that. Here is the code that am using and would like to know if is also necessary to make use of doubleToStr.
The reason that I'm using this code is that I saw it in another ea and it open the orders at precise distance, but here seems to work not so well..........
Thank you in advance
Luis
Hi RaptorUK,
Thank you for clarification about the last issues.
While waiting for errors to appear I'm working in the part of code that open the opposite order.Here am testing al line of code to achieve that. Here is the code that am using and would like to know if is also necessary to make use of doubleToStr.
Do you need to convert double values to a string ? if you do, for example when you want to print with 5 digits instead of 4 then yes, use it . . . but if you want a value and not a string then no, don't use it.
Hi RaptorUK,
Thank you for your prompt response.
As told before when spread starts to increase to values near of opposite distance some errors start to appear. Perhaps this distance can't be used at all....
For the other issue of not getting the same distance on opening opposite orders while using that line of code in other ea the that ea open orders at precise distance, I mean, id a sell is open and if price goes up after x distance another sell opens at that distance, at least on tester, but in this ea it don't or some times do and others not...
I have download a spread controller and go testing under controlled conditions.
Best regards
Luis
Hi RaptorUK,
Thank you for your prompt response.
As told before when spread starts to increase to values near of opposite distance some errors start to appear. Perhaps this distance can't be used at all....
I promise you this . . . if you make your error reporting comprehensive and useful you will be able to determine what the problem was when you get an error . . . without it you are just guessing. Most people that post on this forum leave error reporting to a final afterthought, or don't bother, it should be something that you make a priority and do as soon as possible when you write any code that uses a function that returns a value that tells you if the function worked or not.
We don't have a debugger with mql4, the only tools you have are outputting variables via Print(), Alert(), Comment() or Files . . . when the tools are so scarce you MUST take full advantage of what you have got.
I promise you this . . . if you make your error reporting comprehensive and useful you will be able to determine what the problem was when you get an error . . . without it you are just guessing. Most people that post on this forum leave error reporting to a final afterthought, or don't bother, it should be something that you make a priority and do as soon as possible when you write any code that uses a function that returns a value that tells you if the function worked or not.
We don't have a debugger with mql4, the only tools you have are outputting variables via Print(), Alert(), Comment() or Files . . . when the tools are so scarce you MUST take full advantage of what you have got.
Hi RaptorUk,
Thank you for your up most advise regarding the issue.
I already have run that tool just to see if a different spread value could affect the opening of the orders and what I found was that sometimes the opposite order open before or even after it reaches the value to open it for example it should open at 20 points, no less no more.
Now I'm just doing the test with all values that are used to process the orders. Using that tool allowed me to do the test at week end because the last market spread value was 92 points.
Meanwhile I appreciate your support.
Luis
Hi RaptorUk,
So, I've run a test using the spread control just to work on week end and to confirm the behaviour of opposite order against spread value.
The result of that test have shown that the orders have been open very near of opposite order value, but in a particular part where a break occurred the opposite orders have open on 30 points instead of 20, from there the next order open at the right value (20 points up) and the next one at 9 points down (no good) and again the next open at 9 points up...
Looking for the errors on Journal tab from Tester no error came up and now I start to get stupid looking for a valid reason why is this happen. In next comment is the log because the text is to long.
Follow is the code to open the opposite order and would like to know if lines marked make sense.
Thank you for time spent
Luis