- OrderSend()...4109....???
- [WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you.
- Error 130 Assistance needed please.
Takeprofit for Long (Buy) = Ask + takeprofit
Stoploss = Ask - stoploss
Takeprofit for Sell (Short) = Bid - takeprofit
Stoploss = Bid + stoploss
Notice the + - and work from there. This is the example.
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);
- 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.
- deysmacro:
Takeprofit for Long (Buy) = Ask + takeprofit
Stoploss = Ask - stoploss
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.)
- 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.
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? |
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.
- 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!
- I know that your code will do NOTHING, if it doesn't get any ticks or can't send a message to your broker.
- 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.)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use