One question please ... when I place an order with SL and this order is executed in my EA, I see the order placed (graph + trade TAB) but my SL I see only @ graph (as picture atached).
Is this normal ? Was I supposed to see an order @ trade TAB ? (code also below) ?
Complementing the last post ... see that now, EA placed a new order with a new stop loss and the "old" stop loss disappeared! (Picture attached)
One question please ... when I place an order with SL and this order is executed in my EA, I see the order placed (graph + trade TAB) but my SL I see only @ graph (as picture atached).
Is this normal ? Was I supposed to see an order @ trade TAB ? (code also below) ?
Yes it's how MT5 works, the last SL/TP always replace the old one.
Yes, you need to delete pending orders, IF your expert advisor actually sends it !!
What Alain is trying to say is: when you attach a SL to a POSITION you don't actually have an order sent to market, but this SL will be automatically executed by the trade server if the trigger price is reached.
I think a good article to better understand this situation can be found here: https://www.mql5.com/en/articles/211
![Orders, Positions and Deals in MetaTrader 5 Orders, Positions and Deals in MetaTrader 5](https://c.mql5.com/36/4/orders-positions-and-deals-in-metatrader__1.png)
- 2011.02.01
- MetaQuotes Software Corp.
- www.mql5.com
Yes, you need to delete pending orders, IF your expert advisor actually sends it !!
What Alain is trying to say is: when you attach a SL to a POSITION you don't actually have an order sent to market, but this SL will be automatically executed by the trade server if the trigger price is reached.
I think a good article to better understand this situation can be found here: https://www.mql5.com/en/articles/211
Ok so here relies the question ... what is the best approach ?
1. Send one POSITION + SL - same OrderSend() or
2. Send TWO orders (one for POSITION and ONE for SL) - 2 OrderSend()
Regards
Ok so here relies the question ... what is the best approach ?
1. Send one POSITION + SL - same OrderSend() or
2. Send TWO orders (one for POSITION and ONE for SL) - 2 OrderSend()
Regards
Well, it's a very good approach to ALWAYS send a position with a stop loss attached to it...
Think about the situation where you have any kind of failure while sending the buy stop / sell stop order you want to set as the stop loss... In this case you have the risk to create a position without any kind of stop loss attached to it. So, IMHO, it's a good approach to always send a position with its own SL attached.
It's also possible to have a partial execution, so if you use the second option, you also need to adjust the volume of the second buy stop / sell stop order.
So, I vote for option 1 (position + SL on the same OrderSend() ).
Well, it's a very good approach to ALWAYS send a position with a stop loss attached to it...
Think about the situation where you have any kind of failure while sending the buy stop / sell stop order you want to set as the stop loss... In this case you have the risk to create a position without any kind of stop loss attached to it. So, IMHO, it's a good approach to always send a position with its own SL attached.
It's also possible to have a partial execution, so if you use the second option, you also need to adjust the volume of the second buy stop / sell stop order.
So, I vote for option 1 (position + SL on the same OrderSend() ).
ok ... I will work on option 1. Please give me a clue on how to find the pending order since (1) I cannot see it on the Trade TAB and (2) my delete_pending_order() funcion also cannot find it :)
ok ... I will work on option 1. Please give me a clue on how to find the pending order since (1) I cannot see it on the Trade TAB and (2) my delete_pending_order() funcion also cannot find it :)
Marcelo, when you send an order with a SL attached to it and it becomes a position, please observe on the chart that you have two lines: a green one and a red one. The green line identifies the position price, while the red line identifies the SL price.
Although you cannot see any buy stop / sell stop order on your MT5 terminal, the SL IS PLACED AND WILL AUTOMATICALLY BE EXECUTED BY THE TRADE SERVER WHEN THE TRIGGER PRICE IS REACHED!!!
So don't worry if you cannot see any pending order on your terminal... if you can see a green line and a red line on the chart, then your SL is placed.
Marcelo, when you send an order with a SL attached to it and it becomes a position, please observe on the chart that you have two lines: a green one and a red one. The green line identifies the position price, while the red line identifies the SL price.
Although you cannot see any buy stop / sell stop order on your MT5 terminal, the SL IS PLACED AND WILL AUTOMATICALLY BE EXECUTED BY THE TRADE SERVER WHEN THE TRIGGER PRICE IS REACHED!!!
So don't worry if you cannot see any pending order on your terminal... if you can see a green line and a red line on the chart, then your SL is placed.
FIRST
Ok ... This I understood. However, my question was different from what you exposed.
If the order is there "somewhere"and I cannot see it, how can I delete it?
My delete_orders() is only getting the orders I see on my trade tab so I understand that I am using a wrong process to "visualize/ delete this order".
IOW, I understood the order is there. How can I catch/ reach it?
SECOND
Another point that I explained before is that indeed, I see two lines (green + red) but when the EA places another new order (position + SL) the red line from the previous order dissapear. From angelvoyageur: Yes it's how MT5 works, the last SL/TP always replace the old one.
English is not my mother language but the verb replace means remove one and places a new one (order in this case)
void Apaga_Pending_Orders() { int ord_total=OrdersTotal(); if(ord_total>0) { for(int i=ord_total-1;i>=0;i--) { ulong ticket=OrderGetTicket(i); ZeroMemory(mrequest); mrequest.action=TRADE_ACTION_REMOVE; // immediate order execution mrequest.magic=0; mrequest.order=ticket; mrequest.comment="YouTrade"; // comment if(OrderSend(mrequest,mresult) && (mresult.retcode==TRADE_RETCODE_DONE)) { Print("[TICKET] Order ticket: ",mresult.order," retcode: ",mresult.retcode); } else { Print("Order error: ",GetLastError()," retcode: ",mresult.retcode); ResetLastError(); return; } } } }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
One question please ... when I place an order with SL and this order is executed in my EA, I see the order placed (graph + trade TAB) but my SL I see only @ graph (as picture atached).
Is this normal ? Was I supposed to see an order @ trade TAB ? (code also below) ?