Hello! First of all, I am a total Newbie to Mql4 and I just started like 3 days ago to discover the possibilities of an EA.
Please bare with me, I really do appreciate any kind of help, that I can get. I was reading here in the forum and in the manual alot about the
NormalizeDouble function, after I am getting the ongoing error OrderSend 4051. I kind of figured out, that this has to do with the Lot Value and maybe the Bid Value given back,
my EA is currently just for NZDJPY, M5 and only short.
I simply cant figure out on my own how to put the NormalizeDouble function correctly, and where. Thank you for your help! I know its anything else than a proper or a clean code, maybe even wrong, but as
I said, please bare with me, I am very green :-)
4051 | ERR_INVALID_FUNCTION_PARAMVALUE | Invalid function parameter value |
https://forum.mql4.com/43325
- to make a lot size. NormalizeDouble(x, 1) ASSUMES LOTSTEP is 0.1 it fails for any other. Use MathFloor(x/lotStep)*lotStep.
Hope that helps.
4051 | ERR_INVALID_FUNCTION_PARAMVALUE | Invalid function parameter value |
https://forum.mql4.com/43325
- to make a lot size. NormalizeDouble(x, 1) ASSUMES LOTSTEP is 0.1 it fails for any other. Use MathFloor(x/lotStep)*lotStep.
Hope that helps.
Ok I dont reallz know how to and where to put this, I am assuming somewhere here:
//max open orders if (OrdersTotal() < 3) { //open short position if (ShortSignal == true) { ShortOrder = OrderSend(Symbol(),OP_SELL,LotValue,Bid,5,0,0,"short_forex",MagicNumber,0,Green); } else Print("Error OrderSend : ",GetLastError()); }
I am getting this error by the way not in the tester and not in the code, when I implement it into a chart it starts immediately and ongoing 2 times or more per second ....on all tested charts so far. First it gives back after activating in demo mode is Order Send Error: 0, then it starts.... even if there is nothing to
be sent yet!
- Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it.
It's use is always wrong
- 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./a>
if (ShortSignal == true) { LotValue = NormalizeDouble(LotValue,1); ShortOrder = OrderSend(Symbol(),OP_SELL,LotValue,Bid,10,0,0,"forex_short",MagicNumber,0,Green); } else Print("Error OrderSend : ",GetLastError());
Do not print GetLastError unless you have an error; only if OrderSend fails. If ShortSignal is false, GLE is meaningless.
- Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it.It's use is always wrong
- 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./a>
- Do not print GetLastError unless you have an error; only if OrderSend fails. If ShortSignal is false, GLE is meaningless.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello! First of all, I am a total Newbie to Mql4 and I just started like 3 days ago to discover the possibilities of an EA.
Please bare with me, I really do appreciate any kind of help, that I can get. I was reading here in the forum and in the manual alot about the
NormalizeDouble function, after I am getting the ongoing error OrderSend 4051. I kind of figured out, that this has to do with the Lot Value and maybe the Bid Value given back,
my EA is currently just for NZDJPY, M5 and only short.
I simply cant figure out on my own how to put the NormalizeDouble function correctly, and where. Thank you for your help! I know its anything else than a proper or a clean code, maybe even wrong, but as
I said, please bare with me, I am very green :-)