Hello
This is probably a simple fix, but I've got a cold.
In my buy function I have
So I'm expecting one open position (short), with, in this case - as I run the back tester to the first order point - one sell order. This is what the journal says:
So I don't understand why the OrdersTotal() function returns 0 when the very previous instant, it has just opened a SELL order.
I've read the article about orders and deals and positions, so I think I'm doing this right. This sell order is open at that point, so I'm expecting OrdersTotal() to return the integer 1.
Can anyone tell me why this is not the case please?
Thanks
...
I've read the article about orders and deals and positions, so I think I'm doing this right. This sell order is open at that point, so I'm expecting OrdersTotal() to return the integer 1.
Can anyone tell me why this is not the case please?
Thanks
Seems you have to read it again See documentation of OrdersTotal() also.
You sent a market order (sell), so when to order is executed, it doesn't exist anymore. OrdersTotal() is related to pending orders.
Thanks for the clarification.
I saw reference in the docs to pending orders and confused it with deals. If I send an order to buy EURUSD, I see an up arrow on the terminal chart. If I open three others *on the same chart*, that's four arrows, 4 sent - and processed - buy orders, and 4 deals. I'm interested in using a function which returns the integer 4 as a result of this. PositionsTotal will return 1. HistoryDealGetInteger() is thus what I (think I) am looking for.

- www.mql5.com
Thanks for the clarification.
I saw reference in the docs to pending orders and confused it with deals. If I send an order to buy EURUSD, I see an up arrow on the terminal chart. If I open three others *on the same chart*, that's four arrows, 4 sent - and processed - buy orders, and 4 deals. I'm interested in using a function which returns the integer 4 as a result of this. PositionsTotal will return 1. HistoryDealGetInteger() is thus what I (think I) am looking for.
HistorySelectByPosition() requires the POSITION_IDENTIFIER. This is a unique number assigned presumably when it is created. Is the most efficient way of doing this by using PositionSelect(SYMBOL)?
No.
You have this code:
if(mresult.retcode==10009 || mresult.retcode==10008) { // Request is completed or order placed Alert("SELL order has been successfully placed with Ticket #",mresult.order,"."); Print("OrdesTotal=",OrdersTotal());
mresult gives you the deal ticket number, so you can use it to get your information :
HistoryDealSelect(mresult.deal); HistoryDealGetInteger(mresult.deal,DEAL_POSITION_ID);
I don't include error checking.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello
This is probably a simple fix, but I've got a cold.
In my buy function I have
OrderSend(mrequest,mresult);
So I'm expecting one open position (short), with, in this case - as I run the back tester to the first order point - one sell order. This is what the journal says:
So I don't understand why the OrdersTotal() function returns 0 when the very previous instant, it has just opened a SELL order.
I've read the article about orders and deals and positions, so I think I'm doing this right. This sell order is open at that point, so I'm expecting OrdersTotal() to return the integer 1.
Can anyone tell me why this is not the case please?
Thanks