Stop and freeze level are first things to be considered in these cases.
Huge spreads can be another reason for this error, with information that you gave us is pretty impossible to understand where is the problem.
Stop and freeze level are first things to be considered in these cases.
Huge spreads can be another reason for this error, with information that you gave us is pretty impossible to understand where is the problem.
My function have spread and slipage protection
int SendSellOrder(string sym, double FXlot, int stopLoss,int takeProfit, int magic, int maxspread, int slipage, string FXcomment) { RefreshRates(); if(maxspread > 0 && MarketInfo(sym, MODE_SPREAD) > maxspread) return(0); int digit = (int)MarketInfo(sym, MODE_DIGITS); double sl, tp, ask = MarketInfo(sym, MODE_ASK), point = MarketInfo(sym, MODE_POINT), price = MarketInfo(sym, MODE_BID), stoplevel = MarketInfo(sym, MODE_STOPLEVEL); if (stopLoss != 0) sl = NormalizeDouble(MathMax(ask + (stopLoss * point), ask + stoplevel ), digit); else sl = 0; if (takeProfit != 0) tp = NormalizeDouble(MathMin(price - (takeProfit * point), ask - stoplevel ), digit); else tp = 0; Print("EA Make a Sell for " + sym + " | Vol: " + DoubleToString(FXlot,2) + " | At: " + DoubleToString(price,digit) + " | Sl: " + DoubleToString(sl,digit) + " | Tp:" + DoubleToString(tp,digit) + ""); return(OrderSend(sym, OP_SELL, FXlot, price, slipage, sl, tp, FXcomment + " | SELL", magic)); }
From what I see on your code, you already has a print log on your order send function.
Please, post the log that was printed when the error 130 happens.
This is my metatrader log:
2020.01.15 21:45:03.604 '47443724': order sell 0.06 EURUSD opening at market sl: 1.12591 tp: 1.11377 failed [Invalid S/L or T/P]
And this is my function printed:
2020.01.15 21:45:03.373 EURUSD,M15: EA Make a Sell for EURUSD | Vol: 0.06 | At: 1.11589 | Sl: 1.12591 | Tp:1.11377
This is my metatrader log:
2020.01.15 21:45:03.604 '47443724': order sell 0.06 EURUSD opening at market sl: 1.12591 tp: 1.11377 failed [Invalid S/L or T/P]
And this is my function printed:
2020.01.15 21:45:03.373 EURUSD,M15: EA Make a Sell for EURUSD | Vol: 0.06 | At: 1.11589 | Sl: 1.12591 | Tp:1.11377
100 pip SL and 20 pip TP
Apparently there is no problem realted to SL and TP.
I can suggest to you to normalize also the "price" variable to digits, in order to be sure.
Sometimes, I seen that, without specific reasons, if I don't normalize ask/bid price order send generate errors similar to invalid sl/tp.
I hope this can help.
Apparently there is no problem realted to SL and TP.
I can suggest to you to normalize also the "price" variable to digits, in order to be sure.
Sometimes, I seen that, without specific reasons, if I don't normalize ask/bid price order send generate errors similar to invalid sl/tp.
I hope this can help.
I do this well But nothing changed !!!!!
Apparently there is no problem realted to SL and TP.
I can suggest to you to normalize also the "price" variable to digits, in order to be sure.
Sometimes, I seen that, without specific reasons, if I don't normalize ask/bid price order send generate errors similar to invalid sl/tp.
I hope this can help.
If i send an order with Sl=0 and Tp=0 I dont have any issue !!!
So open order price is ok
Sometimes, on forums I seen words like "With ECN broker you need to send order without SL and TP and set them after the order is opened".
I never understood what they mean because I always worked with ECN brokers and I never had a problem in sending order with SL and TP, but maybe, with some broker, it can really occurs... and maybe the error 130 can happens...
It's just a theory.
Hello my friends.
I have an EA that work correctly. I tested it on Alpari broker
But this ea on forex-time broker some times have error
130 on order send.
BUT i know about minimum tp or sl distance. see this:
I trade EURUSD on this price 1.11600
and I got this
2020.01.15 20:33:22.696 '47443724': order sell 0.03 EURUSD opening at market sl: 1.12101 tp: 1.11399 failed [Invalid S/L or T/P]
Dear Faeze
FXTM is ECN broker, You must first send order without sl & tp(SL & TP = 0), then modify order to set sl & tp.
Happy Writing!!! :)
- 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 my friends.
I have an EA that work correctly. I tested it on Alpari broker
But this ea on forex-time broker some times have error 130 on order send.
BUT i know about minimum tp or sl distance. see this:
I trade EURUSD on this price 1.11600
and I got this
2020.01.15 20:33:22.696 '47443724': order sell 0.03 EURUSD opening at market sl: 1.12101 tp: 1.11399 failed [Invalid S/L or T/P]