A trade can remain open for several days or a few seconds so calculating the number open per day can be a little awkward.
semotallica, are you looking to compute the number of trades by day (X trades on Monday, Y trade on Tuesday, etc) or the number of trades per day?
Trades per day is easy, you already know the total trade count by OrdersHistoryTotal() so you just need to determine the total number of days involved in trading and then divide OrdersHistoryTotal() by days of trading.
If you really want to capture/compute the number of trades by day then you'll need to decide whether you count trades as opening or closing on the given day as being a trade for that day.
A trade can remain open for several days or a few seconds so calculating the number open per day can be a little awkward.
Thanks for Replay, All i need number of close trades per day
semotallica, are you looking to compute the number of trades by day (X trades on Monday, Y trade on Tuesday, etc) or the number of trades per day?
Trades per day is easy, you already know the total trade count by OrdersHistoryTotal() so you just need to determine the total number of days involved in trading and then divide OrdersHistoryTotal() by days of trading.
If you really want to capture/compute the number of trades by day then you'll need to decide whether you count trades as opening or closing on the given day as being a trade for that day.
Thanks for clarification, But i need a code to auto that,
For example, at Tuesday there's 5 close trade and Wednesday 6 close trad etc
//+------------------------------------------------------------------+ //| TradesPerDay.mq4 | //| copyright freeware | //+------------------------------------------------------------------+ #include <WinUser32.mqh> //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { datetime LastDate,NextDate ; int ClosedCount=0 ; if ( OrdersHistoryTotal()>0 ) { OrderSelect(0,SELECT_BY_POS,MODE_HISTORY) ; LastDate=TheOrdersDate(OrderCloseTime()) ; for(int i=0;i<OrdersHistoryTotal();i++) { OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) ; NextDate=TheOrdersDate( OrderCloseTime() ); //int MT4 says returns an int when it should return a datetime! if ( LastDate == NextDate ) { ClosedCount++ ; //count } else { Print(TimeToStr(LastDate)," - ", ClosedCount ) ; ClosedCount=1 ; LastDate = NextDate ; } }//end for loop Print(TimeToStr(LastDate)," - ", ClosedCount ) ; } Alert("See Experts Journal for results, expert now being removed" ) ; commitSuicide() ; return(0); } //------ datetime TheOrdersDate( datetime mytime ) { datetime result ; string yy,mm,dd ; string sResult ; yy = IntToStr( TimeYear( mytime ) ); mm = IntToStr( TimeMonth( mytime ) ) ; dd = IntToStr( TimeDay( mytime ) ) ; sResult = yy+"."+mm+"."+dd ; // String date of the format yyyy.mm.dd result = StrToTime( sResult ) ; return(result) ; }//end of function string IntToStr(int myInt ) // Cant find a MT4 function inttostr so this will have to do. { return( myInt ) ; }//end function void commitSuicide() //Don't forget to use #include <WinUser32.mqh> for this function { int h = WindowHandle(Symbol(), Period()); if (h != 0) PostMessageA(h, WM_COMMAND, 33050, 0); }//end functionEnjoyable little exercise

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
Please i need a help to know how can i calculate number of trad was open per day,as i search for that by stander function and i don't found it
Please i need your help
Thanks