Yes, it's right, and it can be added also
ticketsProfit[x]=OrderTicket();
x++;
In case you need to work with them later or to close them later...
TY, good tip of yours.
I think it needs a little tweak . . .
double findProfit() // Profit is a double not an int { int total = OrdersTotal(); double profit; // OrderProfit() returns a double not an int for (int cnt = 0 ; cnt <total ; cnt++) { if (OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) // does your OrderSelect() work . . . this checks it { if(OrderProfit() > 0) { profit = profit + OrderProfit(); // you can use profit += OrderProfit() } } else { Print("OrderSelect failed !"); return(-999); // check for -999 from the code that calls the function so that you know you have an error } } return (profit); }
RaptorUK:
I think it needs a little tweak . . .
I think it needs another couple of tweaks.
1) You are using profit to sum values but you do not explicitly set it to zero before you start. (I know MQL4 will do that for you implicitly but not all languages do and it is bad practice)
2) Profit should include OrderSwap() (and also OrderCommission() );
dabbler:
:-) there is always room for improvement.
I think it needs another couple of tweaks.
Thank you guys?
But I still have a problem, something wrong with the order select, any thought?
Thanks again!
I solve the problem thank you all

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 guys,
I am trying to find the sum of my all open profitable trades, I wrote this function any ideas?
Thank you