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
In order to test it on a hedging account do I just need to change the Account Type under the Common Tab when publishing the EA to the market place?
Yes!
EDIT: I believe you can also set both options, and have it test both.
I'm still getting [Invalid Stops] on a hedging account. Any other ideas?
I added code to check the freeze level before closing and that seemed to fix the modification errors so some progress was made.
It seems rather strange that it only seems to fail for "Instant Execution".
I am wondering if it has anything to do with re-quotes and the value you set for your maximum deviation. In other words, slippage!
What value are you using for deviation?
Also, as a test, can you force your stops to widen a bit more?
On MQL5, I use the CTrade class to place orders. I use:
SetDeviationInPoints(0)
I added an extra 10 pips to each SL. I'm no longer getting [Invalid Stops] errors but I am getting these errors:
I'm always risking 1 percent but it seems like the balance is set to $1? That seems really low for testing. Either way, I don't think these need to be worried about.
Tyler James Wanta #: On MQL5, I use the CTrade class to place orders. I use:
I added an extra 10 pips to each SL. I'm no longer getting [Invalid Stops] errors but I am getting these errors:
I'm always risking 1 percent but it seems like the balance is set to $1? That seems really low for testing. Either way, I don't think these need to be worried about.
Given that widening your stop did change things, tells me that slippage was, in part, involved in the issue.
As for the "no money" problem, that tells me that you are not properly adjusting your volume accordingly to both Stop-Loss risk and the Margin requirements.
There are just too many inconsistency. It would be necessary to do a proper and completely analysis of your code to debug the issues.
Since this is for a Market product, I can understand that you would not want to publish the entire code here in public.
"Given that widening your stop dis change things, tells me that slippage was, in part, involved in the issue."
Is there a specific way I should be addressing this? If slippage is involved in the issue, should I be allowing for more of it? Just increasing it doesn't seem like an actual solution, just a convenience to pass validation.
"As for the "no money" problem, that tells me that you are not properly adjusting your volume accordingly to both Stop-Loss risk and the Margin requirements."
I don't think I am taking into account the Margin requirement. I assume you mean, to account for how much margin is left and only use as much as is available? This is all i'm doing for the lot size calculation.
By the way, to quote another person's text, first start your own post and position your cursor where you want to place the quote, then with your mouse, select/highlight the section of the other person's text and then click "reply" in the bottom-right corner of their post.
Ok. That makes sense. Thanks for clearing that part up.
I tried normalizing the price like so:
(I know I should place code instead of images but the code formatting was not working)
but this still isn't working. In fact, it lead to a larger number of [Invalid Stops] errors when running validation. Any thoughts?
Error in your logic:
1. You only check if minstoplos>0.
=You should know that SYMBOL_TRADE_STOPS_LEVEL is not always greater than 0.
=Error [Invalid Stops] when running validation, because SYMBOL_TRADE_STOPS_LEVEL or minstoplos is 0.
2. You have to code what if minstoplos=0.
Most probably, you will just need to have default inputs that widen the stop sufficiently to compensate for any slippage, but allowing the user to modify those inputs for tighter stops for actual live trading.
Not ideal but it does work so I guess I'm fine with it.
When calculating your volume, you first calculate it based on maximum allowed risk for the stop-loss size (e.g. 1% risk of balance).
Then you see how much margin is required for that volume, and what percentage is acceptable. (e.g. 10% margin maximum).
And when the minimum allowed volume is beyond the allowed margin requirement, then no order is placed at all.
For MQL5, please read the following ... https://www.mql5.com/en/forum/446211#comment_46501011
I implemented a margin check for both MQl4 and 5 and they both seem to be working properly. Thanks for the resources.
For MQL4, your code is unfortunately incorrect. See the following (please note that I am taking a very conservative approach) ... https://www.mql5.com/en/forum/390589#comment_28231377 .
I compared the results from this approach to what I am currently doing and got the exact same result so I'm going to leave it as it is.
After implementing the margin checks, a bit extra SL padding, and switching the account type to Hedging, all validation passed. Thanks for all the help!