Hi, is there a function that returns the historic profit of the day ?
signal.it: Hi, is there a function that returns the historic profit of the day ?
One function? No!
Several functions that are related and can be used to access that information? Yes!
Documentation on MQL5: Trade Functions
- www.mql5.com
Trade Functions - Reference on algorithmic/automated trading language for MetaTrader 5
// MQL4&5-code #include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006 #define DAY (24 * 3600) double GetPofitDay( const datetime timeDay ) { const datetime BeginTime = timeDay - (timeDay % DAY); const datetime EndTime = BeginTime + DAY; double Res = 0; for (int i = OrdersHistoryTotal() - 1; (i >= 0) && OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && (OrderCloseTime() >= BeginTime); i--) if ((OrderCloseTime() < EndTime) && (OrderType() <= OP_SELL)) Res += OrderProfit() + OrderCommission() + OrderSwap(); return(Res); } void OnStart() { Alert("Today Profit = " + (string)GetPofitDay(TimeCurrent())); Alert("Yesterday Profit = " + (string)GetPofitDay(TimeCurrent() - DAY)); }
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