mosta777:
i searched very hard for this issue i want to count total lost orders in order history and total profit orders in the closed orders not open orders .... after i searched i found this code but seems doesnt work dont know what's wrong with it
"doesn't work' can mean many things, but this line:
else return(TotalLost);
should be changed to:
continue;
instead, since you may not have checked all history orders yet.
- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless.
- As Seng said, or just remove the line completely. You want to process all of
history, not just the first entry found.
- Why did you post your MT4 question in the Root / MT5 General
section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - Do not assume history has only closed orders. You need to add
OrderType to your filter.
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum
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 searched very hard for this issue i want to count total lost orders in order history and total profit orders in the closed orders not open orders .... after i searched i found this code but seems doesnt work dont know what's wrong with it
int TotalLostOrders()
{
int TotalLost;
for(int i=OrdersHistoryTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
{
if(OrderProfit()<0)TotalLost++;
else return(TotalLost);
}
}
return(TotalLost);
}