double p;
if(digits == 5 || digits == 3)
{
p = Point * 10;
}
else
{
p = Point;
}
The above will adjust the precision used based on what your broker is using. Replace Point with p in your code.
The above will adjust the precision used based on what your broker is using. Replace Point with p in your code.
Hi fxcourt,
Thanks for your reply, but the problem is not in the number of digits used by the broker. If I got the digits wrong I wouldn't be able to set a new SL with OrderModify 8 pips from the price. That is the problem- why OrderModify is able to set new SL 8 pips lower but anything less than 8 pips gets error 130???
Cheers,
Tom
Thanks for your reply, but the problem is not in the number of digits used by the broker. If I got the digits wrong I wouldn't be able to set a new SL with OrderModify 8 pips from the price. That is the problem- why OrderModify is able to set new SL 8 pips lower but anything less than 8 pips gets error 130???
You may need to have a closer look at the existing posts on this forum which you've already searched for - error #130 is one of the most common topics, and there's a wealth of information out there about why it happens and how to solve it.
Summarising that information briefly: you get error 130 if you try to place a pending order too close to the current market price, or if you try to set a t/p or s/l which is too tight - either too close to the market price or to the entry price on a pending order, as applicable. In all cases, "too close" is defined by MarketInfo(Symbol(), MODE_STOPLEVEL). Your 5 pips vs 8 pips query may be due to the fact that you can have a tighter s/l or t/p on a pending order than on an order which has already been filled. On a pending order, the t/p or s/l must be at least MODE_STOPLEVEL from the trigger price. On a filled order, the t/p or s/l must be at least MODE_STOPLEVEL from the price at which the order would currently be closed - i.e. from the bid on a buy order, or the ask on a sell order. In other words, the closest permissible t/p or s/l on a filled order is MODE_STOPLEVEL plus the spread.
- 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 traders and coders,
I've searched this forum and found that some people have a similar problem...
When my EA tries to set new SL less than 8 pips from current price on EURUSD I get error 130 (SL too close to current price). I can set SL manually as close as 5 pips from current price.
Part of the code concerned:
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if(OrderType()== OP_BUY && MarketInfo(Symbol(),MODE_ASK)>OrderOpenPrice()+SecureProfitTrig*Point){
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+SecureProfit*Point,OrderTakeProfit(),0,Yellow);
SecureProfitTrig= 80(error 130)/ 90 (works)
SecureProfit=10
my broker is 5 digit
can you help with a word of advice?
Thanks,
Tom