Help with OrderSend

[Deleted]

can somebody help me please with this OrderSend, it's driving me crazy.

int ticket;

Giving each time Error 129 or 130 wen I use a stop loss

Thanks

zaatar2009:

can somebody help me please with this OrderSend, it's driving me crazy.

Giving each time Error 129 or 130 wen I use a stop loss

I'm amazed it works at all. I can't get this to place orders even without a stop loss, and I think there are two separate problems.

Firstly, you're placing a market order (OP_BUY), but you're specifying a price other than the current ask price (Ask + 10 * Point). If you want to place a pending buy order above the market, use OP_BUYSTOP. But you need to make sure that the requested entry price is at least MODE_STOPLEVEL from the current ask.

Secondly, a t/p or s/l on a buy order is effectively a sell order, and gets taken out at the bid. Are you calculating your s/l from the current ask, or the current bid? If the former, then your s/l may be too tight - it needs to be at least MODE_STOPLEVEL from your entry price (for a stop or limit order) or from the current bid price (for a market order).

[Deleted]
jjc wrote >>

I'm amazed it works at all. I can't get this to place orders even without a stop loss, and I think there are two separate problems.

Firstly, you're placing a market order (OP_BUY), but you're specifying a price other than the current ask price (Ask + 10 * Point). If you want to place a pending buy order above the market, use OP_BUYSTOP. But you need to make sure that the requested entry price is at least MODE_STOPLEVEL from the current ask.

Secondly, a t/p or s/l on a buy order is effectively a sell order, and gets taken out at the bid. Are you calculating your s/l from the current ask, or the current bid? If the former, then your s/l may be too tight - it needs to be at least MODE_STOPLEVEL from your entry price (for a stop or limit order) or from the current bid price (for a market order).

Many many thanks for your help.

I corrected the problem and now it works but with OP_BUYLIMIT, I'm placing a stop loss and a take profit values in my order.

Can you explain what is the difference between OP_BUYLIMIT and OP_BUYSTOP ?

I had also to place a pending sell order and I used OP_SELLLIMIT.

Many thanks agai

zaatar2009:

Can you explain what is the difference between OP_BUYLIMIT and OP_BUYSTOP ?

I'd have a look at this: https://book.mql4.com/trading/orders

A buy limit enters at a price below the market (e.g. limit of 1.3200 versus a current ask of 1.3300). A buy stop enters when the market rises to the given price (e.g. stop at 1.3400 versus a current ask of 1.3300). Vice versa for sells: a sell limit is a higher price than the current bid, and a sell stop is a price below it.

Alternatively, you can think of it in terms of a limit order placing a limit on the amount you're prepared to pay - for example, you want to buy some EURUSD, but the current ask is 1.3300 and you're not prepared to pay more than 1.3200.

[Deleted]
jjc wrote >>

Alternatively, you can think of it in terms of a limit order placing a limit on the amount you're prepared to pay - for example, you want to buy some EURUSD, but the current ask is 1.3300 and you're not prepared to pay more than 1.3200.

I have always favoured buy/sell stop orders.

Your succint example has helped me think outside the box...

A gold star is in the post :)