Total profit of closed orders

Back to topics list To post a new topic, please log in or register
avatar
20
satsujin 2013.09.05 17:05
 

Hello,

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...

 
avatar
20
satsujin 2013.09.05 17: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?
 
avatar
13008
WHRoeder 2013.09.05 17:41 #
 
avatar
20
satsujin 2013.09.05 19: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.....

 
avatar
484
ydrol 2013.09.05 20: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.


 
avatar
83
BeLikeWater 2015.02.12 09:55 #
 
So then this means that OrderComission() will return a negative number right?
avatar
736
honest_knave 2015.02.12 11:03 #
 
BeLikeWater:
So then this means that OrderComission() will return a negative number right?

 

Back to topics list  

To add comments, please log in or register