But this code has got the same problem. I used your code and just replaced Slippage.Pips with an integer value, same error raised after executing.
For learning purpose, I want to write a simple expert which sends just one instant sell or buy order, and I want to adjust everything according to parameters queried from broker.
Any advice?
Please show your modified code. Did you replace your OrderSend with and OrderSend followed by an OrderModify ? With ECN brokers you must use TP=0 and SL=0 when you send the order and then modify the order to add the TP and SL
int ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.1,NormalizeDouble(BuyLimitPrice,Digits),5,NormalizeDouble(StopPrice,Digits),NormalizeDouble(TakeProfitPrice,Digits),"LimitTest",0,0,Blue);
Seems to me the slippage of 5 would be .5 on 5 digit broker so this may need to be 50 or more = 5pips depending on the spread.
Or WHRoeder's post for 4/5 digit brokers as he posted above.
I could be way off since I'm noob, so don't take my answer too seriously but at least this is what is seems like to me.
Agent86:
What is this ?:
NormalizeDouble(StopPrice,Digits)
NormalizeDouble is never, ever, necessary. Don't use it - it's a crutch. Code correctly and it's unnecessary. There are none in my code. E.G.
double minGapStop = MarketInfo(Symbol(), MODE_STOPLEVEL)*Point;
if ((now.close - newSL)*DIR >= minGapStop // Not too close to market no error 130
&& (newSL -SL)*DIR >= Point// no error 1
) { // OK to modify
RaptorUK:
Please show your modified code. Did you replace your OrderSend with and OrderSend followed by an OrderModify ? With ECN brokers you must use TP=0 and SL=0 when you send the order and then modify the order to add the TP and SL
I use NormalizeDouble in my code . . but I am calculating prices not just reading them from somewhere else. If you read a price value from a bar it will already be set to the correct precision, if you add a point value to a price from a bar it will also have the correct precision so doesn't need to be Normalized.
Thanks for your reply.
But this code has got the same problem. I used your code and just replaced Slippage.Pips with an integer value, same error raised after executing.
For learning purpose, I want to write a simple expert which sends just one instant sell or buy order, and I want to adjust everything according to parameters queried from broker.
Any advice?
What is this ?:
NormalizeDouble(StopPrice,Digits)
Should this not be NormalizeDouble(StopPrice*Digits) or (StopPrice*Point) if thats what your trying to do ?
And if you use the code above posted by WHRoeder to adjust for 4/5 digits would you not put it this way ?
And his notes about ECN does not solve this 130 error ?
or some such thing ?
Your code of:
Seems to me the slippage of 5 would be .5 on 5 digit broker so this may need to be 50 or more = 5pips depending on the spread.
Or WHRoeder's post for 4/5 digit brokers as he posted above.
I could be way off since I'm noob, so don't take my answer too seriously but at least this is what is seems like to me.
Re; NormalizeDouble . . .
NormalizeDouble( double value, int digits) https://docs.mql4.com/convert/NormalizeDouble so NormalizeDouble(StopPrice,Digits) rounds the StopPrice to the value of Digits.
By the way, the NormalizeDounble stuff you are referring to was written by mark1808 on 2010.01.18 14:41 :-) he probably lost interest a while ago .. .
What is this ?:
NormalizeDouble(StopPrice,Digits)
NormalizeDouble is never, ever, necessary. Don't use it - it's a crutch. Code correctly and it's unnecessary. There are none in my code. E.G.
This is what I wrote using WHRoeder's code, I don't know if which part is wrong :
It seems WHRoeder's last post is what I'm looking for, I'll give it a try.
And about the broker's type, I don't know about it, how should I find out?
Please show your modified code. Did you replace your OrderSend with and OrderSend followed by an OrderModify ? With ECN brokers you must use TP=0 and SL=0 when you send the order and then modify the order to add the TP and SL
I have a similar problem. I have error 130 and I can't track down why. I would really appreciate some pointers.
I've checked the following...
The SL is delivered as a real price rather than pips away.
It's the correct format... a double and it's been normalised.
It's the correct figure.... confirmed by print in the line above the ordersend.
It's an allowable distance ~50pips
It's not the Boston Technologies Bridge refered to in another thread
I get
Alert: SL 1.4255 Bid 1.4201
OrderSend error 130
I have run out of ideas of where to look next... thanks for any help
V
hi there
my broker wont allow any stop or Take profit to be placed when placing the order
so i have it set to 0
and run a take profit and stoploss straight after
if you broker is same just set your order to 0 stop and 0 take profit
and it the tester should be able to place a trade
NormalizeDouble is never, ever, necessary. Don't use it - it's a crutch. Code correctly and it's unnecessary. There are none in my code. E.G.
And RaptureUK, thanks I get this too.