u can do an error case in ur code and use RefreshRates()
i dont know how to do it right off hand but maybe you can do something like this.
if(Trade==fase)
{
int ErrorCode= GetLastError();
if (ErrorCode=130)
{
RefreshRates();
}
}
again this code might not be right so u should google how to do it.
also, if u havent already do the NormalizeDouble function to round of the numbers.
u can do an error case in ur code and use RefreshRates()
How will that help ?
it could be a temporary issue. he said it was case sensitive so refreshing the rates could fix it.
it could be a temporary issue. he said it was case sensitive so refreshing the rates could fix it.
true.
Raptor, I don't know the spread for the trade above. I have added an log output in the code, the next time the error happens, I will be able to tell you the spread.
But can you tell me, why the spread is important? In what way do I need to take the spead into account, when determining the stoploss?
I send an order with for example:
int ticket = OrderSend(Symbol(), OP_BUY, position_size, Ask, SLIPPAGE, initial_stop, TAKEPROFIT, NULL, EXPERT_ID, 0, Green);
thus the only predefined variable I use when sending orders is: Ask
SLIPPAGE and TAKEPROFIT are both 0.
EXPERT_ID is some unique magic number
position_size is an integer, e.g. 3
initial_stop is my stoploss, which is (in the case of the example above) Bid - risk.
Risk is a value greater than (MODE_STOPLEVEL * Point), in case of the trade in the first post. The risk was: 1.35
thanks for your thoughts.
Raptor, I don't know the spread for the trade above. I have added an log output in the code, the next time the error happens, I will be able to tell you the spread.
But can you tell me, why the spread is important? In what way do I need to take the spead into account, when determining the stoploss?
Well done for adding the Print to the log for future :-)
I always have to think long and hard about where Spread has to be considered and not . . I seem to have a mental block where it is concerned . . . but I think I have this correct.
For a Buy it shouldn't matter, Buy at Ask, SL will happen at Bid, so the Spread is already factored into your OpenPrice. For a Sell it is a different matter . . you Sell at Bid and your SL will be taken by the Ask price . . . where is the Ask price ? well that depends on the spread at the time . . . I think this is correct, please think about it and see if it makes sense . . . I'm more than happy to be corrected if I'm wrong . . . :-)
int ticket = OrderSend(Symbol(), OP_BUY, position_size, Ask, SLIPPAGE, initial_stop, TAKEPROFIT, NULL, EXPERT_ID, 0, Green);EAs must adjust for 4/5 digit brokers, TP, SL, AND slippage. On ECN brokers you must open and THEN set stops.
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits % 2 == 1){ // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262 pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //---- These are adjusted for 5 digit brokers. /* On ECN brokers you must open first and THEN set stops int ticket = OrderSend(...) if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else if (!OrderSelect(ticket, SELECT_BY_POS)) Alert("OrderSelect failed: ", GetLastError()); else if (!OrderModify(OrderTicket()...) Alert("OrderModify failed: ", GetLastError()); */
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have seen many in the forum are struggling with this error.
As I have understood the other threads, the error can be cause by
a: setting a stoploss value too close to the current price
b: a wrong number of digits after 0
Concerning a:
As I have understood. MarketInfo(Symbol(), MODE_STOPLEVEL)) should give me the minimum distance the stoploss needs to have.
So here's an example of a failed trade:
Marekt Info:
Date: 2011/9/15 16:31
Symbol: #ESU1
Stop Level: 75.00000000
Point: 0.01000000
Tick Size: 0.25000000
Tick Value: 12.50000000
Digits: 2.00000000
Thus the minimum distance should be stop level * point, right? so 0.75
So here's my failed order:
2011.09.15 16:32:07 '393930': order sell 18.00 #ESU1 opening at 1201.00 sl: 1202.35 tp: 0.00 failed [Invalid S/L or T/P]
Error is: 130 / invalid stops
stoploss is 1.35 away from opening. So it should be fine. The digits (b) also match.
So why do I get this error?
Also, this error is hard to reproduce. Sometimes it appears. Sometimes it doesn't.
Sometimes it appears for several times after each other.
Any ideas?
Thanks in advance!
shinobi