I found this at OrderModify description:
Notes: Open price and expiration time can be changed only for pending orders.
If unchanged values are passed as the function parameters, the error 1 (ERR_NO_RESULT) will be generated.
For debugging, try to write error codes after OrderSelect / OrderModify functions like this:
if (!OrderSelect(Bear.Ticket1, SELECT_BY_TICKET)) { Print("OrderSelect failed with error code: " + GetLastError()); }
You can try two scripts as example from here: http://www.forexfactory.com/showthread.php?p=3569282, it places TP and SL on ECN.
I found this at OrderModify description:
Notes: Open price and expiration time can be changed only for pending orders.
If unchanged values are passed as the function parameters, the error 1 (ERR_NO_RESULT) will be generated.
For debugging, try to write error codes after OrderSelect / OrderModify functions like this:
I searched through google for how to set stoploss and takeprofit on an ecn broker.
I tried all the examples what could be wrong with my code?
I actually initialized my active open orders ticket number to my variables so that it would work but to no avail on MBtrading
Every trade you do has its own specific OrderTicket() number. That number is given by your broker to the order
You trie to modify it with wrong OrderTicket() number Before you gonna modify you have to select the right trade
Bear.Ticket1 is not your OrderTicket() if it fails OrderModify( ... ) with error invalid ticket for order modify
- Always test return codes including OrderSelect.
- On the creation of an order, you can just select and modify
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.015 0.0150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ OptParameters(); if (Digits % 2 == 1){ // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262 pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //---- These are adjusted for 5 digit brokers. /* On ECN brokers you must open first and THEN set stops int ticket = OrderSend(..., 0,0,...) if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else if (!OrderSelect(ticket, SELECT_BY_TICKET)) Alert("OrderSelect failed: ", GetLastError()); else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0) Alert("OrderModify failed: ", GetLastError()); */
- On a new tick, you must find the open order ticket number as the ticket might already be closed.
for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair. ){ // OrderTicket() is valid here
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I searched through google for how to set stoploss and takeprofit on an ecn broker.
I tried all the examples what could be wrong with my code?
I actually initialized my active open orders ticket number to my variables so that it would work but to no avail on MBtrading