- SL and TP can be no closer than MODE_STOPLEVEL. You are placing them at Bid. Use the debugger or print out your variables, and find out why.
-
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't
use it. It's use is usually wrong, as it is in this case.
- Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
- SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 and MetaTrader 4 - MQL4 programming forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 and MetaTrader 4 - MQL4 programming forum
- 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 and MetaTrader 4 - MQL4 programming forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 and MetaTrader 4 - MQL4 programming forum
- Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
-
In the presence of multiple orders (one EA
multiple charts, multiple EAs, manual
trading,) while you are waiting for the current operation (closing, deleting,
modifying) to complete, any number of other operations on other orders could
have concurrently happened and changed the position indexing:
-
For non-FIFO (US brokers,) (or the EA only opens one order per symbol,) you
can simply count down in a position loop, and you won't miss
orders. Get in the habit of always counting down.
Loops and Closing or Deleting Orders - MQL4 and MetaTrader 4 - MQL4 programming forum
For FIFO (US brokers,) and you (potentially) process multiple orders per symbol, you must count up and on a successful operation, reprocess all positions (set index to -1 before continuing.) -
and check OrderSelect in case earlier positions were deleted.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - and if you (potentially) process multiple orders, must call RefreshRates() after server calls if you want to use the Predefined Variables (Bid/Ask) or OrderClosePrice() instead, on the next order/server call.
-
For non-FIFO (US brokers,) (or the EA only opens one order per symbol,) you
can simply count down in a position loop, and you won't miss
orders. Get in the habit of always counting down.
Stanislav Ivanov:
Hi guys,
Ive went through every material on error 4107 for EAs. I have this Expert that constantly returns this error, but Ive made all adjustments to prevent this - stopleve, normalize double , but still nothing. im adding the code and hope someone has ideas.
thanks
Always count down when you close orders.
for(int i=OrdersTotal()-1;i>=0;i--)
After a trading request, always use RefreshRates() if you want to use predefined variables.
Alain Verleyen:
Oh, seems to have forgotten this one, thanks
Always count down when you close orders.
After a trading request, always use RefreshRates() if you want to use predefined variables.
whroeder1:
Thanks
- SL and TP can be no closer than MODE_STOPLEVEL. You are placing them at Bid. Use the debugger or print out your variables, and find out why.
-
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't
use it. It's use is usually wrong, as it is in this case.
- Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
- SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 and MetaTrader 4 - MQL4 programming forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 and MetaTrader 4 - MQL4 programming forum
- 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 and MetaTrader 4 - MQL4 programming forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 and MetaTrader 4 - MQL4 programming forum
- Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
![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 guys,
Ive went through every material on error 4107 for EAs. I have this Expert that constantly returns this error, but Ive made all adjustments to prevent this - stopleve, normalize double , but still nothing. im adding the code and hope someone has ideas.
thanks