Read the documentation?
Check each of your orders for the criteria you specify
Here. I did' n test it.
#define NO_TRADE_PROFIT -99999999999 // using just an impossible number for profit (could be any other) double getFirstProfitOpenTrade(string symbol) { for(int i=0;i<OrdersTotal();i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()==symbol) return(OrderProfit()); } return(NO_TRADE_PROFIT); } double getLastProfitOpenTrade(string symbol) { for(int i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()==symbol) return(OrderProfit()); } return(NO_TRADE_PROFIT); } int start() { double profit_last = getLastProfitOpenTrade(Symbol()); double profit_first = getFirstProfitOpenTrade(Symbol()); double profit_first_usd_jpy = getFirstProfitOpenTrade("USDJPY"); if(profit_last != NO_TRADE_PROFIT) Print("last_profit_is "+ profit_last); // .... remaining code }
abstract_mind:
Here. I did' n test it.
Hi all,
Thank you very much.
Phy, my biggest problem is to correctly understand some of the explanations on the docs, not just because I do not correctly understand programming and the english language does not help too much.
I think with the sample code send by abstract I will try to build the routine I am trying
Thank you once again
Regards
Paulo
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 there,
Can anyone help me on solving a problem I have...my lack or knowledgment on programming cannot help me :o).
I need to get information about open orders. Basically I need to know what is the total profit of the last open trade for a specific currency pair.
Imagine for instance that I have 6 open positions for EURUSD. How can I know the profit value for the last openned trade and for the first openned trade?
Thank you in advance
Regards
Paulo