I'm testing and messing around with this function, I read even on the mql4 help window that if the order is pending or closed the value it will take is 0, but when I put an alert with that function it returns 1970.01.01 00:00:00.
It returns that value because the return on OrderCloseTime is datetime type and when is 0 it takes that form on the alerts or I have to type "1970.01.01 00:00:00" if I want to use and If function or something?
1970.01.01 00:00:00
is order expiry time for server setting , Ignore it .
in normal use, to check a postion order or a history order .
Orderclosetime() !=0 it is a history order.
if it is a postion order and not a pending order, orderclosetime() == 0 .
hope it can help u .
int orhito () { return OrdersHistoryTotal(); } // number of closed orders int orto () { return OrdersTotal(); } // number of pending orders //+------------------------------------------------------------------+ bool nLossPerTime() { datetime Ora=TimeCurrent(); MqlDateTime strOra,strTrade; TimeToStruct(Ora,strOra); int lossOfToday=0; /* printf("%02d.%02d.%4d, day of year = %d",strOra.day,strOra.mon, strOra.year,strOra.day_of_year); printf("%02d.%02d.%4d, day of year = %d",strTrade.day,strTrade.mon, strTrade.year,strTrade.day_of_year); */ if (orhito() == 0) return true; else{ for ( int i = orhito(); i >= 0 ; i-- ) { if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) if(OrderSymbol()==Symbol() /*&& OrderMagicNumber() == MagicNumber*/) { //check only in closed trades datetime Trade=OrderCloseTime(); TimeToStruct(Trade,strTrade); if(strTrade.day_of_year < strOra.day_of_year) { return true; break; } if(strTrade.day_of_year == strOra.day_of_year) //if last order day number is = to now day number if(OrderProfit() + OrderCommission() + OrderSwap() < 0) lossOfToday++; //if Order Profit is Negative Count +1 if(lossOfToday >= maxNLossPerDay) { lossOfToday = 0; return false; break; } //if Max Loss Per Day Are Reached Inizialize Counter and return False } } return true; } }
-
If the order is pending or open it returns zero. Zero is datetime 1970.
-
Alert("Order Close Time is ", + OrderCloseTime());
You can not use any Trade Functions until you first select an order.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm testing and messing around with this function, I read even on the mql4 help window that if the order is pending or closed the value it will take is 0, but when I put an alert with that function it returns 1970.01.01 00:00:00.
It returns that value because the return on OrderCloseTime is datetime type and when is 0 it takes that form on the alerts or I have to type "1970.01.01 00:00:00" if I want to use and If function or something?