Julio Guerra:
Hi,
I’m looking for any suggestion about this specific code.
This is the original code to check the result of the last closed order.
I don't need the result of the last order, but rather a sum of the OrderProfit() of several closed trades from a predetermined date taken from the open orders. Something like that.
In where the OrderCloseTime come from the HistoryCloseOrder, and the OrderOpenTime, from the order that still open.
Any suggestion will be appreciated. Thanks.
Hi
So in simple terms a function that returns the p+l of closed orders that have closed after the opening of an order ?
Aha , you can use this function then and call it to calculate the p+l after the open time of an order .
double pl_of_closed_after(datetime after_time,//the time after which the order must have closed to be accounted for string _by_symbol_or_null,//the symbol of the order or null (for all symbols) int _by_magic_or_minus_1,//the magic # of the order or -1 for all) int _by_type_or_minus_1,//by order type or -1 for all types bool _add_commissions, bool _add_swaps){ double pl=0.0; int t=OrdersHistoryTotal(); for(int i=0;i<t;i++){ if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)){ //if it closed after this time if(OrderCloseTime()>=after_time){ //and its of the symbol specified or we don't care about the symbol if(OrderSymbol()==_by_symbol_or_null||_by_symbol_or_null==NULL){ //and it's magic number is one we are interested in or we don't care about the magic number if(OrderMagicNumber()==_by_magic_or_minus_1||_by_magic_or_minus_1==-1){ //and it's type is one we want or we don't care if(OrderType()==_by_type_or_minus_1||_by_type_or_minus_1==-1){ //then add to the p+l pl+=OrderProfit(); if(_add_commissions){pl+=OrderCommission();} if(_add_swaps){pl+=OrderSwap();} }}}}} } return(pl); }
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
Hi,
I’m looking for any suggestion about this specific code.
This is the original code to check the result of the last closed order.
I don't need the result of the last order, but rather a sum of the OrderProfit() of several closed trades from a predetermined date taken from the open orders. Something like that.
In where the OrderCloseTime come from the HistoryCloseOrder, and the OrderOpenTime, from the order that still open.
Any suggestion will be appreciated. Thanks.