OrderVolume = NormalizeDouble((Free*SingleOrderRisk/100/One_Lot/Step)*Step,1);
Why divide by Step and then multiply by Step?
What if Step is 0.25 ? If the calculation calculates 0.25, it will then be normalised to 0.3 - an invalid lot size.
What if Step is 0.01 ? If the calculation calculates anything less than 0.05, it will then be normalised to 0.0 - an invalid lot size.
bool OrderVolumeCalc()
If this function returns false, you still carry on and try to use the calculated (too small) lot size
If the OrderSend fails, print out the lot size, that will help you to find your error
Tarkunian: it gives me an error OrderSend 4051, however my OrderVolume is normalized.
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong (as you just proved.)
- SL/TP are market orders when triggered, they don't need to be normalized, only abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum
- Only the open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
- Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
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 guys!
Here is the simple EA. When I am trying to test the strategy it gives me an error OrderSend 4051, however my OrderVolume is normalized. Can you help me to find what is wrong?