Download MetaTrader 5

Total profit of closed orders

To add comments, please log in or register
anoop 2013.09.05 15:05 


I'm new to mql4 so I have some confusion. I want to get the total profit of all orders closed in my last trade ( i have a hedge trade). I know that you can get the profit from OrderProfit but how can you select the trade to get its info if the order is already closed?

Please help...

anoop 2013.09.05 15:26  
Okay I got it. by using order history. But I dont want to get the info of the last order alone, I want all the orders that were open in my last trade since i have multiple orders open in my hedge trade. how do select only those orders?
whroeder1 2013.09.05 15:41  
anoop 2013.09.05 17:54  

Thanks but this seems to use MagicNumber. I know thats a value you can assign when you create the order but since I open a new hedge as soon as my old one is closed wouldnt the same magicnumber be assigned to the new orders also and they would select both old and new orders from the pool? Could use MathRand but that does not maintain magicnumbers through restart of mt4. Some hash function? Probably best to close all trades before restart but then yuo cant account for s system hiccup right?

Also, do you know any way to close all profitable trades first? I'm getting huge drawdown when my hedge trade closes all the negative orders first.....

ydrol 2013.09.05 18:37  

MagicNumber is your reference. It can be different for each order, or the same. You can use a range of numbers. Whatever works for your EA. Manual Orders (I suspect) have Magic of zero. So if you are closeing manual orders that would be different..

To close profitable orders first do two separate loops.

Also Profit = OrderProfit + OrderSwap + OrderComission.

Luis 2015.02.12 08:55  
So then this means that OrderComission() will return a negative number right?
honest_knave 2015.02.12 10:03  
So then this means that OrderComission() will return a negative number right?

To add comments, please log in or register