Some ECN brokers do not allow sending order with SL/TP.
You need to send it and then modify order for settings them.
I see
NormalizePrice(TP_Level)
Not 0
you need to strip out take and stop and set these to zero when first sending the order and then modify the order with take and stop
here's an example
void BuyOrder(double vol,double stop,double take) { Ticket = OrderSend(Symbol(), OP_BUY, vol, Ask, Slippage, 0, 0, "", MagicNumber, 0, Blue); if(OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { SL = Bid - stop * Point; TP = Ask + take * Point if(!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0)) { Print("OrderModify BUY error - code : ", GetLastError()); Print("WARNING: ORDER #", Ticket, " Failed to set TP/SL"); return; } }
Ok i will try with zero. Thank you, everyone!
SL = Bid - stop * Point; TP = Ask + take * PointYou buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.
- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP would be longer. Don't you want the same/specified amount for either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To
trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (Control-O) → charts → Show ask line.)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am using this part for open orders. One of broker ECN account always give error 130 when EA trying to open orders. But when i try it with DEMO account on the same broker, same account type, it never give error 130. It working well with DEMO account and all of other broker accounts that i tested.
So how to solve this problem?
Thank you.