pls is my code correct..
I suggest finding "from" like this:
from=iTime(_Symbol, PERIOD_MN1,0); //profit from start of month from=TimeCurrent()-30*24*3600; //profit from one month ago
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
pls is my code correct..
double profit=0.0; datetime from=0, to=0; double start_balance=AccountInfoDouble(ACCOUNT_BALANCE); double end_balance=AccountInfoDouble(ACCOUNT_BALANCE); datetime last_order_time=0; int trades=OrdersHistoryTotal()-1; for(int i=trades; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) continue; if(OrderCloseTime() == iTime(NULL,PERIOD_MN1,0)){ profit += OrderProfit() + OrderSwap()+OrderCommision(); } }
You can try it like this .decrement loop is efficient when looping through history orders
for(int i=0; i<trades; i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) continue;
-
Do not assume history has only closed orders.
OrderType() == 6, 7 in the history pool? - MQL4 programming forum (2017) -
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum (2012)
Taking the last profit and storing it in a variable | MQL4 - MQL4 programming forum #3 (2020) -
Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
"balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)Broker History FXCM Commission - «TICKET»
Rollover - «TICKET»>R/O - 1,000 EUR/USD @0.52 #«ticket» N/A OANDA Balance update
Financing (Swap: One entry for all open orders.)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
pls is my code correct..