hi, I ´m working with orders at stop an many orders don´t execute because of error 4107. can anybody explain it for me?. i `m ataching the EA
- error 4107 ordersend
- Confusing Error Code
- Need help with 4107 error
Try using NormalizeDouble() to set correct number of Digits.
,NormalizeDouble(iClose(NULL,0,1)+Trigger,Digits),
Try To Ude RefreshRates() Before ticket= OrderSend(.....)
ticket= OrderSend(Symbol(), OP_SELLSTOP, Lots, iClose(NULL,0,1)-Trigger, 3, Ask+100*Point, Bid-100*Point, "OpenShort", 1, expire, Pink);
- Don't need a RefreshRates unless you have a sleep or another server call before. You can drop the while(true), sleep, and breaks. Simplify.
- Can't open a pending order closer than MarketInfo(Symbol(), MODE_STOPLEVEL)*Point from current market. (On IBFX, stoplevel=30, 3 pips.) Last bar close and current bar open are likely +/- one pip. Depending on the timeframe, even adding ATR might be too close.
- You don't need to normalize values. As long as you're farther then stoplevel away. I have no normalize in my code. I compare doubles >= never equality. SLnew=mathmin(x,Bid-stoplevel). Etc.
- On some brokers you must open the order first and then set the TP/SL. The same applies to pending order I believe. I also found that mt4 was checking the stops against the current price instead of where the price would be. Drop the stops and set them when the order opens.
start(){ for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == Magic // my magic number && OrderType() <= OP_SELL // Open orders only && OrderSymbol() == Symbol() ){ // and symbol if (OrderStopLoss() == 0) { if(!OrderModify( OrderTicket(), OrderOpenPrice, oo.SL, oo.TP, 0)){ Alert(... } ...
- You must adjust TP, SL, and slippage for 5 digit brokers
//++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
WHRoeder:
- Don't need a RefreshRates unless you have a sleep or another server call before.
I do not know, maybe maybe not, but I had a similar problem in the past 12 hours and everything worked out after putting RefrashRates()
qjol:
I do not know, maybe maybe not, but I had a similar problem in the past 12 hours and everything worked out after putting RefrashRates()
ordersend followed by ordermodify? Two ordersends? Very long computation?
Doesn't hurt but won't fix other problems.

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