# What prices should be used for the target level?

889

When using OrderModify() to set the values of "takeprofit" and "stoploss", should I suppose the "takeprofit" or the "stoploss" is an Ask price or a Bid price for an existing long and short orders respectively?
1401

Takeprofit for Sell (Short) = Bid - takeprofit

Stoploss = Bid + stoploss

Notice the + - and work from there. This is the example.

889

Thanks, Deysmacro.

Therefore, if order '1' is an existing short position, I should use below codes. Correct?

`If(target<Ask) OrderModify(1, OrderOpenPrice(),0,target,0);`
15085

jollydragon: values of "takeprofit" and "stoploss", should I suppose the "takeprofit" or the "stoploss" is an Ask price or a Bid price for an existing long and short orders respectively?
1. You buy at the Ask and Sell at the Bid. So for a Buy order the TP/SL trigger when the Bid reaches the value. For Sells when the Ask reaches the value.
2. deysmacro:

Takeprofit for Sell (Short) = Bid - takeprofit

Stoploss = Bid + stoploss

deysmacro's post assumes that

• There was no slippage.
• The takeprofit does not include the spread (a takeprofit of zero results in the order being closed at the OrderOpenPrice for zero profit.
• The stoploss does include the spread (if stoploss is less than the spread it fails.)

3. My code converts the OrderOpenPrice to a Bid price (subtract spread only for buy orders) Add or subtracts distance+spread. Then convert the Bid price to a Stop price (add spread only for sell orders.)  Distance+spread must be at least MODE_STOPLEVEL.

If you are using a chart price (lowest low/highest high) then for a sell order only, you must add the spread. Chart prices are Bid prices, sells close at the Ask.

15085

 jollydragon: Therefore, if order '1' is an existing short position, I should use below codes. Correct? If your network goes down you never close the order. Why aren't you setting the TP in the OrderSend?
889

WHRoeder:
 If your network goes down you never close the order. Why aren't you setting the TP in the OrderSend?

Dear WHRoeder,

What do you mean with "network goes down"?

You know my code will modify the takeprofit based on lastest market price. Just set takeprofit based on 'Ask' as it's a short order.

15085

jollydragon: What do you mean with "network goes down"? You know my code will modify the takeprofit based on lastest market price. Just set takeprofit based on 'Ask' as it's a short order.
1. PC shutsdown, Airplane mode activated, loose connection, modem dies, lightning strike takes out one of your ISPs repeaters, someone starts digging and cut's their wire: Network goes down!
2. I know that your code will do NOTHING, if it doesn't get any ticks or can't send a message to your broker.
3. The point of TP and SL is that they function on the broker's server. You will be taken out of the order. Don't set a SL and you risk your entire account (up to the margin call.)